Name | topstats JSON |
Version |
1.1.0
JSON |
| download |
home_page | None |
Summary | The community-maintained Python API wrapper for topstats.gg. |
upload_time | 2025-02-18 12:52:04 |
maintainer | None |
docs_url | None |
author | null8626 |
requires_python | >=3.9 |
license | MIT |
keywords |
discord
discord-bot
topgg
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# [topstats][pypi-url] [![pypi][pypi-image]][pypi-url] [![downloads][downloads-image]][pypi-url]
[pypi-image]: https://img.shields.io/pypi/v/topstats.svg?style=flat-square
[pypi-url]: https://pypi.org/project/topstats/
[downloads-image]: https://img.shields.io/pypi/dm/topstats?style=flat-square
The community-maintained Python API wrapper for [topstats.gg](https://topstats.gg).
## Installation
```console
pip install topstats
```
## Example
For more information, please read the [documentation](https://topstats.readthedocs.io/en/latest/).
```py
# import the module
import topstats
import asyncio
import os
async def main() -> None:
# declare the client. to retrieve your topstats.gg token, see https://docs.topstats.gg/authentication/tokens/
async with topstats.Client('your topstats.gg API token') as ts:
# fetch a ranked bot from its bot 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)
# 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 votes
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__':
# see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop
# for more details
if os.name == 'nt':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
asyncio.run(main())
```
Raw data
{
"_id": null,
"home_page": null,
"name": "topstats",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "discord, discord-bot, topgg",
"author": "null8626",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/92/e6/3352d034b142bc575ef6aa2a59413639799cc0cca3ebb5bddd3d038d08d0/topstats-1.1.0.tar.gz",
"platform": null,
"description": "# [topstats][pypi-url] [![pypi][pypi-image]][pypi-url] [![downloads][downloads-image]][pypi-url]\n\n[pypi-image]: https://img.shields.io/pypi/v/topstats.svg?style=flat-square\n[pypi-url]: https://pypi.org/project/topstats/\n[downloads-image]: https://img.shields.io/pypi/dm/topstats?style=flat-square\n\nThe community-maintained Python API wrapper for [topstats.gg](https://topstats.gg).\n\n## Installation\n\n```console\npip install topstats\n```\n\n## Example\n\nFor more information, please read the [documentation](https://topstats.readthedocs.io/en/latest/).\n\n```py\n# import the module\nimport topstats\n\nimport asyncio\nimport os\n\nasync def main() -> None:\n # declare the client. to retrieve your topstats.gg token, see https://docs.topstats.gg/authentication/tokens/\n async with topstats.Client('your topstats.gg API token') as ts:\n # fetch a ranked bot from its bot ID\n bot = await ts.get_bot(432610292342587392)\n \n print(bot)\n\n # fetch topstats.gg's top bots\n bots = await ts.get_top_bots(sort_by=topstats.SortBy.server_count())\n \n for b in bots:\n print(b)\n \n # compare two bots' historical server count\n vs = await ts.compare_bot_server_count(432610292342587392, 437808476106784770)\n\n for first, second in vs:\n print(first, second)\n \n # compare up to four bots' historical total votes\n vs2 = await ts.compare_bot_total_votes(\n topstats.Period.LAST_YEAR,\n 339254240012664832,\n 432610292342587392,\n 408785106942164992,\n 437808476106784770\n )\n\n for first, second, third, fourth in vs2:\n print(first, second, third, fourth)\n\nif __name__ == '__main__':\n # see https://stackoverflow.com/questions/45600579/asyncio-event-loop-is-closed-when-getting-loop\n # for more details\n if os.name == 'nt':\n asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())\n \n asyncio.run(main())\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "The community-maintained Python API wrapper for topstats.gg.",
"version": "1.1.0",
"project_urls": {
"Documentation": "https://topstats.readthedocs.io/en/latest/",
"Raw API Documentation": "https://docs.topstats.gg/introduction/introduction/",
"Repository": "https://github.com/top-stats/python-sdk",
"Support server": "https://discord.gg/jjEauJXuZc"
},
"split_keywords": [
"discord",
" discord-bot",
" topgg"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "8e3072c2492f9cc9eaa6f314c1d99f4f56369aee956ffc39f6aef4c00668c544",
"md5": "8d18e15e6ba7f6fa0bef4a46f8b87dbf",
"sha256": "f3b9bcef913b794c01cb7fb6e3b93065533677600a68d55f40f2867807f965b4"
},
"downloads": -1,
"filename": "topstats-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8d18e15e6ba7f6fa0bef4a46f8b87dbf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 13266,
"upload_time": "2025-02-18T12:52:03",
"upload_time_iso_8601": "2025-02-18T12:52:03.222079Z",
"url": "https://files.pythonhosted.org/packages/8e/30/72c2492f9cc9eaa6f314c1d99f4f56369aee956ffc39f6aef4c00668c544/topstats-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "92e63352d034b142bc575ef6aa2a59413639799cc0cca3ebb5bddd3d038d08d0",
"md5": "57eade79cfd346f70af72c197c090222",
"sha256": "2caf43f7b36d26616abfa8911b68147f63f7f300b33f354116af4d799e0fefa2"
},
"downloads": -1,
"filename": "topstats-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "57eade79cfd346f70af72c197c090222",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 9673,
"upload_time": "2025-02-18T12:52:04",
"upload_time_iso_8601": "2025-02-18T12:52:04.507095Z",
"url": "https://files.pythonhosted.org/packages/92/e6/3352d034b142bc575ef6aa2a59413639799cc0cca3ebb5bddd3d038d08d0/topstats-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-18 12:52:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "top-stats",
"github_project": "python-sdk",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "topstats"
}