Skip to main content

A simple API wrapper for topstats.gg written in Python.

Project description

topstats pypi downloads

A simple API wrapper for topstats.gg written in Python.

Getting started

Make sure you already have an API token handy. See this page on how to retrieve it.

After that, run the following command in your terminal:

pip install topstats

Example

For more information, please read the documentation.

# Import the module.
import topstats

import asyncio
import os


async def main() -> None:
  
  # Declare the client.
  async with topstats.Client(os.getenv('TOPSTATS_TOKEN')) as ts:
    
    # Fetch a bot from its ID.
    bot = await ts.get_bot(432610292342587392)
    
    print(bot)

    # Fetch topstats.gg's top bots.
    bots = await ts.get_top_bots(sort_by=topstats.SortBy.server_count())
    
    for b in bots:
      print(b)
    
    # Search for bots that has the name 'MEE6.'
    mee6_bots = await ts.search_bots(name='MEE6')

    for b in mee6_bots:
      print(b)

    # Search for anime-tagged bots.
    anime_bots = await ts.search_bots(tag='anime')

    for b in anime_bots:
      print(b)
    
    # Fetch a bot's historical server count.
    sc = await ts.get_historical_bot_server_count(432610292342587392)

    for server_count in sc:
      print(server_count)
    
    # Compare two bots' historical server count.
    vs = await ts.compare_bot_server_count(432610292342587392, 437808476106784770)

    for first, second in vs:
      print(first, second)
    
    # Compare up to four bots' historical total vote count.
    vs2 = await ts.compare_bot_total_votes(
      topstats.Period.LAST_YEAR,
      339254240012664832,
      432610292342587392,
      408785106942164992,
      437808476106784770
    )

    for first, second, third, fourth in vs2:
      print(first, second, third, fourth)

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

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

topstats-1.1.3.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

topstats-1.1.3-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file topstats-1.1.3.tar.gz.

File metadata

  • Download URL: topstats-1.1.3.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for topstats-1.1.3.tar.gz
Algorithm Hash digest
SHA256 82dabbf14bffc2c04df035b74d42c9d6f98e3e269c9a6a342d476a92eeaae768
MD5 79868080314991ce36854bf90e99799e
BLAKE2b-256 a293a65a168596bae1798c5f4cf5d3a069029e8281179857ccc425e7496067f9

See more details on using hashes here.

File details

Details for the file topstats-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: topstats-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for topstats-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e86cb408fa3bfb028e11bf77f0ac79d669070915b537674b687fd00a5aa69e8a
MD5 07fd9d43be68f159aaf1413c7aa7ae1d
BLAKE2b-256 faa264882438ed417c06576bbca39f2637c5f17058652971aec10eb801136960

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