Python wrapper for the Mastodon ( https://github.com/mastodon/mastodon/ ) API.
Go to file
halcy 47aa316c36 different variant 2024-02-11 23:33:50 +02:00
.circleci another attempt at unfucking the CI 2024-02-11 15:52:06 +02:00
docs different variant 2024-02-11 23:33:50 +02:00
mastodon add py.typed marker 2024-02-11 22:38:14 +02:00
srcgen change some internals and rerun tests, lets see how CI likes this 2024-02-11 15:18:53 +02:00
tests add some more eeping and redo casettes. maybe that will resolve ordering problems? 2024-02-11 16:24:06 +02:00
.gitignore Update .gitignore to ignore pytest cache 2019-10-11 22:08:52 +02:00
.readthedocs.yaml different variant 2024-02-11 23:33:50 +02:00
CHANGELOG.rst add research note to docs 2024-02-11 22:53:49 +02:00
CITATION.cff add citation file 2024-02-11 22:43:46 +02:00
DEVELOPMENT.md Add reactions to changelog 2020-02-29 18:52:20 +01:00
LICENSE Update LICENSE to reflect that this is not a single person project 2019-05-31 12:57:38 +02:00
MANIFEST.in Update MANIFEST.in 2018-05-06 01:46:42 +02:00
README.rst Clearified the use of 'code' in log_in() 2023-08-21 22:20:23 +02:00
TODO.md add py.typed marker 2024-02-11 22:38:14 +02:00
pyproject.toml different variant 2024-02-11 23:33:50 +02:00
setup.py setup.py → pyproject.toml 2023-04-24 18:45:53 +02:00
tox.ini move webpush and blurhash deps out of test deps 2023-04-25 14:18:36 +02:00

README.rst

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(
        'my_login_email@example.com', 
        '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.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.

.. 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