PUBG API Core¶
The chicken_dinner
package provides a core class for low-level interaction
with the PUBG JSON API. To use it, you will need an api key, which you can get
from the developer portal here: https://developer.playbattlegrounds.com/.
Each method provides a deserialized JSON response for each of the endpoints provided by the API. Use this if you plan on working directly with the raw JSON responses from the API.
To interact with the API on a higher level refer to the documentation for
the chicken_dinner.pubgapi.PUBG
class.
Developer api keys come with a rate limit of 10 API calls per 60 seconds. The
PUBGCore
class provides a (blocking) built-in rate limiter that sleeps
automatically between consecutive requests to prevent hitting the rate limit.
Warning
(new in 0.4.0) PUBGCore (and PUBG) instances provide a built-in rate limiter which sleeps based on the API call being made and the rate limit information contained in the response headers. When rate limited, these classes will emit a warning to the console.
PUBGCore will attempt to avoid 429 (rate limited) responses altogether, but if a 429 response does occur, the client will sleep and attempt one retry before raising an exception.
-
class
chicken_dinner.pubgapi.
PUBGCore
(api_key, shard=None, gzip=True)[source]¶ Low level interface to the PUBG JSON API.
Provides methods for interfacing directly with the PUBG JSON API. Returns deserialized JSON responses.
Info: https://documentation.playbattlegrounds.com/en/introduction.html
Parameters: - api_key (str) – your PUBG api key
- shard (str) – (optional) the shard to use in all requests for this instance
- gzip (bool) – (optional) compress responses as gzip
-
api_key
¶ The API key being used.
-
leaderboard
(game_mode, shard=None)[source]¶ Get a response from the leaderboards endpoint.
Description: https://documentation.pubg.com/en/leaderboards-endpoint.html
Parameters: - game_mode (str) – the PUBG game mode to query
- shard (str) – (optional) the
shard
to use if different from the one used on instantiation
Returns: the json response from
/{shard}/leaderboards/{game_mode}
-
lifetime
(player_id, shard=None)[source]¶ Get a response from the lifetime stats endpoint.
Description: https://documentation.pubg.com/en/lifetime-stats.html
Parameters: - player_id (str) – the PUBG
player_id
(account id) to query - shard (str) – (optional) the
shard
to use if different from the one used on instantiation
Returns: the json response from
/{shard}/players/{player_id}/seasons/lifetime
- player_id (str) – the PUBG
-
match
(match_id, shard=None)[source]¶ Get a response from the match endpoint.
Description: https://documentation.playbattlegrounds.com/en/matches-endpoint.html
Calls here do not apply to the rate limit.
Parameters: - match_id (str) – the
match_id
to query - shard (str) – (optional) the
shard
to use if different from the one used on instantiation
Returns: the json response from
/{shard}/matches/{match_id}
- match_id (str) – the
-
player
(player_id, shard=None)[source]¶ Get a response from the player endpoint.
Endpoints: https://documentation.playbattlegrounds.com/en/players-endpoint.html
Parameters: - player_id (str) – the PUBG
player_id
(account id) to query - shard (str) – (optional) the
shard
to use if different from the one used on instantiation
Returns: the JSON response from
/{shard}/players/{player_id}
- player_id (str) – the PUBG
-
player_season
(player_id, season_id, shard=None)[source]¶ Get a response from the player/season endpoint.
Endpoints: https://documentation.playbattlegrounds.com/en/players-endpoint.html
Parameters: - player_id (str) – the PUBG
player_id
(account id) to query - season_id (str) – the
season_id
to query - shard (str) – (optional) the
shard
to use if different from the one used on instantiation
Returns: the JSON response from
/{shard}/players/{player_id}/seasons/{season_id}
- player_id (str) – the PUBG
-
players
(filter_type, filter_value, shard=None)[source]¶ Get a response from the players endpoint.
Description: https://documentation.playbattlegrounds.com/en/players-endpoint.html
Parameters: - filter_type (str) – query by either “player_ids” or “player_names”
- filter_value (list) – a list of strings of the
player_ids
orplayer_names
to search - shard (str) – (optional) the
shard
to use if different from the one used on instantiation
Returns: the response from the
/{shard}/players
endpoint
-
samples
(start=None, shard=None)[source]¶ Get a response from the samples endpoint.
Description: https://documentation.playbattlegrounds.com/en/samples-endpoint.html
Parameters: - start (str) – (optional) the start timestamp from which to get samples
- shard (str) – (optional) the
shard
to use if different from the one used on instantiation
Returns: the JSON response from the
/{shard}/samples
endpoint
-
seasons
(shard=None)[source]¶ Get a response from the seasons endpoint.
Description: https://documentation.playbattlegrounds.com/en/players-endpoint.html#/Seasons/get_seasons
Parameters: shard (str) – (optional) the shard
to use if different from the one used on instantiationReturns: the JSON response from the /{shard}/seasons
endpoint.
-
status
()[source]¶ Get a response from the status endpoint.
Description: https://documentation.playbattlegrounds.com/en/status-endpoint.html
Returns: the JSON response from the /status
endpoint.
-
telemetry
(url)[source]¶ Download the telemetry data.
Description: https://documentation.playbattlegrounds.com/en/telemetry.html
Calls here do not apply to the rate limit.
Parameters: url (str) – the telemetry data URL Returns: the JSON response for the telemetry URL
-
tournament
(tournament_id)[source]¶ Get information about a tournament.
Description: https://documentation.playbattlegrounds.com/en/tournaments-endpoint.html#/Tournaments/get_tournaments__id_
Parameters: tournament_id (str) – the tournament ID on which to retrieve data Returns: the JSON response for the tournament id
-
tournaments
()[source]¶ Get a list of tournaments.
Description: https://documentation.playbattlegrounds.com/en/tournaments-endpoint.html#/Tournaments/get_tournaments
Returns: the JSON response for the tournaments endpoint