PHPUBG
, (*1)
PHP wrapper for the PUBG Tracker API., (*2)
Installation
PHPUBG is available on packagist, so you can easily require it via composer:, (*3)
composer require mcmainiac/phpubg
To use this as a standalone library (without composer), download the repository and extract it somewhere (preferably in your projects libraries folder) and set up an autoloader to load all files dynamically.
The root namespace of this library is \PHPUBG., (*4)
Usage
To get your own api key, please visit pubgtracker.com/site-api., (*5)
Assuming you are at the root of your project (the vendor folder is within your current folder):, (*6)
<?php
require __DIR__ . "/vendor/autoload.php";
use PHPUBG\Region;
use PHPUBG\PubgBuilder;
$statsEurope = PubgBuilder::setApiKey("your-api-key")
->getPlayer("MCMainiac")
->getStats(
Region::get(Region::EUROPE)
);
var_dump($statsEurope);
This should dump all stats available for the player "MCMainiac" in the region "Europe"., (*7)
You can also use the Steam Id (a 64 bit number) instead of the username. PHPUBG will automatically resolve the username and get the stats:, (*8)
<?php
$builder = PubgBuilder::setApiKey("your-api-key");
$playerByName = $builder->getPlayer("MCMainiac");
$playerBySteamId = $builder->getPlayer(76561198128415640); // steam id for "MCMainiac"
// At this point $playerByName and $playerBySteamId are equivalent entities.
$playerByName->getNickname() == $playerBySteamID->getNickname(); // will return true
If you want to apply another filter, just pass it to the getStats method:, (*9)
$player->getStats($region, $season, $mode);
whereas:, (*10)
-
$region is an instance from the \PHPUBG\Region class or null
-
$season is an instance from the \PHPUBG\Season class or null
-
$mode is an instance from the \PHPUBG\matches\MatchMode class or null
If any variable of the above is null, then any value for this filter is accepted., (*11)
Example: You want to get all stats for the region "Europe" and the match mode "Solo":, (*12)
$region = Region::get(Region::EUROPE);
$mode = MatchMode::get(MatchMode::SOLO);
$europeSoloStats = $player->getStats($region, null, $mode);
Development
Feel free to clone the repository, make your changes and open a pull request., (*13)
Please report issues right here on GitHub using the issues system., (*14)
Notes
When requesting stats, please keep the number of requests at ~1/sec., (*15)
Thanks to pubgtracker.com for their public api., (*16)
Thanks to all contributors!, (*17)
Support on Beerpay
Hey dude! Help me out for a couple of :beers:!, (*18)
, (*19)