PUBG Web API wrapper for nodejs
Todo
- Telemetry
-
-
- Spectators class (not yet introduced in API)
- Rounds class (not yet introduced in API)
- Tournaments
Install
Clone this repo and include index.js or install via npm:
npm install battlegrounds
Usage
Requiring a module returns API class:
const battlegrounds = require('battlegrounds')
const api = new battlegrounds(APIKEY, 'pc-eu')
// Get a player
const res = await api.getPlayers({ names: ['shroud'] })
Description
The main focus of this module is it's ease of use.
For example, getting a player returns its class that contains other properties methods of which can be used:
const res = await api.getPlayers({ names: ['shroud'] })
// Is a member of Player class
const player = res[0]
// Get first match. Match class is returned
const match = player.matches[0].get()
Classes
List of all classes returned by a module
API(apikey[, platform])
Is returned by module when required
- apikey - your apikey (you can get it here)
- platform (optional) - default platform id to be included as a parameter in every method. Full list here)
API.getSamples(params)
Returns a Sample class
- date (optional) - an instance of Date class. Has to be at least 24hrs in the past. Default value is 24 hours ago.
API.getMatch(params)
Returns a Match class
Note: currently it is not possible to get custom Matches.
API.getPlayers(params)
Returns a list of Player classes
- ids (optional) - An array of Player ids
- names (optional) - An array of Player names
Note: at least one of those parameters have to be provided, in other cases "MissingParameter" error will be thrown
API.getPlayer(params)
Returns a Player class
API.getSeasons(params)
Returns a list of Season classes
API.getPlayerSeason(params)
Returns a PlayerSeason classes
Player
Represents a Player. If only contains its id, get method has to be called to get full info about itself.
- id - Player id. Has a format of
account.x
where x - 32 char hex
- attributes
-
-
- shardId - platform id (full list here))
-
-
- matches - An array of Player Matches
- assets - An array of Player Assets
Player.get()
Calls an API to get Player's full info and returns itself.
Match
Represents a Match. If only contains its id, get method has to be called to get full info about itself.
- id - Match id. Has a format of
a-b-b-b-c
where a - 8 char hex, b - 4 char hex, c - 12 char hex
- attributes
-
-
- createdAt - date when the object was created
-
- duration - duration time in seconds
-
- gameMode - game mode (for ex duo-fpp, squad-tpp, etc)
-
-
- shardId - platform id (full list here)
-
-
-
- titleId - tournament title. For regular matches will be
bluehole-pubg
- rosters - An array of Rosters
- assets - An array of Assets
- rounds - An array of Rounds
- spectators - An array of Spectators
- participants - An array of Participants
Match.get()
Calls an API to get Match's full info and returns itself.
Participant
Represents a Match Participant.
- id - Participant id. Has a format of
a-b-b-b-c
where a - 8 char hex, b - 4 char hex, c - 12 char hex
- attributes
-
-
- shardId - platform id (full list here))
-
-
-
-
-
-
-
- damageDealt - damage dealt to others
-
-
- deathType - death type. Can be
byplayer
or suicide
-
-
- headshotKills - headshot kills
-
-
-
- killPlace - place by kills
-
-
-
-
-
-
-
-
-
-
-
- playerId - Player id. Has a format of
account.x
where x - 32 char hex
-
-
-
- rideDistance - distance driven on a vehicle
-
-
- roadKills - kills by vehicle
-
-
-
- timeSurvived - total time survived in seconds
-
-
- vehicleDestroys - vehicles destroyed
-
-
- walkDistance - distance a Player has walked
-
-
-
-
- winPoints - total win points
-
Roster
Represents a team of Participants in a Match
- id - Roster id. Has a format of
a-b-b-b-c
where a - 8 char hex, b - 4 char hex, c - 12 char hex
- attributes
-
- shardId - platform id (full list here))
-
- won - Boolean. Whenever Roster won or not
-
-
-
-
- teamId - Roster team number in Match in order of joining
- participants - Roster Participants
Asset
Represents an Asset with an attached resource
- id - Asset id. Has a format of
a-b-b-b-c
where a - 8 char hex, b - 4 char hex, c - 12 char hex
- attributes
-
- URL - resource url. You can download it using fetch method
-
- createdAt - date when the object was created
-
-
- name - for Match Assets will be
telemetry
Asset.fetch()
Fetches Asset content from URL. Returns different objects depending on type (name) of an Asset:
Sample
Represents a list of Matches
- id - Asset id. Has a format of
a-b-b-b-c
where a - 8 char hex, b - 4 char hex, c - 12 char hex
- attributes
-
- createdAt - date when the object was created
-
- shardId - platform id (full list here))
-
- titleId - tournament title. For regular matches will be
bluehole-pubg
- matches - an array of Matches
Season
Represents a game Season
- id - Asset id. Has a format of
a-b-b-b-c
where a - 8 char hex, b - 4 char hex, c - 12 char hex
- attributes
-
- isCurrentSeason - boolean that indicates if season is active or not
-
- isOffseason - boolean, true if season is not active
Season.get()
Queries all Seasons and finds needed one by id. Returns updated Season class
PlayerSeason
Represents Player Season stats
- attributes
-
- assists - Number of enemy players this player damaged that were killed by teammates
-
- boosts - Number of boost items used
-
- dBNOs - Number of enemy players knocked
-
-
- damageDealt - Total damage dealt. Note: Self inflicted damage is subtracted
-
-
- headshotKills - Number of enemy players killed with headshots
-
- heals - Number of healing items used
-
- killPoints - Points based on how many kills this player had
-
- kills - Number of enemy players killed
-
-
- longestTimeSurvived - Longest time survived in a match
-
- losses - Number of matches lost
-
-
- mostSurvivalTime - Longest time survived in a match
-
- revives - Number of times this player revived teammates
-
- rideDistance - Total distance traveled in vehicles measured in meters
-
- roadKills - Number of kills while in a vehicle
-
- roundMostKills - Highest number of kills in a single match
-
- roundsPlayed - Number of matches played
-
- suicides - Number of self-inflicted deaths
-
- teamKills - Number of times this player killed a teammate
-
- timeSurvived - Total time survived
-
- top10s - Number of times this player made it to the top 10 in a match
-
- vehicleDestroys - Number of vehicles destroyed
-
- walkDistance - Total distance traveled on foot measured in meters
-
- weaponsAcquired - Number of weapons picked up
-
-
-
- wins - Number of matches won
- matchesSolo - solo tpp Match array
- matchesSoloFPP - solo fpp Match array
- matchesDuo - duo tpp Match array
- matchesDuoFPP - duo fpp Match array
- matchesSquad - squad tpp Match array
- matchesSquadFPP - squad fpp Match array
- season - Season
- player - Player