Class TopGGAPI


  • public class TopGGAPI
    extends dev.mayuna.simpleapi.SimpleAPI
    Main class of Top-GG API wrapped in Java. Using this class, you can request stuff and post stuff to top.gg's API. Some endpoints/methods do not require bot ID.
    • Constructor Summary

      Constructors 
      Constructor Description
      TopGGAPI​(@NonNull java.lang.String token)  
      TopGGAPI​(@NonNull java.lang.String token, java.lang.String botId)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      dev.mayuna.simpleapi.Action<Bot> fetchBot()
      Fetches your Bot by specified Bot ID in constructor.
      dev.mayuna.simpleapi.Action<Bot> fetchBot​(java.lang.String botId)
      Fetches your Bot by specified Bot ID in arguments.
      dev.mayuna.simpleapi.Action<Stats> fetchBotStats()
      Fetches specific stats (server count, shards, shard count) about a bot.
      dev.mayuna.simpleapi.Action<User[]> fetchLast1000Votes()
      Fetches the last 1000 voters for your bot.
      Note: If your bot receives more than 1000 votes monthly you cannot use this endpoint and must use webhooks and implement your own caching instead.

      This endpoint only returns unique votes, it does not include double votes (weekend votes).
      dev.mayuna.simpleapi.Action<MultiplierStatus> fetchMultiplierStatus()
      Fetches MultiplierStatus which tells if currently it is weekend (during weekends, bots receive double votes).
      dev.mayuna.simpleapi.Action<User> fetchUser​(java.lang.String userId)
      Fetches User by their Discord user ID
      dev.mayuna.simpleapi.Action<VoteStatus> fetchVoteStatus​(java.lang.String userId)
      Fetches status whether a user has voted for your bot.
      dev.mayuna.simpleapi.Header[] getDefaultHeads()  
      java.lang.String getURL()  
      dev.mayuna.simpleapi.Action<Bots> searchBots()
      Searches bots by specified arguments.
      dev.mayuna.simpleapi.Action<Bots> searchBots​(int limit)
      Searches bots by specified arguments.
      dev.mayuna.simpleapi.Action<Bots> searchBots​(int limit, int offset)
      Searches bots by specified arguments.
      dev.mayuna.simpleapi.Action<Bots> searchBots​(int limit, int offset, java.lang.String search)
      Searches bots by specified arguments.
      dev.mayuna.simpleapi.Action<Bots> searchBots​(int limit, int offset, java.lang.String search, java.lang.String sort)
      Searches bots by specified arguments.
      dev.mayuna.simpleapi.Action<Bots> searchBots​(int limit, int offset, java.lang.String search, java.lang.String sort, java.lang.String fields)
      Searches bots by specified arguments.
      dev.mayuna.simpleapi.Action<Bots> searchBots​(java.lang.String search)
      Searches bots by specified arguments.
      dev.mayuna.simpleapi.Action<Bots> searchBots​(java.lang.String search, java.lang.String sort)
      Searches bots by specified arguments.
      dev.mayuna.simpleapi.Action<TopGGAPIResponse> updateBotStats​(int serverCount)
      Updates bot's stats.
      dev.mayuna.simpleapi.Action<TopGGAPIResponse> updateBotStats​(int[] serverCount)
      Updates bot's stats.
      dev.mayuna.simpleapi.Action<TopGGAPIResponse> updateBotStats​(int[] serverCount, int shardCount)
      Updates bot's stats.
      dev.mayuna.simpleapi.Action<TopGGAPIResponse> updateBotStats​(int serverCount, int shardCount)
      Updates bot's stats.
      dev.mayuna.simpleapi.Action<TopGGAPIResponse> updateBotStats​(int serverCount, int[] shards)
      Updates bot's stats.
      dev.mayuna.simpleapi.Action<TopGGAPIResponse> updateBotStats​(int serverCount, int[] shards, int shardCount)
      Updates bot's stats.
      dev.mayuna.simpleapi.Action<TopGGAPIResponse> updateBotStats​(int serverCount, int shardId, int shardCount)
      Updates bot's stats.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TopGGAPI

        public TopGGAPI​(@NonNull
                        @NonNull java.lang.String token,
                        java.lang.String botId)
      • TopGGAPI

        public TopGGAPI​(@NonNull
                        @NonNull java.lang.String token)
    • Method Detail

      • getURL

        public java.lang.String getURL()
        Specified by:
        getURL in class dev.mayuna.simpleapi.SimpleAPI
      • getDefaultHeads

        public dev.mayuna.simpleapi.Header[] getDefaultHeads()
        Overrides:
        getDefaultHeads in class dev.mayuna.simpleapi.SimpleAPI
      • searchBots

        public dev.mayuna.simpleapi.Action<Bots> searchBots()
        Searches bots by specified arguments. Bot ID for this endpoint is not required.
        Default values:
        - Limit: 50
        - Offset: 0
        - Search empty
        - Sort empty
        - Fields empty
        Returns:
        Action with Bots object
        See Also:
        https://docs.top.gg/api/bot/#search-bots
      • searchBots

        public dev.mayuna.simpleapi.Action<Bots> searchBots​(int limit)
        Searches bots by specified arguments. Bot ID for this endpoint is not required.
        Default values:
        - Offset: 0
        - Search empty
        - Sort empty
        - Fields empty
        Parameters:
        limit - The amount of bots to search for. Max. 500
        Returns:
        Action with Bots object
        See Also:
        https://docs.top.gg/api/bot/#search-bots
      • searchBots

        public dev.mayuna.simpleapi.Action<Bots> searchBots​(int limit,
                                                            int offset)
        Searches bots by specified arguments. Bot ID for this endpoint is not required.
        Default values:
        - Search empty
        - Sort empty
        - Fields empty
        Parameters:
        limit - The amount of bots to search for. Max. 500
        offset - TAmount of bots to skip
        Returns:
        Action with Bots object
        See Also:
        https://docs.top.gg/api/bot/#search-bots
      • searchBots

        public dev.mayuna.simpleapi.Action<Bots> searchBots​(int limit,
                                                            int offset,
                                                            java.lang.String search)
        Searches bots by specified arguments. Bot ID for this endpoint is not required.
        Default values:
        - Sort empty
        - Fields empty
        Parameters:
        limit - The amount of bots to search for. Max. 500
        offset - TAmount of bots to skip
        search - A search string in the format of field: value field2: value2
        Returns:
        Action with Bots object
        See Also:
        https://docs.top.gg/api/bot/#search-bots
      • searchBots

        public dev.mayuna.simpleapi.Action<Bots> searchBots​(java.lang.String search)
        Searches bots by specified arguments. Bot ID for this endpoint is not required.
        Default values:
        - Limit: 50
        - Offset: 0
        - Sort empty
        - Fields empty
        Parameters:
        search - A search string in the format of field: value field2: value2
        Returns:
        Action with Bots object
        See Also:
        https://docs.top.gg/api/bot/#search-bots
      • searchBots

        public dev.mayuna.simpleapi.Action<Bots> searchBots​(java.lang.String search,
                                                            java.lang.String sort)
        Searches bots by specified arguments. Bot ID for this endpoint is not required.
        Default values:
        - Limit: 50
        - Offset: 0
        - Fields empty
        Parameters:
        search - A search string in the format of field: value field2: value2
        sort - The field to sort by. Prefix with - to reverse the order
        Returns:
        Action with Bots object
        See Also:
        https://docs.top.gg/api/bot/#search-bots
      • searchBots

        public dev.mayuna.simpleapi.Action<Bots> searchBots​(int limit,
                                                            int offset,
                                                            java.lang.String search,
                                                            java.lang.String sort)
        Searches bots by specified arguments. Bot ID for this endpoint is not required.
        Default values:
        - Fields empty
        Parameters:
        limit - The amount of bots to search for. Max. 500
        offset - TAmount of bots to skip
        search - A search string in the format of field: value field2: value2
        sort - The field to sort by. Prefix with - to reverse the order
        Returns:
        Action with Bots object
        See Also:
        https://docs.top.gg/api/bot/#search-bots
      • searchBots

        public dev.mayuna.simpleapi.Action<Bots> searchBots​(int limit,
                                                            int offset,
                                                            java.lang.String search,
                                                            java.lang.String sort,
                                                            java.lang.String fields)
        Searches bots by specified arguments. Bot ID for this endpoint is not required.
        Parameters:
        limit - The amount of bots to search for. Max. 500
        offset - TAmount of bots to skip
        search - A search string in the format of field: value field2: value2
        sort - The field to sort by. Prefix with - to reverse the order
        fields - A comma separated list of fields to show
        Returns:
        Action with Bots object
        See Also:
        https://docs.top.gg/api/bot/#search-bots
      • fetchBot

        public dev.mayuna.simpleapi.Action<Bot> fetchBot​(java.lang.String botId)
        Fetches your Bot by specified Bot ID in arguments. Bot ID for this method is not required.
        Parameters:
        botId - Bot's Discord ID
        Returns:
        Action with Bot object
        See Also:
        https://docs.top.gg/api/bot/#find-one-bot
      • fetchBot

        public dev.mayuna.simpleapi.Action<Bot> fetchBot()
        Fetches your Bot by specified Bot ID in constructor. Bot ID for this method is required.
        Returns:
        Action with Bot object
        See Also:
        https://docs.top.gg/api/bot/#find-one-bot
      • fetchLast1000Votes

        public dev.mayuna.simpleapi.Action<User[]> fetchLast1000Votes()
        Fetches the last 1000 voters for your bot.
        Note: If your bot receives more than 1000 votes monthly you cannot use this endpoint and must use webhooks and implement your own caching instead.

        This endpoint only returns unique votes, it does not include double votes (weekend votes).
        Returns:
        Action with User array
        See Also:
        https://docs.top.gg/api/bot/#last-1000-votes
      • fetchBotStats

        public dev.mayuna.simpleapi.Action<Stats> fetchBotStats()
        Fetches specific stats (server count, shards, shard count) about a bot.
        Returns:
        Action with Stats object
      • fetchVoteStatus

        public dev.mayuna.simpleapi.Action<VoteStatus> fetchVoteStatus​(java.lang.String userId)
        Fetches status whether a user has voted for your bot. Safe to use even if you have over 1k monthly votes.
        Parameters:
        userId - User ID (Discord user ID)
        Returns:
        Action with VoteStatus object
        See Also:
        https://docs.top.gg/api/bot/#individual-user-vote
      • updateBotStats

        public dev.mayuna.simpleapi.Action<TopGGAPIResponse> updateBotStats​(int serverCount,
                                                                            int shardId,
                                                                            int shardCount)
        Updates bot's stats.
        Parameters:
        serverCount - Amount of servers the bot is in
        shardId - The zero-indexed id of the shard posting. Makes server_count set the shard specific server count.
        shardCount - The amount of shards the bot has
        Returns:
        Action with TopGGAPIResponse object
        See Also:
        https://docs.top.gg/api/bot/#post-stats
      • updateBotStats

        public dev.mayuna.simpleapi.Action<TopGGAPIResponse> updateBotStats​(int[] serverCount,
                                                                            int shardCount)
        Updates bot's stats.
        Parameters:
        serverCount - Amount of servers the bot is in per shard
        shardCount - The amount of shards the bot has
        Returns:
        Action with TopGGAPIResponse object
        See Also:
        https://docs.top.gg/api/bot/#post-stats
      • updateBotStats

        public dev.mayuna.simpleapi.Action<TopGGAPIResponse> updateBotStats​(int serverCount,
                                                                            int[] shards)
        Updates bot's stats. This method seems quite useless, however I am keeping this method just in case.
        Parameters:
        serverCount - Amount of servers the bot is in
        shards - Amount of servers the bot is in per shard
        Returns:
        Action with TopGGAPIResponse object
        See Also:
        https://docs.top.gg/api/bot/#post-stats
      • updateBotStats

        public dev.mayuna.simpleapi.Action<TopGGAPIResponse> updateBotStats​(int serverCount,
                                                                            int[] shards,
                                                                            int shardCount)
        Updates bot's stats. This method seems quite useless, however I am keeping this method just in case.
        Parameters:
        serverCount - Amount of servers the bot is in per shard
        shards - Amount of servers the bot is in per shard
        shardCount - The amount of shards the bot has
        Returns:
        Action with TopGGAPIResponse object
        See Also:
        https://docs.top.gg/api/bot/#post-stats
      • fetchUser

        public dev.mayuna.simpleapi.Action<User> fetchUser​(java.lang.String userId)
        Fetches User by their Discord user ID
        Parameters:
        userId - User ID (Discord user ID)
        Returns:
        Action with User object
      • fetchMultiplierStatus

        public dev.mayuna.simpleapi.Action<MultiplierStatus> fetchMultiplierStatus()
        Fetches MultiplierStatus which tells if currently it is weekend (during weekends, bots receive double votes).
        Returns:
        Action with MultiplierStatus object