A .NET Standard API Client for the PUBG Statistics API
Endpoint | Status |
---|---|
Players | fully implemented |
Season stats | fully implemented |
Lifetime stats | fully implemented |
Weapon mastery | fully implemented |
Matches | fully implemented |
Leaderboards | fully implemented |
Tournaments | fully implemented |
Samples | fully implemented |
Telemetry | not implemented yet |
Status | not implemented yet |
Caching:
- Basic in-memory caching available
-
Acquire an API key for authorization from the pubg api developer portal.
-
Reference the project or a precompiled assembly in your own project. A NuGet Package will be available once the library is stable and implements all available endpoints.
-
Include the nescessary namespaces:
using PUBG.ApiClient; using PUBG.ApiClient.Model.Response; using PUBG.ApiClient.Model.Entity;
-
Create a new instance of the
PUBGApiClient
like below (you will have to supply your own auth token):PUBGApiClient pubgApiClient = new PUBGApiClient(ApiConstants.AuthToken);
-
Make requests to the api using the api client:
var rankedPlayerStats = await pubgApiClient.GetRankedSeasonStats("steam", account.c0e530e9b7244b358def282782f893af", "division.bro.official.pc-2018-07");
No. The Api client handles this for you. By default InMemoryRequestCache
is used. You can supply an IRequestCache
to the constructor of the PUBGApiClient
like below:
//This is the default behaviour of new PUBGApiClient(ApiConstants.AuthToken). This is just for illustration purposes!
InMemoryRequestCache inMemoryRequestCache = new InMemoryRequestCache();
PUBGApiClient pubgApiClient = new PUBGApiClient(ApiConstants.AuthToken, inMemoryRequestCache);
You can also disable caching by providing a NoRequestCache
to the constructor of the PUBGApiClient
like below:
NoRequestCache noRequestCache = new NoRequestCache();
PUBGApiClient pubgApiClient = new PUBGApiClient(ApiConstants.AuthToken, noRequestCache);
Other request caches will get implemented in the future but in the meantime you can also create your own:
using PUBG.ApiClient.Caching;
public class CustomRequestCache : IRequestCache
{
public async Task AddResponseToCache(string requestUrl, string response, DateTime requestTime)
{
//Implement cache store logic here
}
public async Task<string> TryGetResponseFromCache(string requestUrl, TimeSpan maxAge)
{
//Implement cache retrieve logic here
}
}
By default there are the following caching times defined in code by the [MaxRequestAge(60 * 15)]
attribute:
Endpoint | Default cache time |
---|---|
Players | 15 mins |
Season stats | 15 mins |
Lifetime stats | 15 mins |
Weapon mastery | 15 mins |
Matches | Infinite |
Leaderboards | 2 hours |
Tournaments | 15 mins |
Samples | No caching |
Telemetry | Infinite |
Status | No caching |
For API related known issues please head over to the known issues section of the api documentation