Skip to main content

Python wrapper for the Mastodon API

Project description

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

Project details


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.1.tar.gz (11.0 MB view details)

Uploaded Source

Built Distribution

mastodon_py-2.0.1-py3-none-any.whl (108.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mastodon_py-2.0.1.tar.gz
  • Upload date:
  • Size: 11.0 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.1.tar.gz
Algorithm Hash digest
SHA256 f0a9cf59071347c7ff2ee49487d2520ca661f349f369b68845bdf3e43db1fff3
MD5 4358debecd18306fc8e3e56dd71d0ffe
BLAKE2b-256 d4408f962b2d1782fd097ea45a344094df7d56f980f1d64c62de0bfa1ef5b0fc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mastodon_py-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 108.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5bb543ecbd7526bd50675d5d617ec04caa6b10d4002454cbf5641ad612723455
MD5 ef71b96f0e2c5f7c641f28480ade8478
BLAKE2b-256 cfd7632b8b14a13eb33a9fcc5c3354f878fa39dfb5f51ef6283b24fce84c5796

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page