Skip to main content

An unofficial, async-ready wrapper for the Tatsu API.

Project description

Tatsu API Wrapper

PyPI supported Python versions License: MIT Checked with pyright Ruff Code style: black

A lightweight and asynchronous wrapper for Tatsu v1 API, written in Python. Supports every documented API endpoint.

To get an API key, use the command "t!apikey" on a Discord server with the Tatsu bot present.

Note: Modifying a user's scores/points isn't possible without certain Discord permissions. See the API docs for more info.

Installing

tatsu-api currently requires Python 3.8 or higher.

To install the library, run one of the following commands:

# Linux/macOS
python3 -m pip install -U tatsu-api

# Windows
py -3 -m pip install -U tatsu-api

Quick Example

For more examples, see the examples folder.

import asyncio
import tatsu_api as tatsu

async def main() -> None:
    """Example function."""
    
    api_key = "API_KEY"
    test_guild = 173184118492889089     # The Discord ID of the official Tatsu server.
    test_user = 1234567891              # Random Discord user ID.
    
    # The client can be used as a context manager to handle closing of the
    # internal HTTP session.
    async with tatsu.Client(api_key) as client:
        profile = await client.get_user(test_user)
        print(f"{profile.username} currently has {profile.credits} credits and {profile.reputation} reputation.")
        
        username = profile.username
        
        ranking = await client.get_member_ranking(test_guild, test_user, "all")
        print(f"On the Tatsu server, {username} ranks at {ranking.rank} for all time.")
        
        before_points = await client.get_member_points(test_guild, test_user)
        print(f"{username} - Points before update: {before_points.points}")
        
        after_points = await client.update_member_points(test_guild, test_user, -10)
        print(f"{username} - Points after update: {after_points.points}")

asyncio.run(main())

Acknowledgements

Shoutout to discord.py for being an inspiration and providing a strong example for implementation.

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

tatsu_api-1.0.0.post1.tar.gz (13.6 kB view hashes)

Uploaded Source

Built Distribution

tatsu_api-1.0.0.post1-py3-none-any.whl (12.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page