Pydantic models

Account

class telegraph_api.models.Account(*, short_name: str, author_name: str, author_url: str, access_token: str = None, auth_url: str = None, page_count: int = None)

Represents Account type

access_token: Optional[str]

Optional. Only returned by the createAccount and revokeAccessToken method. Access token of the Telegraph account.

auth_url: Optional[str]

Optional. URL to authorize a browser on telegra.ph and connect it to a Telegraph account.

author_name: str

Default author name used when creating new articles.

author_url: str

Profile link, opened when users click on the author’s name below the title.

page_count: Optional[int]

Optional. Number of pages belonging to the Telegraph account.

short_name: str

Account name, helps users with several accounts remember which they are currently using.

Page

class telegraph_api.models.Page(*, path: str, url: str, title: str, description: str, author_name: str = None, author_url: str = None, image_url: str = None, content: List[Union[Node, str]] = None, views: int, can_edit: bool = None)

PyDantic model for telegra.ph Page

author_name: Optional[str]

Optional. Name of the author, displayed below the title.

author_url: Optional[str]

Optional. 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 channel.

can_edit: Optional[bool]

Optional. Only returned if access_token passed. True, if the target Telegraph account can edit the page.

content: Optional[List[Union[Node, str]]]

Optional. Content of the page.

description: str

Description of the page.

image_url: Optional[str]

Optional. Image URL of the page.

path: str

Path to the page.

title: str

Title of the page.

url: str

URL of the page.

views: int

Number of page views for the page.

PageList

Node

class telegraph_api.models.Node(*, tag: str, attrs: dict = None, children: List[Union[str, Node]] = None)

This abstract object represents a DOM Node.

attrs: Optional[dict]

Optional. Attributes of the DOM element

children: Optional[List[Union[str, Node]]]

Optional. List of child nodes for the DOM element.

tag: str

Name of the DOM element.

Uploaded file

class telegraph_api.models.UploadedFile(*, src: str)

Pydantic model for Uploaded to server File

property extension: str

Extension of file

src: str

Path to telegra.ph file

to_node(caption: str = '') Node

Converts uploaded file object to Node, that can be pasted into Node tree

Parameters

caption – Captions for video or image

Returns

Node object