Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/popura-network/atoot
Asynchronous Python library for Mastodon API
https://github.com/popura-network/atoot
aiohttp asyncio decentralized mastodon python
Last synced: about 1 month ago
JSON representation
Asynchronous Python library for Mastodon API
- Host: GitHub
- URL: https://github.com/popura-network/atoot
- Owner: popura-network
- License: mit
- Created: 2020-06-24T15:26:25.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-07-23T14:07:51.000Z (over 4 years ago)
- Last Synced: 2024-04-14T01:33:18.286Z (7 months ago)
- Topics: aiohttp, asyncio, decentralized, mastodon, python
- Language: Python
- Homepage: https://atoot.readthedocs.io/en/latest/
- Size: 31.3 KB
- Stars: 20
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
=====
atoot
=====*atoot* is a Python library providing an easy way to create Mastodon API applications.
Key features
============- Python 3 library
- Asynchronous networking with asyncio and aiohttp
- Every API method is implemented https://docs.joinmastodon.org/methods/
- Client as a context manager
- Results paginationRequirements
============- aiohttp
- pytest (for tests)Getting started
===============Install
-------::
pip install atoot
Use
---Basic usage example:
.. code-block:: python
import atoot
import asyncioasync def mastodon_bot():
instance = "botsin.space"
access_token = "YOUR_APPLICATION_ACCESS_TOKEN"client = await atoot.MastodonAPI.create(instance, access_token=access_token)
resp = await client.verify_account_credentials()
print(resp)
await client.close()asyncio.run(mastodon_bot())
Using client as a context manager, get 5 pages of home timeline and all notifications:
.. code-block:: python
async def mastodon_bot():
instance = "botsin.space"
access_token = "YOUR_APPLICATION_ACCESS_TOKEN"async with atoot.client(instance, access_token=access_token) as c:
home = await c.get_n_pages(c.home_timeline(limit=20), n=5)
print("Home timeline:", home)notifs = await c.get_all(c.get_notifications())
print("Notifications:", notifs)License
=======MIT