Instance-wide data and search

Instance information

These functions allow you to fetch information associated with the current instance as well as data from the instance-wide profile directory.

Mastodon.instance() Instance | InstanceV2[source]

Retrieve basic information about the instance, including the URI and administrative contact email.

Does not require authentication unless locked down by the administrator.

Returns an instance dict.

Added: Mastodon v1.1.0, last changed: Mastodon v4.0.0

Mastodon.instance_activity() NonPaginatableList[Activity][source]

Retrieve activity stats about the instance. May be disabled by the instance administrator - throws a MastodonNotFoundError in that case.

Activity is returned for 12 weeks going back from the current week.

Added: Mastodon v2.1.2, last changed: Mastodon v2.1.2

Mastodon.instance_peers() NonPaginatableList[str][source]

Retrieve the instances that this instance knows about. May be disabled by the instance administrator - throws a MastodonNotFoundError in that case.

Returns a list of URL strings.

Added: Mastodon v2.1.2, last changed: Mastodon v2.1.2

Mastodon.instance_health() bool[source]

Basic health check. Returns True if healthy, False if not.

Added: Mastodon v3.0.0, last changed: Mastodon v3.0.0

Mastodon.instance_nodeinfo(schema: str = 'http://nodeinfo.diaspora.software/ns/schema/2.0') Nodeinfo | AttribAccessDict[source]

Retrieves the instance’s nodeinfo information.

For information on what the nodeinfo can contain, see the nodeinfo specification: https://github.com/jhass/nodeinfo . By default, Mastodon.py will try to retrieve the version 2.0 schema nodeinfo, for which we have a well defined return object. If you go outside of that, all bets are off.

To override the schema, specify the desired schema with the schema parameter.

Added: Mastodon v3.0.0, last changed: Mastodon v3.0.0

Mastodon.instance_rules() NonPaginatableList[Rule][source]

Retrieve instance rules.

Added: Mastodon v3.4.0, last changed: Mastodon v3.4.0

Profile directory

Mastodon.directory(offset: int | None = None, limit: int | None = None, order: str | None = None, local: bool | None = None) NonPaginatableList[Account][source]

Fetch the contents of the profile directory, if enabled on the server.

offset how many accounts to skip before returning results. Default 0.

limit how many accounts to load. Default 40.

order “active” to sort by most recently posted statuses (usually the default) or

“new” to sort by most recently created profiles.

local True to return only local accounts.

Uses offset/limit pagination, not currently handled by the pagination utility functions, do it manually if you have to.

Added: Mastodon v3.0.0, last changed: Mastodon v3.0.0

Emoji

Mastodon.custom_emojis() NonPaginatableList[CustomEmoji][source]

Fetch the list of custom emoji the instance has installed.

Does not require authentication unless locked down by the administrator.

Added: Mastodon v2.1.0, last changed: Mastodon v2.1.0

Announcements

These functions allow you to fetch announcements, mark annoucements read and modify reactions.

Reading

Mastodon.announcements() NonPaginatableList[Announcement][source]

Fetch currently active announcements.

Returns a list of announcement dicts.

Added: Mastodon v3.1.0, last changed: Mastodon v3.1.0

Writing

Mastodon.announcement_dismiss(id: Announcement | str | int | MaybeSnowflakeIdType)[source]

Set the given annoucement to read.

Added: Mastodon v3.1.0, last changed: Mastodon v3.1.0

Mastodon.announcement_reaction_create(id: Announcement | str | int | MaybeSnowflakeIdType, reaction: str)[source]

Add a reaction to an announcement. reaction can either be a unicode emoji or the name of one of the instances custom emoji.

Will throw an API error if the reaction name is not one of the allowed things or when trying to add a reaction that the user has already added (adding a reaction that a different user added is legal and increments the count).

Added: Mastodon v3.1.0, last changed: Mastodon v3.1.0

Mastodon.announcement_reaction_delete(id: Announcement | str | int | MaybeSnowflakeIdType, reaction: str)[source]

Remove a reaction to an announcement.

Will throw an API error if the reaction does not exist.

Added: Mastodon v3.1.0, last changed: Mastodon v3.1.0