API Reference

Client

class mystbin.Client(*, session: ClientSession | None = None, root_url: str = 'https://mystb.in')[source]

The main client class that interacts with the mystb.in API.

Parameters:
  • session (Optional[aiohttp.ClientSession]) – The session to use for the HTTP requests. If not provided, a new session will be created.

  • root_url (str) – The root URL for the mystbin instance. Defaults to https://mystb.in.

await close() None[source]

This function is a coroutine.

Closes the internal HTTP session and this client.

await create_paste(*, files: Sequence[File], password: str | None = None, expires: datetime.datetime | None = None) Paste[source]

This function is a coroutine.

Create a single file paste on mystb.in.

Parameters:
  • files (List[File]) – The pre-creates list of files you wish to upload.

  • password (Optional[str]) – The password of the paste, if any.

  • expires (Optional[datetime.datetime]) – When the paste expires, if any.

Returns:

The paste that was created.

Return type:

mystbin.Paste

await delete_paste(security_token: str, /) None[source]

This function is a coroutine.

Delete a paste.

Parameters:

security_token (str) – The security token relating to the paste to delete.

await get_paste(paste_id: str, *, password: str | None = None, raw: Literal[False]) Paste[source]
await get_paste(paste_id: str, *, password: str | None = None, raw: Literal[True]) list[str]
await get_paste(paste_id: str, *, password: str | None = None) Paste

This function is a coroutine.

Fetch a paste.

Parameters:
  • paste_id (str) – The paste id to fetch.

  • password (Optional[str]) – The password of the paste, if any.

  • raw (bool) – Whether to return the raw file(s) content or a Paste instance. Defaults to False.

Returns:

The paste data returned.

Return type:

Union[Paste, List[str]]

Paste

class mystbin.Paste[source]

Represents a Paste object from mystbin instances.

id

The ID of this paste.

Type:

str

created_at

When this paste was created in UTC.

Type:

datetime.datetime

files

The list of files within this Paste.

Type:

List[mystbin.File]

property url: str

The paste URL.

Return type:

str

property expires: datetime | None

When the paste expires, if at all.

Return type:

Optional[datetime.datetime]

property views: int | None

The pastes view count, if any.

Return type:

Optional[int]

property security_token: str | None

The pastes security token, if any.

Return type:

Optional[str]

await delete() None[source]

This function is a coroutine.

This method will delete this paste from the mystbin instance.

Raises:

ValueError – The paste requires the security token to be present.

File

class mystbin.File(*, filename: str, content: str)[source]

Represents a single file within a mystb.in paste.

filename

The file’s name.

Type:

str

content

The file’s contents.

Type:

str

property lines_of_code: int

The total lines of code this file has.

Return type:

int

property character_count: int

The total character count of this file.

Return type:

int

property annotation: str

The files annotation.

Return type:

str

property parent_id: str

The files parent paste ID.

Return type:

str