PHP code example of ptrtn / battlerite

1. Go to this page and download the library: Download ptrtn/battlerite library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ptrtn / battlerite example snippets


$client = \PtrTn\Battlerite\Client::create('your-api-key');
$status = $client->getStatus();

$client = \PtrTn\Battlerite\Client::create('your-api-key');
$matches = $client->getMatches();
echo $matches[0]->map->type;
// QUICK2V2

$client = \PtrTn\Battlerite\Client::create('your-api-key');
$teams = $client->getTeams(
    TeamsQuery::create()
    ->forPlayerIds(['322'])
    ->forSeason(5)
);

$client = \PtrTn\Battlerite\Client::create('your-api-key');
$match = $client->getMatch('AB9C81FABFD748C8A7EC545AA6AF97CC');

$client = \PtrTn\Battlerite\Client::create('your-api-key');
$match = $client->getPlayer('934791968557563904');

$client = \PtrTn\Battlerite\Client::create('your-api-key');
// Retrieve matches for a specific player for the last 24 hours
$matches = $client->getMatches(
    MatchesQuery::create()
    ->forPlayerIds(['934791968557563904'])
    ->withStartDate(new DateTime('-1 day'))
);

$client = \PtrTn\Battlerite\Client::create('your-api-key');
// Retrieve a list of players for a specific player name
$players = $client->getPlayers(
    PlayersQuery::create()
    ->forPlayerNames(['PlakkeStrasser'])
);

 $client = \PtrTn\Battlerite\Client::create('your-api-key');
 $teams = $client->getTeams(
     TeamsQuery::create()
     ->forPlayerIds(['322'])
     ->forSeason(5)
 );
 

// Create client using default filesystem cache
$client = ClientWithCache::create('your-api-key');

// Create a client using custom configured cache
$client = ClientWithCache::createWithCache(
    'your-api-key',
    new RedisCache(),
    300
);