2016-11-24 19:55:54 +00:00
|
|
|
Mastodon.py
|
|
|
|
===========
|
2022-11-08 12:13:30 +00:00
|
|
|
Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
|
2022-11-30 23:51:49 +00:00
|
|
|
Feature complete for public API as of Mastodon version 3.5.5 and easy to get started with:
|
2018-08-14 17:04:21 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
2019-04-28 21:22:09 +00:00
|
|
|
from mastodon import Mastodon
|
|
|
|
|
2022-11-30 23:51:49 +00:00
|
|
|
# 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:
|
2019-04-28 21:22:09 +00:00
|
|
|
'''
|
|
|
|
Mastodon.create_app(
|
2022-11-30 23:51:49 +00:00
|
|
|
'pytooterapp',
|
|
|
|
api_base_url = 'https://mastodon.social',
|
|
|
|
to_file = 'pytooter_clientcred.secret'
|
2019-04-28 21:22:09 +00:00
|
|
|
)
|
|
|
|
'''
|
|
|
|
|
2022-11-30 23:51:49 +00:00
|
|
|
# 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',)
|
2019-04-28 21:22:09 +00:00
|
|
|
mastodon.log_in(
|
2022-11-30 23:51:49 +00:00
|
|
|
'my_login_email@example.com',
|
|
|
|
'incrediblygoodpassword',
|
2019-04-28 21:22:09 +00:00
|
|
|
to_file = 'pytooter_usercred.secret'
|
|
|
|
)
|
|
|
|
|
2022-11-30 23:51:49 +00:00
|
|
|
# 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:
|
2022-11-13 16:39:56 +00:00
|
|
|
mastodon = Mastodon(access_token = 'pytooter_usercred.secret')
|
2022-11-13 21:41:14 +00:00
|
|
|
mastodon.toot('Tooting from Python using #mastodonpy !')
|
2016-11-23 22:30:51 +00:00
|
|
|
|
2016-11-24 20:03:18 +00:00
|
|
|
You can install Mastodon.py via pypi:
|
|
|
|
|
|
|
|
.. code-block:: Bash
|
2022-11-13 21:41:14 +00:00
|
|
|
|
2016-11-24 20:03:18 +00:00
|
|
|
# Python 3
|
|
|
|
pip3 install Mastodon.py
|
|
|
|
|
2022-11-30 23:51:49 +00:00
|
|
|
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.
|
2019-07-23 10:37:28 +00:00
|
|
|
|
2022-11-13 21:41:14 +00:00
|
|
|
Full documentation and basic usage examples can be found
|
|
|
|
at https://mastodonpy.readthedocs.io/en/stable/
|
2017-11-29 17:11:03 +00:00
|
|
|
|
2017-12-14 12:42:13 +00:00
|
|
|
Acknowledgements
|
2019-06-23 10:17:45 +00:00
|
|
|
----------------
|
2017-12-14 12:42:13 +00:00
|
|
|
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
|
2022-11-13 21:41:14 +00:00
|
|
|
about who helped with which particular feature or fix in the changelog.
|
2017-12-14 12:42:13 +00:00
|
|
|
|
2022-11-10 23:53:06 +00:00
|
|
|
.. image:: https://circleci.com/gh/halcy/Mastodon.py.svg?style=svg
|
|
|
|
:target: https://app.circleci.com/pipelines/github/halcy/Mastodon.py
|
2017-11-30 15:04:42 +00:00
|
|
|
.. image:: https://codecov.io/gh/halcy/Mastodon.py/branch/master/graph/badge.svg
|
2017-12-14 12:42:13 +00:00
|
|
|
:target: https://codecov.io/gh/halcy/Mastodon.py
|
2022-11-13 21:41:14 +00:00
|
|
|
|