popura-network / atoot

Asynchronous Python library for Mastodon API

Home Page:https://atoot.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

atoot

atoot is a Python library providing an easy way to create Mastodon API applications.

Key features

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

About

Asynchronous Python library for Mastodon API

https://atoot.readthedocs.io/en/latest/

License:MIT License


Languages

Language:Python 100.0%