BF4 Stats API

The BF4 Stats API provides several endpoints to query the BF4Stats.com database from different applications.

The API is not finished yet. There is more to come.

The API can be queried per HTTP GET or POST. All parameters are supported as URL Query parameters or POST parameters. If same parameter is given on both ways, POST is preferred.
If the request header Accept-Encoding contains gzip, it returns a compressed response.

POST data can be encoded as application/x-www-form-urlencoded or application/json

We support cross domain requests. The response headers Access-Control-Allow-Origin, Access-Control-Allow-Headers and Access-Control-Allow-Methods are configured to allow requests from anywhere. So the API can be queried via. AJAX.

Platforms

Most endpoints take a plat parameter to specifiy the game platform. The following platform codes are available:

pc
PC platform
xbox
XBOX 360 console platform
ps3
Playstation 3 console platform
xone
XBOX ONE console platform.
ps4
Playstation 4 console platform.

Graphics

The API returns image paths for several items. In bf4stats.com_images.zip you find all those images. Most images are from Battlelog.

General parameters

The following parameters can be used as URL query parameters or POST parameters.

output

Sets the output format. Default is json

json
Returns all data in JSON format which is usually supported in all programming and script languages.
jsonp
Returns a javascript function call which provides all data. Requires the additional callback parameter to be set as the function name to be called.
js
Returns all data as javascript variable pd. Usually just used for debugging and better human readability.
lines
Returns one value per line in parameter format.

Endpoint: playerInfo

http://api.bf4stats.com/api/playerInfo

Returns data about a player.

Parameters

plat
Platform identifier
name
Player name
opt
[optional] Options as comma separated list. See Player data output options

Errors

nameInvalid
Name parameter is missing or contains invalid characters
nameLong
Given name is too long
nameShort
Given name is too short
notFound
Player was not found
notPublic
Player is not public and can't be seen by API clients

Example

http://api.bf4stats.com/api/playerInfo?plat=pc&name=1ApRiL&output=js

Endpoint: playerRankings

http://api.bf4stats.com/api/playerRankings

Returns a list of all rankings for the given player.

Parameters

plat
Platform identifier
name
Player name

Errors

nameInvalid
Name parameter is missing or contains invalid characters
nameLong
Given name is too long
nameShort
Given name is too short
notFound
Player was not found
notPublic
Player is not public and can't be seen by API clients

Example

http://api.bf4stats.com/api/playerRankings?plat=pc&name=1ApRiL&output=js

Errors

The HTTP Status code should always be checked. Only 200 means the request was successful and contains a valid response. If you provided one of the request headers If-Modified-Since or If-None-Match you could get a 304 back which means also success but nothing changed.

All errors are returned with a HTTP Status code above 400 or above 500. If you receive such a status code, always check for the Content-Type header, because in some cases you won't get the desired output format.

Common errors

unknownOutput
The value on your given output parameter is not known.
unknownEndpoint
The URL you called contains an endpoint name which is not supported.
unknownPlat
The given plat parameter contains an unknown platform.
generalError
An undefined error. The message field should contain further information. This could appear on database failures.

Player data output options

With the playerInfo endpoint you can supply the opt parameter. If the opt parameter is supplied, it must have a comma separated list of option identifiers. Otherwise it is assumed that no options are set. If the opt parameter is not set, it is assumed that all options are set.

Option identifiers

imagePaths
Includes paths for images
details
Includes further details
names
Includes names
progress
Includes progress information
extra
Includes additional calculations
stats
Includes detailed stats
weapons
Includes weapons
weaponUnlocks
Includes weapon unlocks
weaponCategory
Includes weapon categories
vehicles
Includes vehicles
vehicleCategory
Includes vehicle categories
vehicleUnlocks
Includes vehicle unlocks
kititems
Includes gadgets
awards
Includes medals and ribbons
dogtags
Includes dogtags information
assignments
Includes assignments
upcomingUnlocks
Includes list of upcoming unlocks
urls
Includes urls to player profiles
P-STATS NETWORK FORUM LOGIN CREATE ACCOUNT