Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Polsulpicien/ObserverAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

observer logo

ObserverAPI

Discord Discord
Stars Version
Pip Downloads Pip Downloads Pip Downloads

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.tracked_players)
    
    # 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.