2016-11-24 01:27:00 +00:00
|
|
|
Mastodon.py
|
|
|
|
===========
|
2016-11-25 19:33:00 +00:00
|
|
|
.. py:module:: mastodon
|
|
|
|
.. py:class: Mastodon
|
2022-11-13 21:42:29 +00:00
|
|
|
|
2019-04-28 11:58:18 +00:00
|
|
|
Register your app! This only needs to be done once. Uncomment the code and substitute in your information:
|
2016-11-23 23:58:14 +00:00
|
|
|
|
2016-11-24 02:03:52 +00:00
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from mastodon import Mastodon
|
|
|
|
|
|
|
|
'''
|
|
|
|
Mastodon.create_app(
|
2017-06-15 18:48:59 +00:00
|
|
|
'pytooterapp',
|
|
|
|
api_base_url = 'https://mastodon.social',
|
|
|
|
to_file = 'pytooter_clientcred.secret'
|
2016-11-24 02:03:52 +00:00
|
|
|
)
|
|
|
|
'''
|
|
|
|
|
2019-04-28 11:58:18 +00:00
|
|
|
Then login. This can be done every time, or you can use the persisted information:
|
2018-08-17 13:09:25 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from mastodon import Mastodon
|
2022-11-13 21:42:29 +00:00
|
|
|
|
2022-11-27 21:07:08 +00:00
|
|
|
mastodon = Mastodon(client_id = 'pytooter_clientcred.secret',)
|
|
|
|
mastodon.log_in('my_login_email@example.com', 'incrediblygoodpassword', to_file = 'pytooter_usercred.secret')
|
2016-11-24 02:03:52 +00:00
|
|
|
|
2019-04-28 11:58:18 +00:00
|
|
|
To post, create an actual API instance:
|
2018-08-17 13:09:25 +00:00
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
from mastodon import Mastodon
|
2022-11-13 21:42:29 +00:00
|
|
|
|
2022-11-27 21:07:08 +00:00
|
|
|
mastodon = Mastodon(access_token = 'pytooter_usercred.secret')
|
2022-11-13 21:42:29 +00:00
|
|
|
mastodon.toot('Tooting from Python using #mastodonpy !')
|
2016-11-24 01:27:00 +00:00
|
|
|
|
2022-11-13 21:42:29 +00:00
|
|
|
`Mastodon`_ is an ActivityPub-based Twitter-like federated social
|
|
|
|
network node. It has an API that allows you to interact with its
|
|
|
|
every aspect. This is a simple Python wrapper for that API, provided
|
2022-11-27 21:07:08 +00:00
|
|
|
as a single Python module.
|
2016-11-24 01:27:00 +00:00
|
|
|
|
2017-06-15 23:31:18 +00:00
|
|
|
Mastodon.py aims to implement the complete public Mastodon API. As
|
2022-11-27 20:53:07 +00:00
|
|
|
of this time, it is feature complete for Mastodon version 3.5.0. The
|
|
|
|
Mastodon compatible API layers of various other pieces of software as well
|
|
|
|
as forks, while not an official target, should also be basically
|
2019-05-08 16:08:11 +00:00
|
|
|
compatible, and Mastodon.py does make some allowances for behaviour that isn't
|
2022-11-27 20:53:07 +00:00
|
|
|
strictly like that of Mastodon, and attempts to support extensions to the API.
|
2017-06-15 23:31:18 +00:00
|
|
|
|
2017-12-14 12:42:13 +00:00
|
|
|
Acknowledgements
|
|
|
|
----------------
|
2022-11-13 21:42:29 +00:00
|
|
|
Mastodon.py contains work by a large number of contributors, many of which have
|
2017-12-14 12:42:13 +00:00
|
|
|
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.
|
2018-06-05 12:10:53 +00:00
|
|
|
|
2022-11-13 21:42:29 +00:00
|
|
|
.. _Mastodon: https://github.com/mastodon/mastodon
|
|
|
|
.. _Mastodon flagship instance: https://mastodon.social/
|
|
|
|
.. _Official Mastodon API docs: https://docs.joinmastodon.org/client/intro/
|
2022-11-18 22:44:15 +00:00
|
|
|
|
|
|
|
.. toctree::
|
2022-11-27 23:31:04 +00:00
|
|
|
:caption: Introduction
|
2022-11-27 23:37:04 +00:00
|
|
|
|
2022-11-27 23:31:04 +00:00
|
|
|
Mastodon.py <self>
|
|
|
|
01_general
|
|
|
|
02_return_values
|
|
|
|
03_errors
|
2022-11-27 23:17:08 +00:00
|
|
|
|
2022-11-27 23:31:04 +00:00
|
|
|
.. toctree::
|
|
|
|
:caption: API methods
|
2022-11-27 23:37:04 +00:00
|
|
|
|
|
|
|
04_auth
|