Asynchronous Python library for the Mastodon API
Project description
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 pagination
Requirements
aiohttp
pytest (for tests)
Getting started
Install
pip install atoot
Use
Basic usage example:
import atoot
import asyncio
async 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:
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
atoot-1.0.post1.tar.gz
(8.9 kB
view hashes)
Built Distribution
Close
Hashes for atoot-1.0.post1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42ffd0724913507b33dd135ab4571778233ec29c4f7b5004972593cafc790bd5 |
|
MD5 | 2120037e7f1639c51ef94668b21fe3fa |
|
BLAKE2b-256 | 3b8d9c1654bbdcde1771352be066af376bc05f7bf7530bfc719bcadd7b0c8d62 |