mastodon#
Description#
Plugin to interact with Mastodon instances.
It requires an active API token associated to an app registered on the instance. In order to get one:
Open
https://<mastodon-base-url>/settings/applications/Create a new application
Select the scopes relevant for your specific usage.
Take note of the token reported on the Your access token row.
The notifications subscription service requires the ngrok plugin and the
http backend to be enabled, since we need to expose an external URL that
the Mastodon instance can call when new events occur.
Configuration#
mastodon:
# [Required]
# Base URL of the Mastodon web server, in the form of ``https://<domain-name>``.
base_url: # type=str
# [Optional]
# Access token as reported on ``https://<base_url>/settings/applications/<app_id>``.
# access_token: # type=Optional[str]
Actions#
Module reference#
- class platypush.plugins.mastodon.MastodonPlugin(base_url: str, access_token: str | None = None, **kwargs)[source]#
Bases:
PluginPlugin to interact with Mastodon instances.
It requires an active API token associated to an app registered on the instance. In order to get one:
Open
https://<mastodon-base-url>/settings/applications/Create a new application
Select the scopes relevant for your specific usage.
Take note of the token reported on the Your access token row.
The notifications subscription service requires the
ngrokplugin and the http backend to be enabled, since we need to expose an external URL that the Mastodon instance can call when new events occur.- __init__(base_url: str, access_token: str | None = None, **kwargs)[source]#
- Parameters:
base_url – Base URL of the Mastodon web server, in the form of
https://<domain-name>.access_token – Access token as reported on
https://<base_url>/settings/applications/<app_id>.
- add_accounts_to_list(list_id: int, account_ids: Sequence[str], **kwargs)[source]#
Add accounts to a list.
It requires the specified API token to have the
write:listspermission.- Parameters:
list_id – List ID.
account_ids – Accounts that should be added.
kwargs –
base_url/access_tokenoverride.
- Returns:
{ "id": 8, "replies_policy": "string", "title": "strippedstring" }
- add_favourite_status(status_id: str, **kwargs)[source]#
Favourite a status.
It requires the specified API token to have the
write:favouritespermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- add_featured_tag(name: str, **kwargs) dict[source]#
Add a featured tag to the current account.
It requires the specified API token to have the
write:accountspermission.- Parameters:
name – Hashtag name.
kwargs –
base_url/access_tokenoverride.
- Returns:
{ "id": 81, "last_status": "2020-01-01T00:00:00+00:00", "name": "string", "statuses_count": 26 }
- block_account(account_id: str, **kwargs)[source]#
Block a given account ID.
It requires the specified API token to have the
write:blockspermission.- Parameters:
account_id – Account ID.
kwargs –
base_url/access_tokenoverride.
- bookmark_status(status_id: str, **kwargs)[source]#
Add a status to the bookmarks.
It requires the specified API token to have the
write:bookmarkspermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- create_filter(phrase: str, context: Iterable[str], irreversible: bool | None = None, whole_word: bool | None = None, expires_in: int | None = None, **kwargs) dict[source]#
Create a new filter.
It requires the specified API token to have the
write:filterspermission.- Parameters:
phrase – Text to be filtered.
context – Array of enumerable strings:
home,notifications,public,thread. At least one context must be specified.irreversible – Should the server irreversibly drop matching entities from home and notifications?
whole_word – Consider word boundaries?
expires_in – Expires in the specified number of seconds.
kwargs –
base_url/access_tokenoverride.
- Returns:
{ "context": "Which context(s) this filter applies to. Possible values: home, notifications, public, thread", "expires_at": "2020-01-01T00:00:00+00:00", "id": 39, "irreversible": true, "phrase": "strippedstring", "whole_word": true }
- create_list(title: str, replies_policy: str = 'list', **kwargs) dict[source]#
Create a new list.
It requires the specified API token to have the
write:listspermission.- Parameters:
title – List title.
replies_policy – Possible values:
none,followingorlist. Default:list.kwargs –
base_url/access_tokenoverride.
- Returns:
{ "id": 94, "replies_policy": "string", "title": "strippedstring" }
- delete_list(list_id: int, **kwargs)[source]#
Delete a list.
It requires the specified API token to have the
write:listspermission.- Parameters:
list_id – List ID.
kwargs –
base_url/access_tokenoverride.
- dismiss_notifications(notification_id: str | None = None, **kwargs)[source]#
Dismiss notifications.
It requires the specified API token to have the
write:notificationspermission.- Parameters:
notification_id – Dismiss only this notification.
kwargs –
base_url/access_tokenoverride.
- follow_account(account_id: str, notify: bool = False, reblogs: bool = True, **kwargs)[source]#
Follow a given account ID.
It requires the specified API token to have the
write:followspermission.- Parameters:
account_id – Account ID.
notify – Receive notifications when this account posts a new status (default: False).
reblogs – Receive this account’s reblogs on your timeline (default: True).
kwargs –
base_url/access_tokenoverride.
- get_account(account_id: str, **kwargs) dict[source]#
Retrieve an account by ID.
It requires the specified API token to have
read:accountspermissions.- Parameters:
account_id – Account ID to retrieve.
kwargs –
base_url/access_tokenoverride.
- Returns:
{ "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 44, "following_count": 42, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" }
- get_blocked_accounts(max_id: str | None = None, since_id: str | None = None, limit: int = 20, **kwargs) Iterable[dict][source]#
Retrieve the list of blocked accounts.
It requires the specified API token to have the
read:blockspermission.- Parameters:
max_id – Return results older than this ID.
since_id – Return results newer than this ID.
limit – Maximum number of results (default: 20).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 92, "following_count": 48, "group": true, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": false, "note": "string", "url": "https://example.org", "username": "admin" } ]
- get_bookmarked_statuses(min_id: str | None = None, max_id: str | None = None, limit: int = 20, **kwargs) Iterable[dict][source]#
Retrieve the list of statuses bookmarked by the user.
It requires the specified API token to have the
read:bookmarkspermission.- Parameters:
min_id – Return results newer than this ID.
max_id – Return results older than this ID.
limit – Maximum number of results (default: 20).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "account": { "avatar": "https://example.org", "bot": true, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 34, "following_count": 88, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": false, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": true, "favourites_count": 1, "hashtags": [ { "history": [ { "accounts": 95, "day": "2020-01-01", "uses": 95 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": true, "pinned": true, "reblogged": false, "reblogs_count": 50, "replies_count": 45, "sensitive": true, "url": "https://example.org" } ]
- get_conversations(min_id: str | None = None, max_id: str | None = None, limit: int = 20, **kwargs) Iterable[dict][source]#
Get a list of user conversations.
It requires the specified API token to have the
read:statusespermission.- Parameters:
min_id – Return results newer than this ID.
max_id – Return results older than this ID.
limit – Maximum number of results (default: 20).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "accounts": [ { "avatar": "https://example.org", "bot": true, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 61, "following_count": 14, "group": true, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" } ], "id": 37, "last_status": { "account": { "avatar": "https://example.org", "bot": true, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 88, "following_count": 78, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": false, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": true, "favourites_count": 66, "hashtags": [ { "history": [ { "accounts": 14, "day": "2020-01-01", "uses": 67 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": false, "pinned": false, "reblogged": false, "reblogs_count": 70, "replies_count": 77, "sensitive": true, "url": "https://example.org" }, "unread": true } ]
- get_favourited_statuses(min_id: str | None = None, max_id: str | None = None, limit: int = 20, **kwargs) Iterable[dict][source]#
Retrieve the list of statuses favourited by the account.
It requires the specified API token to have the
read:favouritespermission.- Parameters:
min_id – Return results newer than this ID.
max_id – Return results older than this ID.
limit – Maximum number of results (default: 20).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "account": { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": false, "display_name": "Name Surname", "followers_count": 28, "following_count": 65, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": true, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": true, "favourites_count": 94, "hashtags": [ { "history": [ { "accounts": 4, "day": "2020-01-01", "uses": 1 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": true, "pinned": false, "reblogged": true, "reblogs_count": 79, "replies_count": 65, "sensitive": false, "url": "https://example.org" } ]
- get_featured_lists(account_id: str, max_id: str | None = None, since_id: str | None = None, limit: int = 20, offset: int = 0, **kwargs) Iterable[dict][source]#
Retrieve the list that you have added a certain account to.
It requires the specified API token to have the
read:listspermission.- Parameters:
account_id – Account ID.
max_id – Return results older than this ID.
since_id – Return results newer than this ID.
limit – Maximum number of results (default: 20).
offset – Return results from this offset (default: 0).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "id": 12, "title": "strippedstring" } ]
- get_featured_tags(account_id: str | None = None, max_id: str | None = None, since_id: str | None = None, limit: int = 20, offset: int = 0, **kwargs) Iterable[dict][source]#
Retrieve the list of featured hashtags of an account.
It requires the specified API token to have the
read:accountspermission.- Parameters:
account_id – Account ID (if not specified then retrieve the featured tags of the current account).
max_id – Return results older than this ID.
since_id – Return results newer than this ID.
limit – Maximum number of results (default: 20).
offset – Return results from this offset (default: 0).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "id": 26, "last_status": "2020-01-01T00:00:00+00:00", "name": "string", "statuses_count": 77 } ]
- get_filters(**kwargs) Iterable[dict][source]#
Retrieve the list of filters created by the account.
It requires the specified API token to have the
read:filterspermission.- Parameters:
kwargs –
base_url/access_tokenoverride.- Returns:
[ { "context": "Which context(s) this filter applies to. Possible values: home, notifications, public, thread", "expires_at": "2020-01-01T00:00:00+00:00", "id": 84, "irreversible": true, "phrase": "strippedstring", "whole_word": true } ]
- get_followers(account_id: str, max_id: str | None = None, since_id: str | None = None, limit: int = 20, offset: int = 0, **kwargs) Iterable[dict][source]#
Retrieve the list of followers of an account.
It requires the specified API token to have the
read:accountspermission.- Parameters:
account_id – Account ID.
max_id – Return results older than this ID.
since_id – Return results newer than this ID.
limit – Maximum number of results (default: 20).
offset – Return results from this offset (default: 0).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 48, "following_count": 7, "group": true, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" } ]
- get_following(account_id: str, max_id: str | None = None, since_id: str | None = None, limit: int = 20, offset: int = 0, **kwargs) Iterable[dict][source]#
Retrieve the list of accounts followed by a specified account.
It requires the specified API token to have the
read:accountspermission.- Parameters:
account_id – Account ID.
max_id – Return results older than this ID.
since_id – Return results newer than this ID.
limit – Maximum number of results (default: 20).
offset – Return results from this offset (default: 0).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "avatar": "https://example.org", "bot": true, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": false, "display_name": "Name Surname", "followers_count": 2, "following_count": 49, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" } ]
- get_hashtag_timeline(hashtag: str, local: bool = False, only_media: bool = False, min_id: str | None = None, max_id: str | None = None, limit: int = 20, offset: int = 0, **kwargs) Iterable[dict][source]#
Get a list of statuses associated to a hashtag.
It requires the specified API token to have the
read:statusespermission.- Parameters:
hashtag – Hashtag to search.
local – Retrieve only local statuses (default:
False).only_media – Retrieve only statuses with media attached (default:
False).min_id – Return results newer than this ID.
max_id – Return results older than this ID.
limit – Maximum number of results (default: 20).
offset – Return results from this offset (default: 0).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "account": { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": false, "display_name": "Name Surname", "followers_count": 64, "following_count": 86, "group": true, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": false, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": false, "favourites_count": 36, "hashtags": [ { "history": [ { "accounts": 42, "day": "2020-01-01", "uses": 70 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": true, "pinned": true, "reblogged": true, "reblogs_count": 75, "replies_count": 84, "sensitive": false, "url": "https://example.org" } ]
- get_home_timeline(local: bool = False, only_media: bool = False, min_id: str | None = None, max_id: str | None = None, limit: int = 20, offset: int = 0, **kwargs) Iterable[dict][source]#
Get a list of statuses from the followed users.
It requires the specified API token to have the
read:statusespermission.- Parameters:
local – Retrieve only local statuses (default:
False).only_media – Retrieve only statuses with media attached (default:
False).min_id – Return results newer than this ID.
max_id – Return results older than this ID.
limit – Maximum number of results (default: 20).
offset – Return results from this offset (default: 0).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "account": { "avatar": "https://example.org", "bot": true, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 14, "following_count": 90, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": false, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": true, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": true, "favourites_count": 27, "hashtags": [ { "history": [ { "accounts": 14, "day": "2020-01-01", "uses": 95 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": true, "pinned": false, "reblogged": false, "reblogs_count": 67, "replies_count": 24, "sensitive": false, "url": "https://example.org" } ]
- get_list_accounts(list_id: int | None = None, min_id: str | None = None, max_id: str | None = None, limit: int = 20, **kwargs) Iterable[dict][source]#
Get the accounts in a list.
It requires the specified API token to have the
read:listspermission.- Parameters:
list_id – List ID.
min_id – Return results newer than this ID.
max_id – Return results older than this ID.
limit – Maximum number of results (default: 20).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 34, "following_count": 53, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": false, "note": "string", "url": "https://example.org", "username": "admin" } ]
- get_list_timeline(list_id: str, min_id: str | None = None, max_id: str | None = None, limit: int = 20, offset: int = 0, **kwargs) Iterable[dict][source]#
Get a list of statuses from a list timeline.
It requires the specified API token to have the
read:listspermission.- Parameters:
list_id – List ID.
min_id – Return results newer than this ID.
max_id – Return results older than this ID.
limit – Maximum number of results (default: 20).
offset – Return results from this offset (default: 0).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "account": { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 20, "following_count": 20, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": false, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": true, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": false, "favourites_count": 92, "hashtags": [ { "history": [ { "accounts": 32, "day": "2020-01-01", "uses": 19 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": false, "pinned": true, "reblogged": false, "reblogs_count": 86, "replies_count": 7, "sensitive": false, "url": "https://example.org" } ]
- get_lists(list_id: int | None = None, **kwargs) dict | Iterable[dict][source]#
Get the lists owned by the logged user.
It requires the specified API token to have the
read:listspermission.- Parameters:
list_id – Retrieve a specific list ID (default: retrieve all).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "id": 87, "replies_policy": "string", "title": "strippedstring" } ]
- get_muted_accounts(max_id: str | None = None, since_id: str | None = None, limit: int = 20, **kwargs) Iterable[dict][source]#
Retrieve the list of muted accounts.
It requires the specified API token to have the
read:mutespermission.- Parameters:
max_id – Return results older than this ID.
since_id – Return results newer than this ID.
limit – Maximum number of results (default: 20).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 32, "following_count": 33, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": false, "note": "string", "url": "https://example.org", "username": "admin" } ]
- get_notifications(notification_id: str | None = None, min_id: str | None = None, max_id: str | None = None, limit: int = 20, **kwargs) dict | Iterable[dict][source]#
Get the list of notifications of the user.
It requires the specified API token to have the
read:notificationspermission.- Parameters:
notification_id – If specified then retrieve only the notification associated to this ID.
min_id – Return results newer than this ID.
max_id – Return results older than this ID.
limit – Maximum number of results (default: 20).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "account": { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": false, "display_name": "Name Surname", "followers_count": 97, "following_count": 25, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": false, "note": "string", "url": "https://example.org", "username": "admin" }, "created_at": "2020-01-01T00:00:00+00:00", "id": "string", "mention": { "id": 77, "url": "https://mastodon.social/@user", "username": "user" }, "status": { "account": { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 49, "following_count": 93, "group": true, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": false, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": true, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": false, "favourites_count": 27, "hashtags": [ { "history": [ { "accounts": 24, "day": "2020-01-01", "uses": 24 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": true, "pinned": true, "reblogged": false, "reblogs_count": 21, "replies_count": 77, "sensitive": false, "url": "https://example.org" }, "type": "string" } ]
- get_public_timeline(local: bool = False, remote: bool = False, only_media: bool = False, min_id: str | None = None, max_id: str | None = None, limit: int = 20, offset: int = 0, **kwargs) Iterable[dict][source]#
Get a list of statuses from the public timeline.
It requires the specified API token to have the
read:statusespermission.- Parameters:
local – Retrieve only local statuses (default:
False).remote – Retrieve only remote statuses (default:
False).only_media – Retrieve only statuses with media attached (default:
False).min_id – Return results newer than this ID.
max_id – Return results older than this ID.
limit – Maximum number of results (default: 20).
offset – Return results from this offset (default: 0).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "account": { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 83, "following_count": 79, "group": true, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": true, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": false, "favourites_count": 48, "hashtags": [ { "history": [ { "accounts": 98, "day": "2020-01-01", "uses": 67 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": false, "pinned": true, "reblogged": true, "reblogs_count": 79, "replies_count": 23, "sensitive": false, "url": "https://example.org" } ]
- get_status(status_id: str, **kwargs) dict[source]#
Get a status by ID.
It requires the specified API token to have the
read:statusespermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- Returns:
{ "account": { "avatar": "https://example.org", "bot": true, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": false, "display_name": "Name Surname", "followers_count": 45, "following_count": 91, "group": true, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": false, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": true, "favourites_count": 46, "hashtags": [ { "history": [ { "accounts": 75, "day": "2020-01-01", "uses": 95 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": false, "pinned": false, "reblogged": false, "reblogs_count": 30, "replies_count": 64, "sensitive": true, "url": "https://example.org" }
- get_statuses(account_id: str, min_id: str | None = None, max_id: str | None = None, limit: int = 20, offset: int = 0, **kwargs) Iterable[dict][source]#
Retrieve statuses by account ID.
It requires the specified API token to have the
read:statusespermission.- Parameters:
account_id – Account ID.
min_id – Return results newer than this ID.
max_id – Return results older than this ID.
limit – Maximum number of results (default: 20).
offset – Return results from this offset (default: 0).
kwargs –
base_url/access_tokenoverride.
- Returns:
[ { "account": { "avatar": "https://example.org", "bot": true, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 91, "following_count": 1, "group": true, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": false, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": false, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": true, "favourites_count": 33, "hashtags": [ { "history": [ { "accounts": 51, "day": "2020-01-01", "uses": 86 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": true, "pinned": true, "reblogged": true, "reblogs_count": 23, "replies_count": 60, "sensitive": true, "url": "https://example.org" } ]
- mark_conversation_as_read(conversation_id: int, **kwargs)[source]#
Mark a conversation as read.
It requires the specified API token to have the
write_conversationspermission.- Parameters:
conversation_id – Conversation ID.
kwargs –
base_url/access_tokenoverride.
- mute_account(account_id: str, **kwargs)[source]#
Mute a given account ID.
It requires the specified API token to have the
write:mutespermission.- Parameters:
account_id – Account ID.
kwargs –
base_url/access_tokenoverride.
- mute_status(status_id: str, **kwargs)[source]#
Mute updates on a status.
It requires the specified API token to have the
write:mutespermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- pin_account(account_id: str, **kwargs)[source]#
Pin a given account ID to your profile.
It requires the specified API token to have the
write:accountspermission.- Parameters:
account_id – Account ID.
kwargs –
base_url/access_tokenoverride.
- pin_status(status_id: str, **kwargs)[source]#
Pin a status to the profile.
It requires the specified API token to have the
write:accountspermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- publish_status(status: str, in_reply_to_id: str | None = None, media_ids: Iterable[str] | None = None, sensitive: bool | None = None, spoiler_text: str | None = None, visibility: str | None = None, **kwargs) dict[source]#
Publish a new status.
It requires the specified API token to have the
write:statusespermission.- Parameters:
status – Content of the status to publish.
in_reply_to_id – Post the status in reply to this status ID.
media_ids – Optional list of media IDs to add as attachments.
sensitive – Set to true if sensitive.
spoiler_text – Set for optional spoiler text.
visibility – Supported values:
public,unlisted,privateanddirect.kwargs –
base_url/access_tokenoverride.
- Returns:
{ "account": { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": false, "display_name": "Name Surname", "followers_count": 13, "following_count": 88, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": false, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": false, "favourites_count": 24, "hashtags": [ { "history": [ { "accounts": 21, "day": "2020-01-01", "uses": 34 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": false, "pinned": true, "reblogged": true, "reblogs_count": 2, "replies_count": 40, "sensitive": false, "url": "https://example.org" }
- reblog_status(status_id: str, **kwargs)[source]#
Reblog (a.k.a. reshare/boost) a status.
It requires the specified API token to have the
write:statusespermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- register_account(username: str, email: str, password: str, locale: str = 'en', reason: str | None = None, **kwargs) dict[source]#
Register a new account.
It requires the specified API token to have
write:accountspermissions.- Parameters:
username – User name.
email – User’s email address (must be a valid address).
password – The password used for the first login.
locale – Language/encoding for the confirmation email.
reason – Text that will be reviewed by moderators if registrations require manual approval.
kwargs –
base_url/access_tokenoverride.
- Returns:
{ "access_token": "string", "created_at": "2020-01-01T00:00:00+00:00", "scope": "read write follow push", "token_type": "Bearer" }
- remove_accounts_from_list(list_id: int, account_ids: Sequence[str], **kwargs)[source]#
Remove accounts from a list
It requires the specified API token to have the
write:listspermission.- Parameters:
list_id – List ID.
account_ids – Accounts that should be removed.
kwargs –
base_url/access_tokenoverride.
- Returns:
{ "id": 15, "replies_policy": "string", "title": "strippedstring" }
- remove_conversation(conversation_id: int, **kwargs)[source]#
Remove a conversation by ID.
It requires the specified API token to have the
write_conversationspermission.- Parameters:
conversation_id – Conversation ID.
kwargs –
base_url/access_tokenoverride.
- remove_favourite_status(status_id: str, **kwargs)[source]#
Undo a status favourite action.
It requires the specified API token to have the
write:favouritespermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- remove_featured_tag(tag_id: int, **kwargs)[source]#
Remove a featured tag from the current account.
It requires the specified API token to have the
write:accountspermission.- Parameters:
tag_id – Hashtag ID.
kwargs –
base_url/access_tokenoverride.
- remove_filter(filter_id: int, **kwargs)[source]#
Remove a filter.
It requires the specified API token to have the
write:filterspermission.- Parameters:
filter_id – Filter ID.
kwargs –
base_url/access_tokenoverride.
- remove_status(status_id: str, **kwargs)[source]#
Remove a status by ID.
It requires the specified API token to have the
read:statusespermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- search(query: str, type: str | None = None, min_id: str | None = None, max_id: str | None = None, limit: int = 20, offset: int = 0, following: bool = False, **kwargs) Mapping[str, Iterable[dict]][source]#
Perform a search.
- Parameters:
query – Search query.
type –
Filter by type. Supported types:
accountshashtagsstatuses
min_id – Return results newer than this ID.
max_id – Return results older than this ID.
limit – Maximum number of results (default: 20).
offset – Return results from this offset (default: 0).
following – Only return results from accounts followed by the user (default: False).
kwargs –
base_url/access_tokenoverride.
- Returns:
{ "accounts": [ { "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": false, "display_name": "Name Surname", "followers_count": 1, "following_count": 69, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": false, "note": "string", "url": "https://example.org", "username": "admin" } ], "hashtags": [ { "history": [ { "accounts": 9, "day": "2020-01-01", "uses": 81 } ], "name": "hashtag", "url": "https://example.org" } ], "statuses": [ { "account": { "avatar": "https://example.org", "bot": true, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 26, "following_count": 60, "group": false, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": true, "note": "string", "url": "https://example.org", "username": "admin" }, "attachments": [ { "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" } ], "bookmarked": true, "content": "string", "created_at": "2020-01-01T00:00:00+00:00", "favourited": false, "favourites_count": 14, "hashtags": [ { "history": [ { "accounts": 25, "day": "2020-01-01", "uses": 78 } ], "name": "hashtag", "url": "https://example.org" } ], "id": "465712675261411379", "in_reply_to_account_id": "126124742755599275", "in_reply_to_id": "328498477392235514", "muted": true, "pinned": true, "reblogged": true, "reblogs_count": 42, "replies_count": 60, "sensitive": true, "url": "https://example.org" } ] }
- set_account_note(account_id: str, note: str, **kwargs)[source]#
Set a private note for an account.
It requires the specified API token to have the
write:accountspermission.- Parameters:
account_id – Account ID.
note – Note content (HTML is supported).
kwargs –
base_url/access_tokenoverride.
- unblock_account(account_id: str, **kwargs)[source]#
Unblock a given account ID.
It requires the specified API token to have the
write:blockspermission.- Parameters:
account_id – Account ID.
kwargs –
base_url/access_tokenoverride.
- undo_bookmark_status(status_id: str, **kwargs)[source]#
Remove a status from the bookmarks.
It requires the specified API token to have the
write:bookmarkspermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- undo_reblog_status(status_id: str, **kwargs)[source]#
Undo a status reblog.
It requires the specified API token to have the
write:statusespermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- unfollow_account(account_id: str, **kwargs)[source]#
Unfollow a given account ID.
It requires the specified API token to have the
write:followspermission.- Parameters:
account_id – Account ID.
kwargs –
base_url/access_tokenoverride.
- unmute_account(account_id: str, **kwargs)[source]#
Unmute a given account ID.
It requires the specified API token to have the
write:mutespermission.- Parameters:
account_id – Account ID.
kwargs –
base_url/access_tokenoverride.
- unmute_status(status_id: str, **kwargs)[source]#
Restore updates on a status.
It requires the specified API token to have the
write:mutespermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- unpin_account(account_id: str, **kwargs)[source]#
Unpin a given account ID from your profile.
It requires the specified API token to have the
write:accountspermission.- Parameters:
account_id – Account ID.
kwargs –
base_url/access_tokenoverride.
- unpin_status(status_id: str, **kwargs)[source]#
Remove a pinned status.
It requires the specified API token to have the
write:accountspermission.- Parameters:
status_id – Status ID.
kwargs –
base_url/access_tokenoverride.
- update_account(discoverable: bool | None = None, bot: bool | None = None, display_name: str | None = None, note: str | None = None, avatar: str | None = None, header: str | None = None, locked: bool | None = None, privacy: str | None = None, sensitive: bool | None = None, language: str | None = None, metadata: Iterable[Mapping] | None = None, **kwargs) dict[source]#
Updates the properties of the account associated to the access token.
It requires the specified API token to have
write:accountspermissions.- Parameters:
discoverable – Whether the account should be shown in the profile directory.
bot – Whether the account is a bot.
display_name – The display name to use for the profile.
note – The account bio (HTML is supported).
avatar – Path to an avatar image.
header – Path to a header image.
locked – Whether manual approval of follow requests is required.
privacy – Default post privacy for authored statuses.
sensitive – Whether to mark authored statuses as sensitive by default.
language – Default language to use for authored statuses (ISO 6391 code).
metadata – Profile metadata items with
nameandvalue.kwargs –
base_url/access_tokenoverride.
- Returns:
{ "avatar": "https://example.org", "bot": false, "created_at": "2020-01-01T00:00:00+00:00", "discoverable": true, "display_name": "Name Surname", "followers_count": 42, "following_count": 64, "group": true, "header": "https://example.org", "id": "933166884256682462", "last_status_at": "2020-01-01T00:00:00+00:00", "locked": false, "note": "string", "url": "https://example.org", "username": "admin" }
- update_filter(filter_id: int, phrase: str | None = None, context: Iterable[str] | None = None, irreversible: bool | None = None, whole_word: bool | None = None, expires_in: int | None = None, **kwargs) dict[source]#
Update a filter.
It requires the specified API token to have the
write:filterspermission.- Parameters:
filter_id – Filter ID.
phrase – Text to be filtered.
context – Array of enumerable strings:
home,notifications,public,thread. At least one context must be specified.irreversible – Should the server irreversibly drop matching entities from home and notifications?
whole_word – Consider word boundaries?
expires_in – Expires in the specified number of seconds.
kwargs –
base_url/access_tokenoverride.
- Returns:
{ "context": "Which context(s) this filter applies to. Possible values: home, notifications, public, thread", "expires_at": "2020-01-01T00:00:00+00:00", "id": 25, "irreversible": true, "phrase": "strippedstring", "whole_word": false }
- update_list(list_id: int, title: str | None, replies_policy: str | None = None, **kwargs) dict[source]#
Update a list.
It requires the specified API token to have the
write:listspermission.- Parameters:
list_id – List ID.
title – New list title.
replies_policy – New replies policy. Possible values:
none,followingorlist. Default:list.kwargs –
base_url/access_tokenoverride.
- Returns:
{ "id": 74, "replies_policy": "string", "title": "strippedstring" }
- update_media(media_id: str, file: str | None = None, description: str | None = None, thumbnail: str | None = None, **kwargs) dict[source]#
Update a media attachment.
It requires the specified API token to have the
write:mediapermission.- Parameters:
media_id – Media ID to update.
file – Path to the new file.
description – New description.
thumbnail – Path to the new thumbnail.
kwargs –
base_url/access_tokenoverride.
- Returns:
{ "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" }
- upload_media(file: str, description: str | None = None, thumbnail: str | None = None, **kwargs) dict[source]#
Upload media that can be used as attachments.
It requires the specified API token to have the
write:mediapermission.- Parameters:
file – Path to the file to upload.
thumbnail – Path to the file thumbnail.
description – Optional attachment description.
kwargs –
base_url/access_tokenoverride.
- Returns:
{ "description": "strippedstring", "id": "string", "meta": { "key": "value" }, "preview_remote_url": "https://example.org", "preview_url": "https://example.org", "remote_url": "https://example.org", "type": "image", "url": "https://example.org" }