battlefield stats (bf1, bf4)
A node api that allows you to collect, analyze, and serve battlefield 1 and battlefield 4 statistics. This fully makes use of the battlefield tracker network - https://battlefieldtracker.com/
Quick start
npm install battlefield-stats
// API_KEY from https://battlefieldtracker.com/site-apiconst bf = API_KEY;const params = personaId: xxxxxxxxx platform: bfPlatformsPC // bf.Server.quickServerInfo({platform: 3}, console.log);bfApi
Getting started
Get your API Key from the battlefield tracker network here: https://battlefieldtracker.com/site-api
Install battlefield-stats using npm by running using npm install battlefield-stats
Example
npm install battlefield-stats
const BattlefieldStats = ;const API_KEY = 'YourAPIKeyFromBfTracker' // from https://battlefieldtracker.com/site-apiconst bf = API_KEY; // All params mirror params listed at http://docs.trnbattlefield.apiary.io/#const params = platform: bfPlatformsPC // also you can use XBOX or PS4 displayName: YourOriginUserName // Or you can use personaId // Proxies to all api routes found http://docs.trnbattlefield.apiary.io/#const route = '/Stats/BasicStats'; bfApi
Usage with Express
You can use battlefield-stats-express
which adds hooks and functionality to express middleware with this module.
npm install battlefield-stats-express
const express = ;const battlefieldStats = ;const app = ; // Get or use your key from https://battlefieldtracker.com/site-api`const bfs = ; appapp;
Now you can see results when you navigate to http://localhost:3000/api/Stats/DetailedStats?platform=3&displayName=Ravic
For more information see battlefield-stats-express on github.
API Documentation
This API closely follows the REST Api documentation found at http://docs.trnbattlefield.apiary.io/#
Common Parameters
All API calls require platform
and either personaId
or displayName
, and optionally may use the game
parameter.
Platform
All the requests require a platform query parameter.
The following values are allowed: 1 for Xbox, 2 for PlayStation, and 3 for Origin. Alternatively, you can use Platforms.XBOX
, Platforms.PS4
, Platforms.PC
respectively.
Personas
Each request will also need either the personaId
or displayName
parameter, if specified.
If you're using the displayName variable be warned that for Xbox One and PlayStation 4 the api can only retrieve data if the player has played Battlefield 4 or Hardline.
Game
Certain requests can have an optional game parameter. The default value is tunguska
, which is the codename for Battlefield 1. It's possible to set this to bf4
to get data from Battlefield 4.
Platforms
This is just an enum to allow for more human readable code and is completely optional.
Platforms.XBOX
: 1
Platforms.PS4
: 2
Platforms.PC
: 3
Api.request
A generic request can be made to obtain anything from the api, however at this time all are covered with the rest of the apis.
const route = '/Stats/CareerForOwnedGames';const params = platform: bfPlatformsXBOX personaId: xxxxxxxxx ;bfApi;
The route
argument may be any of the Request Routes
mentioned in this documentation.
Stats
Stats.careerForOwnedGames
Parameters: platform
, personaId
, displayName
Request Route: /Stats/CareerForOwnedGames
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 displayName: YourOriginUserName // Or you can use personaIdbfStats
Stats.basicStats
Parameters: platform
, personaId
, displayName
, game
Request Route: /Stats/BasicStats
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 displayName: YourOriginUserName // Or you can use personaId game: 'tunguska' // default is tunguska, can be changed to bf4bfStats
Stats.detailedStats
Parameters: platform
, personaId
, displayName
, game
Request Route: /Stats/DetailedStats
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 displayName: YourOriginUserName // Or you can use personaId game: 'tunguska' // default is tunguska, can be changed to bf4bfStats
Progression
Progression.getCodex
Parameters: platform
, game
Request Route: /Progression/GetCodex
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 game: 'tunguska' // default is tunguska, can be changed to bf4bfProgression
Progression.getFilteredCodex
Parameters: platform
, personaId
, displayName
, game
Request Route: /Progression/GetFilteredCodex
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 displayName: YOUR_DISPLAY_NAMEbfProgression
Progression.getKitRanksMap
Parameters: platform
, personaId
, displayName
, game
Request Route: /Progression/GetKitRanksMap
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 displayName: YOUR_DISPLAY_NAMEbfProgression
Progression.getMedals
Parameters: platform
, personaId
, displayName
, game
Request Route: /Progression/GetMedals
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 displayName: YOUR_DISPLAY_NAMEbfProgression
Progression.getVehicle
Parameters: platform
, vehicleId
, personaId
, displayName
, game
Request Route: /Progression/GetVehicle
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 vehicleId: VEHICLE_ID displayName: YOUR_DISPLAY_NAMEbfProgression
Progression.getVehicles
Parameters: platform
, personaId
, displayName
, game
Request Route: /Progression/GetVehicles
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 displayName: YOUR_DISPLAY_NAMEbfProgression
Progression.getWeapon
Parameters: platform
, weaponId
, personaId
, displayName
, game
Request Route: /Progression/GetWeapon
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 weaponId: WEAPON_ID displayName: YOUR_DISPLAY_NAMEbfProgression
Progression.getWeapons
Parameters: platform
, personaId
, displayName
, game
Request Route: /Progression/GetWeapons
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 displayName: YOUR_DISPLAY_NAMEbfProgression
Loadout
Loadout.getItems
Parameters: platform
, game
Request Route: /Loadout/GetWeapons
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 bfLoadout
Loadout.getItemGates
Parameters: platform
, game
Request Route: /Loadout/getItemGates
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPC // also you can use XBOX or PS4 bfLoadout
Loadout.getPresets
Parameters: platform
, personaId
, displayName
, game
Request Route: /Loadout/GetPresets
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPS4 // also you can use XBOX or PC displayName: YOUR_DISPLAY_NAME bfLoadout
Loadout.getEquippedDogtags
Parameters: platform
, personaId
, displayName
, game
Request Route: /Loadout/GetEquippedDogtags
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPS4 // also you can use XBOX or PC displayName: YOUR_DISPLAY_NAME bfLoadout
Server
Server.quickServerInfo
Parameters: platform
, game
Request Route: /quick-server-info
Usage:
const bf = 'battlefield-stats'YOUR_API_KEY;const params = platform: bfPlatformsPS4 // also you can use XBOX or PS4 game: 'tunguska' // default is tunguska, can be changed to bf4bfServer