Skip to main content

PHP Library

The community-maintained PHP Library for If you experience any issues, please submit an issue on GitHub.


composer require top-gg/php-sdk


Getting Started

This library does certain things differently from other API wrappers because it follows PHP's PSR standards. Below is sample code on how to initialize and use the API wrapper.

# Automatically load up the source library code.
include_once __DIR__ . "vendor/autoload.php";

use DBL\DBL;

$api = new DBL([

Below are the currently accepted list of parameters when initializing the API.

tokenstringThe token key of the API.No
auto_statsarray[]Details for automatic stats.Yes
safetyboolWebserver code protection.Yes

The API wrapper also presents you with a boolean instance, connected which may be used to check if your API token key is still valid or not.

Get statistics from

In order to get statistics about a bot or user from, you are able to select between the two interchangably with the same method: find_info().

public function find_info(string $type, int $id): array
$typestringWhether you're looking for a bot or user.
$idintThe bot/user ID.
use DBL\API\Http;

* You will always be presented two constants to choose.
* Http::BOT = "bots"
* Http::USER = "users"
$user = $api->find_info(Http::USER, 242351388137488384);
$bot = $api->find_info(Http::BOT, 799697654279307314);

print_r($user) . print_r($bot) . PHP_EOL;

Search for specific bots

Similar to the same premise as using find_info(), you are able to additionally plug in query information that will be automatically formatted as a query-string URL search when an HTTP request is made by the API wrapper for you. This is known as show_info().

public function show_info(string $type, array $json = []): array
$typestringWhether you're looking for a bot or user.
$jsonarrayInformation to plug into the search.
use DBL\API\Http;

$small_list = $api->show_info(
"limit" => 20,
"sort" => "-"

print_r($small_list) . PHP_EOL;

Checking a vote from a user

It's very important to be able and see if a user has voted for your bot. Below is the given example of how to do this.

public function get_user_vote(int $id, int $user): array
$idintThe bot ID.
$userintThe user's snowflake ID.
$isVoted = $api->get_user_vote(799697654279307314, 242351388137488384);
if($isVoted) echo "This user voted!";