2017 © Pedro Peláez
 

library battlerite

A php-based client wrapping the battlerite API

image

ptrtn/battlerite

A php-based client wrapping the battlerite API

  • Tuesday, December 26, 2017
  • by PtrTn
  • Repository
  • 1 Watchers
  • 2 Stars
  • 45 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

Battlerite-sdk

PHP-based SDK for Battlerite API, (*1)

Build Status Code Coverage Scrutinizer Code Quality, (*2)

Features

  • Retrieve data for matches (by query)
  • Retrieve detailed data for a specific match
  • Retrieve data for players (by query)
  • Retrieve detailed data for a specific player
  • Retrieve team data for specific players and seasons
  • Retrieve api status

Requirements

  • Php 7.1 or higher

Installing

composer require ptrtn/battlerite-sdk, (*3)

Usage

Retrieving data can be as simple as one method call. If no search query is specified, API defaults are used instead., (*4)

Api status

The following example returns API status, patch version and other data, (*5)

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

Retrieving match data

Retrieving match data using API defaults, (*6)

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

Retrieving team data

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

Retrieving detailed match data

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

Retrieving detailed player data

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

Custom querying

A custom search query can be used to retrieve the exact data needed., (*7)

Matches

For matches the following query options are available: - Offset - Limit - Start date - End date - Player ids - Team names - Game modes - Ascending sorting - Descending sorting, (*8)

$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'))
);

Players

For players the following query options are available: - Player name - Steam id - Player id, (*9)

$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'])
);

Note: up to 6 players (1 per region) can be found for a specific player name., (*10)

Teams

For teams the following query options are available: - Season - Player id php $client = \PtrTn\Battlerite\Client::create('your-api-key'); $teams = $client->getTeams( TeamsQuery::create() ->forPlayerIds(['322']) ->forSeason(5) );, (*11)

Caching

When sending a lot of requests, the default rate limit of 10 requests per minute will pose an issue. In order to prevent this, caching can be enabled for the player details and match details endpoints., (*12)

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

Optionally an alternative cache lifetime or caching system implementing the Doctrine\Common\Cache\Cache interface can be configured., (*13)

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

How do I get an API key?

  1. In order to get an API key you should create a developer account and an app
  2. Once created, log in and browse to https://developer.battlerite.com/apps/your-app
  3. Scroll down to DEVELOPMENT API KEY THIS APP USES, it should look like: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9G9lIiwiYWRtaW4iOnRydWV9G9lIi.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ

Api documentation

Documentation for the Battlerite API can be found at http://battlerite-docs.readthedocs.io/en/latest/, (*14)

The Versions

26/12 2017

dev-master

9999999-dev

A php-based client wrapping the battlerite API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Ton

26/12 2017

v1.7

1.7.0.0

A php-based client wrapping the battlerite API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Ton

25/12 2017

v1.6

1.6.0.0

A php-based client wrapping the battlerite API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Ton

23/12 2017

dev-feature/uml-docs

dev-feature/uml-docs

A php-based client wrapping the battlerite API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Ton

23/12 2017

v1.5

1.5.0.0

A php-based client wrapping the battlerite API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Ton

17/12 2017

v1.4

1.4.0.0

A php-based client wrapping the battlerite API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Ton

16/12 2017

v1.3

1.3.0.0

A php-based client wrapping the battlerite API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Ton

16/12 2017

v1.2

1.2.0.0

A php-based client wrapping the battlerite API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Ton

10/12 2017

dev-feature/domain-model

dev-feature/domain-model

A php-based client wrapping the battlerite API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Ton

10/12 2017

v1.1

1.1.0.0

A php-based client wrapping the battlerite API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Ton

10/12 2017

v1.0.2

1.0.2.0

A php-based client wrapping the battlerite API

  Sources   Download

MIT

The Requires

 

The Development Requires

by Peter Ton

10/12 2017

v1.0.1

1.0.1.0

A php-based client wrapping the battlerite API

  Sources   Download

The Requires

 

The Development Requires

by Peter Ton

09/12 2017

v1.0.0

1.0.0.0

A php-based client wrapping the battlerite API

  Sources   Download

The Requires

 

The Development Requires

by Peter Ton