Skip to main content

Observer API Wrapper in Python

Project description

observer logo

ObserverAPI

Discord Discord
Stars Version

Observer API Wrapper in Python

Introduction

This is the first Observer API Wrapper in Python.
This API Wrapper currently supports all endpoints (GET and POST).
You can find them all in the Documentation.

If you need help please join Polsu Development Support Server.

Installing

Install the ObserverAPI using pip
> Current Version: 1.1.5

py -m pip install ObserverAPI

This library was only tested with python 3.10 but I set it to 3.8 since I think everything should work. Please report me any issues! Thank you.

Usage

A Basic Example:

from ObserverAPI import Observer
import asyncio

async def main():
    client = await Observer(key="XXX") #define the client with your Observer API Key

    # Get the stats of Technoblade (UUID: b876ec32e396476ba1158438d83c67d4) 100 days ago
    lookback = await client.lookback.get("b876ec32e396476ba1158438d83c67d4", 100)
    print(lookback.bedwars.level)
    
    # Observer API Stats
    api_stats = await client.stats.get()
    print(api_stats.trackedPlayers)
    
    # Get the Top 10 players, All-Time Bedwars Wins Leaderboard 
    leaderboard = await client.leaderboard.get("alltime", "bedwars", "wins", 1, 10)
    print(leaderboard.leaderboard)
    
    # Get the second player on the leaderboard
    second_player_on_leaderboard = leaderboard.get_index(2)
    print(second_player_on_leaderboard.formatted, second_player_on_leaderboard.rank, second_player_on_leaderboard.value)

    # Get Technoblade (UUID: b876ec32e396476ba1158438d83c67d4) leaderboard rank, in this case in the All-Time Bedwars Wins Leaderboard
    ranking = await client.ranking.get("b876ec32e396476ba1158438d83c67d4", "alltime", "bedwars", "wins")
    print(ranking.rank)
    
    # Get the formatted name of a Player, in this case, Technoblade (UUID: b876ec32e396476ba1158438d83c67d4) -> §d[PIG§b+++§d] Technoblade
    formatted = await client.formatted.get("b876ec32e396476ba1158438d83c67d4")
    print(formatted.formatted)

asyncio.get_event_loop().run_until_complete(main()) # launch the main function

You can find this example and more examples in the examples folder

Links

License

This project is under the MIT License.

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

ObserverAPI-1.1.5.tar.gz (9.6 kB view hashes)

Uploaded Source

Built Distribution

ObserverAPI-1.1.5-py3-none-any.whl (11.2 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