Skip to main content

Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API. Feature complete for public API as of Mastodon version 4.4.3 and easy to get started with:

from mastodon import Mastodon

# Register your app! This only needs to be done once (per server, or when
# distributing rather than hosting an application, most likely per device and server).
# Uncomment the code and substitute in your information:
'''
Mastodon.create_app(
    'pytooterapp',
    api_base_url = 'https://mastodon.social',
    to_file = 'pytooter_clientcred.secret'
)
'''

# Then, log in. This can be done every time your application starts, or you can use the persisted information:
mastodon = Mastodon(client_id = 'pytooter_clientcred.secret',)
print(mastodon.auth_request_url())

# open the URL in the browser and paste the code you get
mastodon.log_in(
    code=input("Enter the OAuth authorization code: "),
    to_file="pytooter_usercred.secret"
)

# To post, create an actual API instance:
mastodon = Mastodon(access_token = 'pytooter_usercred.secret')
mastodon.toot('Tooting from Python using #mastodonpy !')

You can install Mastodon.py via pypi:

pip install Mastodon.py

We currently try to support Python 3.7 and above, and try to at least not break Python 3 versions below that. Python 2 support is no longer a goal.

Full documentation and basic usage examples can be found at https://mastodonpy.readthedocs.io/en/stable/ . Some more extensive examples can be found at https://github.com/halcy/MastodonpyExamples

Acknowledgements

Mastodon.py contains work by a large amount of contributors, many of which have put significant work into making it a better library. You can find some information about who helped with which particular feature or fix in the changelog.

https://circleci.com/gh/halcy/Mastodon.py.svg?style=svg https://codecov.io/gh/halcy/Mastodon.py/branch/master/graph/badge.svg

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mastodon_py-2.1.2.tar.gz (11.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mastodon_py-2.1.2-py3-none-any.whl (123.0 kB view details)

Uploaded Python 3

File details

Details for the file mastodon_py-2.1.2.tar.gz.

File metadata

  • Download URL: mastodon_py-2.1.2.tar.gz
  • Upload date:
  • Size: 11.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mastodon_py-2.1.2.tar.gz
Algorithm Hash digest
SHA256 e06cdcc937fa5ac704ac3b107a2e5fe49a0ee26bf46d30015fa1774bdd1e0c0c
MD5 d426441ea7f1a2296a5abc429eafc855
BLAKE2b-256 8a05e1603a8893c5d12b546fa17c879a15df401466a322c758ce2710903aeda9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mastodon_py-2.1.2.tar.gz:

Publisher: publish.yml on halcy/Mastodon.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mastodon_py-2.1.2-py3-none-any.whl.

File metadata

  • Download URL: mastodon_py-2.1.2-py3-none-any.whl
  • Upload date:
  • Size: 123.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mastodon_py-2.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c1caa16e5eec22c3f4aba25131d7c8ad7954607d976271b0a0a81797f79834b1
MD5 cd2e4d478c4824f0e307723d5c5ca29c
BLAKE2b-256 1f15b3cec4fbe8fdcee1efbab992fb3cb8f6884fb74febaba7b3ed56b906f525

See more details on using hashes here.

Provenance

The following attestation bundles were made for mastodon_py-2.1.2-py3-none-any.whl:

Publisher: publish.yml on halcy/Mastodon.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

2.2.2

2 files

2.2.1

2 files

2.2.0

2 files

2.1.4

2 files

2.1.3

2 files

This release

2.1.2 This release

2 files

2.1.1

2 files

2.1.0

2 files

2.0.1

2 files

2.0.0

2 files

1.8.1

2 files

1.8.0

2 files

1.7.0

2 files

1.6.3

2 files

1.6.2

2 files

1.6.1

2 files

1.6.0

2 files

1.5.2

2 files

1.5.1

2 files

1.5.0

2 files

1.4.6

2 files

1.4.5

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.1

2 files

1.3.0

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page