mastodon

class platypush.plugins.mastodon.MastodonPlugin(base_url: str, access_token: Optional[str] = None, **kwargs)[source]

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.

__init__(base_url: str, access_token: Optional[str] = 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:lists permission.

Parameters
  • list_id – List ID.

  • account_ids – Accounts that should be added.

  • kwargsbase_url/access_token override.

Returns

{
  "id": 89,
  "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:favourites permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

Add a featured tag to the current account.

It requires the specified API token to have the write:accounts permission.

Parameters
  • name – Hashtag name.

  • kwargsbase_url/access_token override.

Returns

{
  "id": 98,
  "last_status": "2021-12-03T23:20:13.430486+00:00",
  "name": "string",
  "statuses_count": 18
}

block_account(account_id: str, **kwargs)[source]

Block a given account ID.

It requires the specified API token to have the write:blocks permission.

Parameters
  • account_id – Account ID.

  • kwargsbase_url/access_token override.

bookmark_status(status_id: str, **kwargs)[source]

Add a status to the bookmarks.

It requires the specified API token to have the write:bookmarks permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

create_filter(phrase: str, context: Iterable[str], irreversible: Optional[bool] = None, whole_word: Optional[bool] = None, expires_in: Optional[int] = None, **kwargs) dict[source]

Create a new filter.

It requires the specified API token to have the write:filters permission.

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.

  • kwargsbase_url/access_token override.

Returns

{
  "context": "Which context(s) this filter applies to. Possible values: home, notifications, public, thread",
  "expires_at": "2021-12-03T23:20:13.432545+00:00",
  "id": 65,
  "irreversible": true,
  "phrase": "strippedstring",
  "whole_word": false
}

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:lists permission.

Parameters
  • title – List title.

  • replies_policy – Possible values: none, following or list. Default: list.

  • kwargsbase_url/access_token override.

Returns

{
  "id": 53,
  "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:lists permission.

Parameters
  • list_id – List ID.

  • kwargsbase_url/access_token override.

dismiss_notifications(notification_id: Optional[str] = None, **kwargs)[source]

Dismiss notifications.

It requires the specified API token to have the write:notifications permission.

Parameters
  • notification_id – Dismiss only this notification.

  • kwargsbase_url/access_token override.

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:follows permission.

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).

  • kwargsbase_url/access_token override.

get_account(account_id: str, **kwargs) dict[source]

Retrieve an account by ID.

It requires the specified API token to have read:accounts permissions.

Parameters
  • account_id – Account ID to retrieve.

  • kwargsbase_url/access_token override.

Returns

{
  "avatar": "https://example.org",
  "bot": false,
  "created_at": "2021-12-03T23:20:13.430214+00:00",
  "discoverable": false,
  "display_name": "Name Surname",
  "followers_count": 68,
  "following_count": 27,
  "group": false,
  "header": "https://example.org",
  "id": "283928772543527481",
  "last_status_at": "2021-12-03T23:20:13.430240+00:00",
  "locked": true,
  "note": "string",
  "url": "https://example.org",
  "username": "admin"
}

get_blocked_accounts(max_id: Optional[str] = None, since_id: Optional[str] = None, limit: int = 20, **kwargs) Iterable[dict][source]

Retrieve the list of blocked accounts.

It requires the specified API token to have the read:blocks permission.

Parameters
  • max_id – Return results older than this ID.

  • since_id – Return results newer than this ID.

  • limit – Maximum number of results (default: 20).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "avatar": "https://example.org",
    "bot": true,
    "created_at": "2021-12-03T23:20:13.430214+00:00",
    "discoverable": false,
    "display_name": "Name Surname",
    "followers_count": 7,
    "following_count": 35,
    "group": false,
    "header": "https://example.org",
    "id": "283928772543527481",
    "last_status_at": "2021-12-03T23:20:13.430240+00:00",
    "locked": true,
    "note": "string",
    "url": "https://example.org",
    "username": "admin"
  }
]

get_bookmarked_statuses(min_id: Optional[str] = None, max_id: Optional[str] = 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:bookmarks permission.

Parameters
  • min_id – Return results newer than this ID.

  • max_id – Return results older than this ID.

  • limit – Maximum number of results (default: 20).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "account": {
      "avatar": "https://example.org",
      "bot": true,
      "created_at": "2021-12-03T23:20:13.430214+00:00",
      "discoverable": false,
      "display_name": "Name Surname",
      "followers_count": 39,
      "following_count": 97,
      "group": false,
      "header": "https://example.org",
      "id": "283928772543527481",
      "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
    "favourited": false,
    "favourites_count": 75,
    "hashtags": [
      {
        "history": [
          {
            "accounts": 15,
            "day": "2021-12-04",
            "uses": 71
          }
        ],
        "name": "hashtag",
        "url": "https://example.org"
      }
    ],
    "id": "393736729789491264",
    "in_reply_to_account_id": "467448283635858295",
    "in_reply_to_id": "342454686927823723",
    "muted": false,
    "pinned": false,
    "reblogged": false,
    "reblogs_count": 13,
    "replies_count": 73,
    "sensitive": false,
    "url": "https://example.org"
  }
]

get_conversations(min_id: Optional[str] = None, max_id: Optional[str] = None, limit: int = 20, **kwargs) Iterable[dict][source]

Get a list of user conversations.

It requires the specified API token to have the read:statuses permission.

Parameters
  • min_id – Return results newer than this ID.

  • max_id – Return results older than this ID.

  • limit – Maximum number of results (default: 20).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "accounts": [
      {
        "avatar": "https://example.org",
        "bot": true,
        "created_at": "2021-12-03T23:20:13.430214+00:00",
        "discoverable": false,
        "display_name": "Name Surname",
        "followers_count": 64,
        "following_count": 26,
        "group": true,
        "header": "https://example.org",
        "id": "283928772543527481",
        "last_status_at": "2021-12-03T23:20:13.430240+00:00",
        "locked": true,
        "note": "string",
        "url": "https://example.org",
        "username": "admin"
      }
    ],
    "id": 86,
    "last_status": {
      "account": {
        "avatar": "https://example.org",
        "bot": true,
        "created_at": "2021-12-03T23:20:13.430214+00:00",
        "discoverable": true,
        "display_name": "Name Surname",
        "followers_count": 3,
        "following_count": 13,
        "group": true,
        "header": "https://example.org",
        "id": "283928772543527481",
        "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
      "favourited": false,
      "favourites_count": 5,
      "hashtags": [
        {
          "history": [
            {
              "accounts": 33,
              "day": "2021-12-04",
              "uses": 47
            }
          ],
          "name": "hashtag",
          "url": "https://example.org"
        }
      ],
      "id": "393736729789491264",
      "in_reply_to_account_id": "467448283635858295",
      "in_reply_to_id": "342454686927823723",
      "muted": true,
      "pinned": true,
      "reblogged": false,
      "reblogs_count": 3,
      "replies_count": 70,
      "sensitive": false,
      "url": "https://example.org"
    },
    "unread": true
  }
]

get_favourited_statuses(min_id: Optional[str] = None, max_id: Optional[str] = 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:favourites permission.

Parameters
  • min_id – Return results newer than this ID.

  • max_id – Return results older than this ID.

  • limit – Maximum number of results (default: 20).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "account": {
      "avatar": "https://example.org",
      "bot": false,
      "created_at": "2021-12-03T23:20:13.430214+00:00",
      "discoverable": true,
      "display_name": "Name Surname",
      "followers_count": 22,
      "following_count": 56,
      "group": false,
      "header": "https://example.org",
      "id": "283928772543527481",
      "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
    "favourited": false,
    "favourites_count": 48,
    "hashtags": [
      {
        "history": [
          {
            "accounts": 71,
            "day": "2021-12-04",
            "uses": 76
          }
        ],
        "name": "hashtag",
        "url": "https://example.org"
      }
    ],
    "id": "393736729789491264",
    "in_reply_to_account_id": "467448283635858295",
    "in_reply_to_id": "342454686927823723",
    "muted": true,
    "pinned": false,
    "reblogged": true,
    "reblogs_count": 27,
    "replies_count": 63,
    "sensitive": false,
    "url": "https://example.org"
  }
]

Retrieve the list that you have added a certain account to.

It requires the specified API token to have the read:lists permission.

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).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "id": 63,
    "title": "strippedstring"
  }
]

Retrieve the list of featured hashtags of an account.

It requires the specified API token to have the read:accounts permission.

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).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "id": 98,
    "last_status": "2021-12-03T23:20:13.430486+00:00",
    "name": "string",
    "statuses_count": 93
  }
]

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:filters permission.

Parameters

kwargsbase_url/access_token override.

Returns

[
  {
    "context": "Which context(s) this filter applies to. Possible values: home, notifications, public, thread",
    "expires_at": "2021-12-03T23:20:13.432545+00:00",
    "id": 8,
    "irreversible": false,
    "phrase": "strippedstring",
    "whole_word": true
  }
]

get_followers(account_id: str, max_id: Optional[str] = None, since_id: Optional[str] = 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:accounts permission.

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).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "avatar": "https://example.org",
    "bot": false,
    "created_at": "2021-12-03T23:20:13.430214+00:00",
    "discoverable": true,
    "display_name": "Name Surname",
    "followers_count": 30,
    "following_count": 66,
    "group": false,
    "header": "https://example.org",
    "id": "283928772543527481",
    "last_status_at": "2021-12-03T23:20:13.430240+00:00",
    "locked": true,
    "note": "string",
    "url": "https://example.org",
    "username": "admin"
  }
]

get_following(account_id: str, max_id: Optional[str] = None, since_id: Optional[str] = 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:accounts permission.

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).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "avatar": "https://example.org",
    "bot": true,
    "created_at": "2021-12-03T23:20:13.430214+00:00",
    "discoverable": false,
    "display_name": "Name Surname",
    "followers_count": 14,
    "following_count": 97,
    "group": true,
    "header": "https://example.org",
    "id": "283928772543527481",
    "last_status_at": "2021-12-03T23:20:13.430240+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: Optional[str] = None, max_id: Optional[str] = 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:statuses permission.

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).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "account": {
      "avatar": "https://example.org",
      "bot": true,
      "created_at": "2021-12-03T23:20:13.430214+00:00",
      "discoverable": false,
      "display_name": "Name Surname",
      "followers_count": 23,
      "following_count": 8,
      "group": true,
      "header": "https://example.org",
      "id": "283928772543527481",
      "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
    "favourited": true,
    "favourites_count": 56,
    "hashtags": [
      {
        "history": [
          {
            "accounts": 85,
            "day": "2021-12-04",
            "uses": 33
          }
        ],
        "name": "hashtag",
        "url": "https://example.org"
      }
    ],
    "id": "393736729789491264",
    "in_reply_to_account_id": "467448283635858295",
    "in_reply_to_id": "342454686927823723",
    "muted": false,
    "pinned": false,
    "reblogged": true,
    "reblogs_count": 88,
    "replies_count": 40,
    "sensitive": false,
    "url": "https://example.org"
  }
]

get_home_timeline(local: bool = False, only_media: bool = False, min_id: Optional[str] = None, max_id: Optional[str] = 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:statuses permission.

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).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "account": {
      "avatar": "https://example.org",
      "bot": true,
      "created_at": "2021-12-03T23:20:13.430214+00:00",
      "discoverable": true,
      "display_name": "Name Surname",
      "followers_count": 42,
      "following_count": 17,
      "group": false,
      "header": "https://example.org",
      "id": "283928772543527481",
      "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
    "favourited": true,
    "favourites_count": 25,
    "hashtags": [
      {
        "history": [
          {
            "accounts": 54,
            "day": "2021-12-04",
            "uses": 6
          }
        ],
        "name": "hashtag",
        "url": "https://example.org"
      }
    ],
    "id": "393736729789491264",
    "in_reply_to_account_id": "467448283635858295",
    "in_reply_to_id": "342454686927823723",
    "muted": false,
    "pinned": false,
    "reblogged": false,
    "reblogs_count": 22,
    "replies_count": 19,
    "sensitive": false,
    "url": "https://example.org"
  }
]

get_list_accounts(list_id: Optional[int] = None, min_id: Optional[str] = None, max_id: Optional[str] = None, limit: int = 20, **kwargs) Iterable[dict][source]

Get the accounts in a list.

It requires the specified API token to have the read:lists permission.

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).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "avatar": "https://example.org",
    "bot": false,
    "created_at": "2021-12-03T23:20:13.430214+00:00",
    "discoverable": false,
    "display_name": "Name Surname",
    "followers_count": 68,
    "following_count": 67,
    "group": false,
    "header": "https://example.org",
    "id": "283928772543527481",
    "last_status_at": "2021-12-03T23:20:13.430240+00:00",
    "locked": true,
    "note": "string",
    "url": "https://example.org",
    "username": "admin"
  }
]

get_list_timeline(list_id: str, min_id: Optional[str] = None, max_id: Optional[str] = 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:lists permission.

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).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "account": {
      "avatar": "https://example.org",
      "bot": true,
      "created_at": "2021-12-03T23:20:13.430214+00:00",
      "discoverable": false,
      "display_name": "Name Surname",
      "followers_count": 61,
      "following_count": 13,
      "group": false,
      "header": "https://example.org",
      "id": "283928772543527481",
      "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
    "favourited": false,
    "favourites_count": 51,
    "hashtags": [
      {
        "history": [
          {
            "accounts": 53,
            "day": "2021-12-04",
            "uses": 27
          }
        ],
        "name": "hashtag",
        "url": "https://example.org"
      }
    ],
    "id": "393736729789491264",
    "in_reply_to_account_id": "467448283635858295",
    "in_reply_to_id": "342454686927823723",
    "muted": true,
    "pinned": false,
    "reblogged": true,
    "reblogs_count": 50,
    "replies_count": 69,
    "sensitive": false,
    "url": "https://example.org"
  }
]

get_lists(list_id: Optional[int] = None, **kwargs) Union[dict, Iterable[dict]][source]

Get the lists owned by the logged user.

It requires the specified API token to have the read:lists permission.

Parameters
  • list_id – Retrieve a specific list ID (default: retrieve all).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "id": 75,
    "replies_policy": "string",
    "title": "strippedstring"
  }
]

get_muted_accounts(max_id: Optional[str] = None, since_id: Optional[str] = None, limit: int = 20, **kwargs) Iterable[dict][source]

Retrieve the list of muted accounts.

It requires the specified API token to have the read:mutes permission.

Parameters
  • max_id – Return results older than this ID.

  • since_id – Return results newer than this ID.

  • limit – Maximum number of results (default: 20).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "avatar": "https://example.org",
    "bot": false,
    "created_at": "2021-12-03T23:20:13.430214+00:00",
    "discoverable": true,
    "display_name": "Name Surname",
    "followers_count": 19,
    "following_count": 36,
    "group": true,
    "header": "https://example.org",
    "id": "283928772543527481",
    "last_status_at": "2021-12-03T23:20:13.430240+00:00",
    "locked": false,
    "note": "string",
    "url": "https://example.org",
    "username": "admin"
  }
]

get_notifications(notification_id: Optional[str] = None, min_id: Optional[str] = None, max_id: Optional[str] = None, limit: int = 20, **kwargs) Union[dict, Iterable[dict]][source]

Get the list of notifications of the user.

It requires the specified API token to have the read:notifications permission.

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).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "account": {
      "avatar": "https://example.org",
      "bot": true,
      "created_at": "2021-12-03T23:20:13.430214+00:00",
      "discoverable": false,
      "display_name": "Name Surname",
      "followers_count": 25,
      "following_count": 88,
      "group": false,
      "header": "https://example.org",
      "id": "283928772543527481",
      "last_status_at": "2021-12-03T23:20:13.430240+00:00",
      "locked": true,
      "note": "string",
      "url": "https://example.org",
      "username": "admin"
    },
    "created_at": "2021-12-03T23:20:13.433565+00:00",
    "id": "string",
    "mention": {
      "id": 33,
      "url": "https://mastodon.social/@user",
      "username": "user"
    },
    "status": {
      "account": {
        "avatar": "https://example.org",
        "bot": false,
        "created_at": "2021-12-03T23:20:13.430214+00:00",
        "discoverable": false,
        "display_name": "Name Surname",
        "followers_count": 67,
        "following_count": 10,
        "group": true,
        "header": "https://example.org",
        "id": "283928772543527481",
        "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
      "favourited": false,
      "favourites_count": 70,
      "hashtags": [
        {
          "history": [
            {
              "accounts": 37,
              "day": "2021-12-04",
              "uses": 88
            }
          ],
          "name": "hashtag",
          "url": "https://example.org"
        }
      ],
      "id": "393736729789491264",
      "in_reply_to_account_id": "467448283635858295",
      "in_reply_to_id": "342454686927823723",
      "muted": false,
      "pinned": false,
      "reblogged": true,
      "reblogs_count": 48,
      "replies_count": 33,
      "sensitive": true,
      "url": "https://example.org"
    },
    "type": "string"
  }
]

get_public_timeline(local: bool = False, remote: bool = False, only_media: bool = False, min_id: Optional[str] = None, max_id: Optional[str] = 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:statuses permission.

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).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "account": {
      "avatar": "https://example.org",
      "bot": false,
      "created_at": "2021-12-03T23:20:13.430214+00:00",
      "discoverable": false,
      "display_name": "Name Surname",
      "followers_count": 68,
      "following_count": 33,
      "group": true,
      "header": "https://example.org",
      "id": "283928772543527481",
      "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
    "favourited": true,
    "favourites_count": 51,
    "hashtags": [
      {
        "history": [
          {
            "accounts": 7,
            "day": "2021-12-04",
            "uses": 13
          }
        ],
        "name": "hashtag",
        "url": "https://example.org"
      }
    ],
    "id": "393736729789491264",
    "in_reply_to_account_id": "467448283635858295",
    "in_reply_to_id": "342454686927823723",
    "muted": true,
    "pinned": false,
    "reblogged": false,
    "reblogs_count": 72,
    "replies_count": 36,
    "sensitive": true,
    "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:statuses permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

Returns

{
  "account": {
    "avatar": "https://example.org",
    "bot": true,
    "created_at": "2021-12-03T23:20:13.430214+00:00",
    "discoverable": false,
    "display_name": "Name Surname",
    "followers_count": 86,
    "following_count": 9,
    "group": false,
    "header": "https://example.org",
    "id": "283928772543527481",
    "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
  "favourited": true,
  "favourites_count": 75,
  "hashtags": [
    {
      "history": [
        {
          "accounts": 16,
          "day": "2021-12-04",
          "uses": 61
        }
      ],
      "name": "hashtag",
      "url": "https://example.org"
    }
  ],
  "id": "393736729789491264",
  "in_reply_to_account_id": "467448283635858295",
  "in_reply_to_id": "342454686927823723",
  "muted": true,
  "pinned": true,
  "reblogged": false,
  "reblogs_count": 59,
  "replies_count": 66,
  "sensitive": false,
  "url": "https://example.org"
}

get_statuses(account_id: str, min_id: Optional[str] = None, max_id: Optional[str] = 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:statuses permission.

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).

  • kwargsbase_url/access_token override.

Returns

[
  {
    "account": {
      "avatar": "https://example.org",
      "bot": true,
      "created_at": "2021-12-03T23:20:13.430214+00:00",
      "discoverable": false,
      "display_name": "Name Surname",
      "followers_count": 10,
      "following_count": 58,
      "group": false,
      "header": "https://example.org",
      "id": "283928772543527481",
      "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
    "favourited": true,
    "favourites_count": 68,
    "hashtags": [
      {
        "history": [
          {
            "accounts": 13,
            "day": "2021-12-04",
            "uses": 30
          }
        ],
        "name": "hashtag",
        "url": "https://example.org"
      }
    ],
    "id": "393736729789491264",
    "in_reply_to_account_id": "467448283635858295",
    "in_reply_to_id": "342454686927823723",
    "muted": true,
    "pinned": true,
    "reblogged": true,
    "reblogs_count": 35,
    "replies_count": 78,
    "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_conversations permission.

Parameters
  • conversation_id – Conversation ID.

  • kwargsbase_url/access_token override.

mute_account(account_id: str, **kwargs)[source]

Mute a given account ID.

It requires the specified API token to have the write:mutes permission.

Parameters
  • account_id – Account ID.

  • kwargsbase_url/access_token override.

mute_status(status_id: str, **kwargs)[source]

Mute updates on a status.

It requires the specified API token to have the write:mutes permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

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:accounts permission.

Parameters
  • account_id – Account ID.

  • kwargsbase_url/access_token override.

pin_status(status_id: str, **kwargs)[source]

Pin a status to the profile.

It requires the specified API token to have the write:accounts permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

publish_status(status: str, in_reply_to_id: Optional[str] = None, media_ids: Optional[Iterable[str]] = None, sensitive: Optional[bool] = None, spoiler_text: Optional[str] = None, visibility: Optional[str] = None, **kwargs) dict[source]

Publish a new status.

It requires the specified API token to have the write:statuses permission.

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, private and direct.

  • kwargsbase_url/access_token override.

Returns

{
  "account": {
    "avatar": "https://example.org",
    "bot": false,
    "created_at": "2021-12-03T23:20:13.430214+00:00",
    "discoverable": false,
    "display_name": "Name Surname",
    "followers_count": 46,
    "following_count": 31,
    "group": false,
    "header": "https://example.org",
    "id": "283928772543527481",
    "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
  "favourited": true,
  "favourites_count": 75,
  "hashtags": [
    {
      "history": [
        {
          "accounts": 36,
          "day": "2021-12-04",
          "uses": 95
        }
      ],
      "name": "hashtag",
      "url": "https://example.org"
    }
  ],
  "id": "393736729789491264",
  "in_reply_to_account_id": "467448283635858295",
  "in_reply_to_id": "342454686927823723",
  "muted": false,
  "pinned": false,
  "reblogged": true,
  "reblogs_count": 37,
  "replies_count": 51,
  "sensitive": true,
  "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:statuses permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

register_account(username: str, email: str, password: str, locale: str = 'en', reason: Optional[str] = None, **kwargs) dict[source]

Register a new account.

It requires the specified API token to have write:accounts permissions.

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.

  • kwargsbase_url/access_token override.

Returns

{
  "access_token": "string",
  "created_at": "2021-12-03T23:20:13.432131+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:lists permission.

Parameters
  • list_id – List ID.

  • account_ids – Accounts that should be removed.

  • kwargsbase_url/access_token override.

Returns

{
  "id": 94,
  "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_conversations permission.

Parameters
  • conversation_id – Conversation ID.

  • kwargsbase_url/access_token override.

remove_favourite_status(status_id: str, **kwargs)[source]

Undo a status favourite action.

It requires the specified API token to have the write:favourites permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

Remove a featured tag from the current account.

It requires the specified API token to have the write:accounts permission.

Parameters
  • tag_id – Hashtag ID.

  • kwargsbase_url/access_token override.

remove_filter(filter_id: int, **kwargs)[source]

Remove a filter.

It requires the specified API token to have the write:filters permission.

Parameters
  • filter_id – Filter ID.

  • kwargsbase_url/access_token override.

remove_status(status_id: str, **kwargs)[source]

Remove a status by ID.

It requires the specified API token to have the read:statuses permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

search(query: str, type: Optional[str] = None, min_id: Optional[str] = None, max_id: Optional[str] = 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:

    • accounts

    • hashtags

    • statuses

  • 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).

  • kwargsbase_url/access_token override.

Returns

{
  "accounts": [
    {
      "avatar": "https://example.org",
      "bot": false,
      "created_at": "2021-12-03T23:20:13.430214+00:00",
      "discoverable": false,
      "display_name": "Name Surname",
      "followers_count": 25,
      "following_count": 76,
      "group": false,
      "header": "https://example.org",
      "id": "283928772543527481",
      "last_status_at": "2021-12-03T23:20:13.430240+00:00",
      "locked": false,
      "note": "string",
      "url": "https://example.org",
      "username": "admin"
    }
  ],
  "hashtags": [
    {
      "history": [
        {
          "accounts": 26,
          "day": "2021-12-04",
          "uses": 96
        }
      ],
      "name": "hashtag",
      "url": "https://example.org"
    }
  ],
  "statuses": [
    {
      "account": {
        "avatar": "https://example.org",
        "bot": false,
        "created_at": "2021-12-03T23:20:13.430214+00:00",
        "discoverable": true,
        "display_name": "Name Surname",
        "followers_count": 92,
        "following_count": 50,
        "group": true,
        "header": "https://example.org",
        "id": "283928772543527481",
        "last_status_at": "2021-12-03T23:20:13.430240+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": "2021-12-03T23:20:13.431699+00:00",
      "favourited": true,
      "favourites_count": 98,
      "hashtags": [
        {
          "history": [
            {
              "accounts": 3,
              "day": "2021-12-04",
              "uses": 62
            }
          ],
          "name": "hashtag",
          "url": "https://example.org"
        }
      ],
      "id": "393736729789491264",
      "in_reply_to_account_id": "467448283635858295",
      "in_reply_to_id": "342454686927823723",
      "muted": true,
      "pinned": true,
      "reblogged": true,
      "reblogs_count": 12,
      "replies_count": 89,
      "sensitive": false,
      "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:accounts permission.

Parameters
  • account_id – Account ID.

  • note – Note content (HTML is supported).

  • kwargsbase_url/access_token override.

unblock_account(account_id: str, **kwargs)[source]

Unblock a given account ID.

It requires the specified API token to have the write:blocks permission.

Parameters
  • account_id – Account ID.

  • kwargsbase_url/access_token override.

undo_bookmark_status(status_id: str, **kwargs)[source]

Remove a status from the bookmarks.

It requires the specified API token to have the write:bookmarks permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

undo_reblog_status(status_id: str, **kwargs)[source]

Undo a status reblog.

It requires the specified API token to have the write:statuses permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

unfollow_account(account_id: str, **kwargs)[source]

Unfollow a given account ID.

It requires the specified API token to have the write:follows permission.

Parameters
  • account_id – Account ID.

  • kwargsbase_url/access_token override.

unmute_account(account_id: str, **kwargs)[source]

Unmute a given account ID.

It requires the specified API token to have the write:mutes permission.

Parameters
  • account_id – Account ID.

  • kwargsbase_url/access_token override.

unmute_status(status_id: str, **kwargs)[source]

Restore updates on a status.

It requires the specified API token to have the write:mutes permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

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:accounts permission.

Parameters
  • account_id – Account ID.

  • kwargsbase_url/access_token override.

unpin_status(status_id: str, **kwargs)[source]

Remove a pinned status.

It requires the specified API token to have the write:accounts permission.

Parameters
  • status_id – Status ID.

  • kwargsbase_url/access_token override.

update_account(discoverable: Optional[bool] = None, bot: Optional[bool] = None, display_name: Optional[str] = None, note: Optional[str] = None, avatar: Optional[str] = None, header: Optional[str] = None, locked: Optional[bool] = None, privacy: Optional[str] = None, sensitive: Optional[bool] = None, language: Optional[str] = None, metadata: Optional[Iterable[Mapping]] = None, **kwargs) dict[source]

Updates the properties of the account associated to the access token.

It requires the specified API token to have write:accounts permissions.

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 name and value.

  • kwargsbase_url/access_token override.

Returns

{
  "avatar": "https://example.org",
  "bot": true,
  "created_at": "2021-12-03T23:20:13.430214+00:00",
  "discoverable": false,
  "display_name": "Name Surname",
  "followers_count": 67,
  "following_count": 33,
  "group": true,
  "header": "https://example.org",
  "id": "283928772543527481",
  "last_status_at": "2021-12-03T23:20:13.430240+00:00",
  "locked": false,
  "note": "string",
  "url": "https://example.org",
  "username": "admin"
}

update_filter(filter_id: int, phrase: Optional[str] = None, context: Optional[Iterable[str]] = None, irreversible: Optional[bool] = None, whole_word: Optional[bool] = None, expires_in: Optional[int] = None, **kwargs) dict[source]

Update a filter.

It requires the specified API token to have the write:filters permission.

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.

  • kwargsbase_url/access_token override.

Returns

{
  "context": "Which context(s) this filter applies to. Possible values: home, notifications, public, thread",
  "expires_at": "2021-12-03T23:20:13.432545+00:00",
  "id": 34,
  "irreversible": false,
  "phrase": "strippedstring",
  "whole_word": false
}

update_list(list_id: int, title: Optional[str], replies_policy: Optional[str] = None, **kwargs) dict[source]

Update a list.

It requires the specified API token to have the write:lists permission.

Parameters
  • list_id – List ID.

  • title – New list title.

  • replies_policy – New replies policy. Possible values: none, following or list. Default: list.

  • kwargsbase_url/access_token override.

Returns

{
  "id": 95,
  "replies_policy": "string",
  "title": "strippedstring"
}

update_media(media_id: str, file: Optional[str] = None, description: Optional[str] = None, thumbnail: Optional[str] = None, **kwargs) dict[source]

Update a media attachment.

It requires the specified API token to have the write:media permission.

Parameters
  • media_id – Media ID to update.

  • file – Path to the new file.

  • description – New description.

  • thumbnail – Path to the new thumbnail.

  • kwargsbase_url/access_token override.

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: Optional[str] = None, thumbnail: Optional[str] = None, **kwargs) dict[source]

Upload media that can be used as attachments.

It requires the specified API token to have the write:media permission.

Parameters
  • file – Path to the file to upload.

  • thumbnail – Path to the file thumbnail.

  • description – Optional attachment description.

  • kwargsbase_url/access_token override.

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"
}