Skip to main content

A new, modern API wrapper for top.gg

Project description

Top.py

A modern python module wrapper for the official top.gg API.

THIS MODULE IS NOT ENDORSED BY TOP.GG. Their official package is here.

Installation

Dev

without pip

git clone https://github.com/dragdev-studios/top.py
cd top.py
python3 setup.py build && python3 setup.py install

with pip

pip install git+https://github.com/dragdev-studios/top.py

Stable

pip

pip install top.py

git

# replace curl with wget, or whatever you use to make web requests
curl https://github.com/dragdev-studios/top.py/archive/<version>.tar.gz > top.py.tar.gz
tar -xf top.py.tar.gz
cd top.py
python3 setup.py install

Usage

Documentation can be found in the github's wiki

from toppy.client import TopGG
from discord.ext import commands


class TopGGCog(commands.Cog):
    def __init__(self, bot):
        self.bot = bot
        self.top_gg = TopGG(
            self.bot,
            token="example-token-please-replace"
        )

    @commands.command()
    @commands.cooldown(1, 5)  # this can be changed, however over 60 requests per minute will get you blocked.
    async def voted(self, ctx):
        """Tells you if you've voted for me!"""
        has_voted = await self.top_gg.upvote_check(ctx.author.id)
        return await ctx.send("You have voted for me <3" if has_voted else "No, you haven't. Please vote!")

def setup(bot):
    bot.add_cog(TopGGCog(bot))

The above example will create a cog that will have a top_gg attribute and a voted command, which tells the user if they've voted.

TopGG(
    bot,
    token="...",
    autopost=False
)

This example will disable the internal autopost task (which posts your server count evey 30 minutes)

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

top.py-1.0.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

top.py-1.0.0-py3-none-any.whl (1.9 MB view details)

Uploaded Python 3

File details

Details for the file top.py-1.0.0.tar.gz.

File metadata

  • Download URL: top.py-1.0.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

File hashes

Hashes for top.py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 71dc1bbe61d15ad4abaa2d329743d65d1ed9b0b0f8bd094f6672531a0b6e02b2
MD5 e70aa2daf72242b0eb5f9733abaa5202
BLAKE2b-256 d9270c03b5c4c9ad1c2b898ce4f4776ef429cd5cb3811e857f4ef87f3df870d7

See more details on using hashes here.

File details

Details for the file top.py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: top.py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 1.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/54.1.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.1

File hashes

Hashes for top.py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5bdecdad09a32ebd3210c306d76e449d08109f487da1db9d4bec47d9fc2b6d97
MD5 ea72b98c519aea84977ea4d9aec72134
BLAKE2b-256 2a6632be5342c30df4c528266896f041e4274bdc9f15cee0080c1fda7a005379

See more details on using hashes here.

Supported by

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