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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ObserverAPI-1.1.5-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file ObserverAPI-1.1.5.tar.gz.

File metadata

  • Download URL: ObserverAPI-1.1.5.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.1

File hashes

Hashes for ObserverAPI-1.1.5.tar.gz
Algorithm Hash digest
SHA256 489dc2382b6725167caa7abe61586fa0f9c32d265f1b502faedf20aec2e0c33b
MD5 bc465bf02b10961976a56d49b0ddda88
BLAKE2b-256 f06d4edd50a4dcf86ebf5cdc20aeac5fb97aca157b80c11d20c1eaf184caf4f8

See more details on using hashes here.

File details

Details for the file ObserverAPI-1.1.5-py3-none-any.whl.

File metadata

  • Download URL: ObserverAPI-1.1.5-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.1

File hashes

Hashes for ObserverAPI-1.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 da277d7341a1b245dc146aa14cefc059e615570c4e5031a0e6ae69ec72d3171c
MD5 61c31f75b14c9c3d3f847ac2eef8e4b9
BLAKE2b-256 1e92ac67511eef1276f8f61e849ab3bcb75eb0330ec7711c813e3dab306e1a3b

See more details on using hashes here.

Supported by

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