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.3.0 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.0.0.tar.gz (11.1 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.0.0-py3-none-any.whl (108.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mastodon_py-2.0.0.tar.gz
  • Upload date:
  • Size: 11.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for mastodon_py-2.0.0.tar.gz
Algorithm Hash digest
SHA256 34f45aee283bda437f16d512d9a5c7f2cf39b427bff7282ac0a82339d65ed8c7
MD5 79d4e2860c9721b152a212cf872978c3
BLAKE2b-256 b9c0110aad2e33a4036fb905bc2f14555d48a57511385bc217ec843451e8ef44

See more details on using hashes here.

File details

Details for the file Mastodon.py-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: Mastodon.py-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 108.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for Mastodon.py-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b2f08ffc19bf93db2cd2b7f11d785e847cd09d20127004de1aa089d20d402478
MD5 094ac8bf57a55343011fcb950d2e5e13
BLAKE2b-256 16c15b76c5c0ffe3b2454264c56899f58dd293049b9f17d78d34b52474187e35

See more details on using hashes here.

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

2.1.2

2 files

2.1.1

2 files

2.1.0

2 files

2.0.1

2 files

This release

2.0.0 This release

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