Giter VIP home page Giter VIP logo

aiosu's Introduction

aiosu

Python version info PyPI version info pre-commit.ci status Documentation Status pytest Status mypy Status Codacy Status

Simple and fast asynchronous osu! API v1 and v2 library with various utilities.

Features

  • Support for modern async syntax (async with)
  • Support for API v1 and API v2
  • Rate limit handling
  • Utilities for osu! related calculations
  • Easy to use

Installing

Python 3.9 or higher is required

To install the library, simply run the following commands

# Linux/macOS
python3 -m pip install -U aiosu

# Windows
py -3 -m pip install -U aiosu

To install the development version, do the following:

$ git clone https://github.com/NiceAesth/aiosu
$ cd aiosu
$ python3 -m pip install -U .

API v1 Example

import aiosu
import asyncio


async def main():
    # async with syntax
    async with aiosu.v1.Client("osu api token") as client:
        user = await client.get_user(7782553)

    # regular syntax
    client = aiosu.v1.Client("osu api token")
    user = await client.get_user(7782553)
    await client.close()


if __name__ == "__main__":
    asyncio.run(main())

API v2 Example

import aiosu
import asyncio
import datetime


async def main():
    token = aiosu.models.OAuthToken.model_validate(json_token_from_api)

    # or

    token = aiosu.models.OAuthToken(
        access_token="access token",
        refresh_token="refresh token",
        expires_on=datetime.datetime.utcnow()
        + datetime.timedelta(days=1),  # can also be string
    )

    # async with syntax
    async with aiosu.v2.Client(
        client_secret="secret", client_id=1000, token=token
    ) as client:
        user = await client.get_me()

    # regular syntax
    client = aiosu.v2.Client(client_secret="secret", client_id=1000, token=token)
    user = await client.get_me()
    await client.close()


if __name__ == "__main__":
    asyncio.run(main())

You can find more examples in the examples directory.

Contributing

Please read the CONTRIBUTING.rst to learn how to contribute to aiosu!

Acknowledgments

aiosu's People

Contributors

niceaesth avatar pre-commit-ci[bot] avatar renovate[bot] avatar enricobaivo avatar mayacopeland avatar kuro-rui avatar lenforiee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.