telegraph package¶
telegraph.api module¶
- class telegraph.api.Telegraph(access_token=None, domain='telegra.ph')[source]¶
Bases:
object
Telegraph API client helper
- Parameters
access_token – access token
domain – domain (e.g. alternative mirror graph.org)
- create_account(short_name, author_name=None, author_url=None, replace_token=True)[source]¶
Create a new Telegraph account
- Parameters
short_name – Account name, helps users with several accounts remember which they are currently using. Displayed to the user above the “Edit/Publish” button on Telegra.ph, other users don’t see this name
author_name – Default author name used when creating new articles
author_url – Default profile link, opened when users click on the author’s name below the title. Can be any link, not necessarily to a Telegram profile or channels
replace_token – Replaces current token to a new user’s token
- create_page(title, content=None, html_content=None, author_name=None, author_url=None, return_content=False)[source]¶
Create a new Telegraph page
- Parameters
title – Page title
content – Content in nodes list format (see doc)
html_content – Content in HTML format
author_name – Author name, displayed below the article’s title
author_url – Profile link, opened when users click on the author’s name below the title
return_content – If true, a content field will be returned
- edit_account_info(short_name=None, author_name=None, author_url=None)[source]¶
- Update information about a Telegraph account.
Pass only the parameters that you want to edit
- Parameters
short_name – Account name, helps users with several accounts remember which they are currently using. Displayed to the user above the “Edit/Publish” button on Telegra.ph, other users don’t see this name
author_name – Default author name used when creating new articles
author_url – Default profile link, opened when users click on the author’s name below the title. Can be any link, not necessarily to a Telegram profile or channels
- edit_page(path, title, content=None, html_content=None, author_name=None, author_url=None, return_content=False)[source]¶
Edit an existing Telegraph page
- Parameters
path – Path to the page
title – Page title
content – Content in nodes list format (see doc)
html_content – Content in HTML format
author_name – Author name, displayed below the article’s title
author_url – Profile link, opened when users click on the author’s name below the title
return_content – If true, a content field will be returned
- get_account_info(fields=None)[source]¶
Get information about a Telegraph account
- Parameters
fields –
List of account fields to return. Available fields: short_name, author_name, author_url, auth_url, page_count
Default: [“short_name”,“author_name”,“author_url”]
- get_page(path, return_content=True, return_html=True)[source]¶
Get a Telegraph page
- Parameters
path – Path to the Telegraph page (in the format Title-12-31, i.e. everything that comes after https://telegra.ph/)
return_content – If true, content field will be returned
return_html – If true, returns HTML instead of Nodes list
- get_page_list(offset=0, limit=50)[source]¶
- Get a list of pages belonging to a Telegraph account
sorted by most recently created pages first
- Parameters
offset – Sequential number of the first page to be returned (default = 0)
limit – Limits the number of pages to be retrieved (0-200, default = 50)
- get_views(path, year=None, month=None, day=None, hour=None)[source]¶
Get the number of views for a Telegraph article
- Parameters
path – Path to the Telegraph page
year – Required if month is passed. If passed, the number of page views for the requested year will be returned
month – Required if day is passed. If passed, the number of page views for the requested month will be returned
day – Required if hour is passed. If passed, the number of page views for the requested day will be returned
hour – If passed, the number of page views for the requested hour will be returned