Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/halcy/Mastodon.py
Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
https://github.com/halcy/Mastodon.py
api api-client api-rest mastodon mastodon-api mastodon-app mastodon-client social social-network
Last synced: 6 days ago
JSON representation
Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
- Host: GitHub
- URL: https://github.com/halcy/Mastodon.py
- Owner: halcy
- License: mit
- Created: 2016-11-23T22:29:30.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-02-11T21:34:01.000Z (9 months ago)
- Last Synced: 2024-10-29T15:24:14.034Z (11 days ago)
- Topics: api, api-client, api-rest, mastodon, mastodon-api, mastodon-app, mastodon-client, social, social-network
- Language: Python
- Homepage:
- Size: 31.2 MB
- Stars: 879
- Watchers: 29
- Forks: 151
- Open Issues: 28
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
- Citation: CITATION.cff
Awesome Lists containing this project
- awesome-mastodon-cn - Mastodon.py - Mastodon API的Python包装器。 (图书馆 / 法兰西)
- awesome-mastodon - Mastodon.py - Python wrapper for the Mastodon API. (Libraries / Français)
README
Mastodon.py
===========
Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
Feature complete for public API as of Mastodon version 3.5.5 and easy to get started with:.. code-block:: python
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 (e.g. when writing a
# simple bot), or you can use the persisted information:
mastodon = Mastodon(client_id = 'pytooter_clientcred.secret',)
mastodon.log_in(
'[email protected]',
'incrediblygoodpassword',
to_file = 'pytooter_usercred.secret'
)# If you are logging in for the first time you need to give permissions to the app
# via OAuth, at the URL given by auth_request_url() and then pass code instead of
# username and password.
mastodon.log_in(
to_file = 'pytooter_usercred.secret',
code='code_from_oauth,
scopes=['read', 'write'],
)# Note that this won't work when using 2FA - you'll have to use OAuth, in that case.
# 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:
.. code-block:: Bash
# Python 3
pip3 install Mastodon.pyWe 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/MastodonpyExamplesAcknowledgements
----------------
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... image:: https://circleci.com/gh/halcy/Mastodon.py.svg?style=svg
:target: https://app.circleci.com/pipelines/github/halcy/Mastodon.py
.. image:: https://codecov.io/gh/halcy/Mastodon.py/branch/master/graph/badge.svg
:target: https://codecov.io/gh/halcy/Mastodon.py