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.2.tar.gz (11.8 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.2-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: topstats-1.1.2.tar.gz
  • Upload date:
  • Size: 11.8 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.2.tar.gz
Algorithm Hash digest
SHA256 15ddb3d054a399330604a6273ff9b9c66ceeece05b8aece46e42f1cfccd42076
MD5 911612d9a88f70a5b0c9d2b456fabd71
BLAKE2b-256 edf4b412a1263e5735891d65d87f4a712432b24e484a4385a265f02792d71e28

See more details on using hashes here.

File details

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

File metadata

  • Download URL: topstats-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8a1d7d1ea4ba5046100feed312cf1f6dcd3be2f21ac2783dd4ffcac6707edcb7
MD5 0aeab658fa24f0d7cac48b769bb5ec1d
BLAKE2b-256 3234faa283f2f0f8e3e58773c6063c5e279a40f0b5ee63fe9587bc7a87b4e585

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