Battlefield 3 Stats JSON API
This API can be used by software engineers to integrate BF3 Stats into their software.
If you use this API, please set a link back to bf3stats.com like: Powered by bf3stats.com
We think commercial use of this API is not fair.
You can get further information and help in our Forum
Download our Graphics Pack (90MB) for all BF3 graphics we use.
Accessing the API
http://api.bf3stats.com/[Platform]/[DataGroup]/As
[DataGroup] you can use following:
- playerlist
- player
- dogtags
- server
- onlinestats
- playerupdate *(for registered apps)
- playerlookup *(for registered apps)
- setupkey *(for registered apps)
- getkey *(for registered apps)
I recommend to access this API via. cronjobs.
If your request was processed by the API, you get HTTP STATUS 200. If your request was not handled by our API you get HTTP STATUS 500.
You can use this PHP Example to begin.
DataGroups
-
outputdefines the output format. This isjsonby default. You can also choosejs,lines,sig
playerlist
URL:http://api.bf3stats.com/[Platform]/playerlist/[Platform] can be pc, 360 or ps3POST parameters:
-
players* is a required list of player names.
The list can be comma separated, or a JSON Array or a URI encoded array -
optis a list of [playerOutputOptions]
See below for a list of [playerOutputOptions].
Return parameters:
-
statuscan containokorerror -
erroris only returned ifstatusiserrorwith one of following error codes:
invalid_platform, no_players_given, no_valid_players, index_database_error, data_database_error, too_many_players, private -
listis the list of players data with index name equal your requested name. Every item hasstatuswith following codes:
pifoundonly the index data of the player was found
datacomplete data of the player was found
-
failedis a list of failed players with index name equal your requested name. An item has at leasterrorwith one of the following codes: invalid_name, notfound
player
URL:http://api.bf3stats.com/[Platform]/player/[Platform] can be pc, 360 or ps3POST parameters:
-
playername of a player -
optis a list of [playerOutputOptions]
See below for a list of [playerOutputOptions].
Return parameters:
-
statuscan containpifound,data,notfoundorerror
pifoundonly the index data of the player was found
datacomplete data of the player was found
-
erroris only returned ifstatusiserrorwith one of following error codes:
invalid_platform, invalid_name, private
dogtags
URL:http://api.bf3stats.com/[Platform]/dogtags/[Platform] can be pc, 360 or ps3POST parameters:
-
playername of a player
Return parameters:
-
statuscan containdogtags,pifound,notfoundorerror
dogtagsdogtags found successfully
pifoundonly the index data of the player was found
-
erroris only returned ifstatusiserrorwith one of following error codes:
invalid_platform, invalid_name, private
server
URL:http://api.bf3stats.com/[Platform]/server/[Platform] can be pc, 360 or ps3POST parameters:
-
id36 chars length id code of the serverhistoryset to 1 to receive history data
Return parameters:
-
statuscan containfound,notfoundorerror
-
erroris only returned ifstatusiserrorwith one of following error codes:
invalid_platform, invalid_id
onlinestats
URL:http://api.bf3stats.com/[Platform]/onlinestats/[Platform] must be globalPOST parameters:
noneReturn parameters:
-
statuscan containok,nodataorerror
okonline data is available
nodatadata is not available
-
erroris only returned ifstatusiserrorwith one of following error codes:
invalid_platform -
pccount of online players on PC -
360count of online players on 360 -
ps3count of online players on PS3
playerupdate *(for registered apps)
URL:http://api.bf3stats.com/[Platform]/playerupdate/[Platform] can be pc, 360 or ps3playerupdate is a signed request.
Use this request to update a player. This means we request the current data from EA for this player.
If the player was not in our database, we do automatically a lookup and add the player.
signed request parameters:
-
timetimestamp in seconds -
identUnique ident of your app -
playername of a player
Return parameters:
-
statuscan containerror,added,notfound,pifound,nobackend,timedout,noplatform,noname,nopid,noworker,exists,full,task,notask
-
erroris only returned ifstatusiserrorand can containinvalid_platform,invalid_time,invalid_name,over_update_limit,no_update_right,noresponse,invalid_request,invalid_ident,ident_not_found,ident_locked,signature_wrong,invalid_json_data
-
posif thestatusisaddedorexiststhis is the queue position. If the update is in progress or finished,poswill be negative.
-
taskis only returned ifstatusisadded,taskorexists
task.statecan containqueued,started,finishedtask.resultcan contain after task.state is finished:notfound,found
Limiting
This request is limited for your app key.Only requests which result in status=added are counted towards your update limit.
The limit is counted per hour. The counter gets reseted 60 minutes after your first request.
How playerupdate can be used
If you requested a player from DataGroupplayer or playerlist and the stats are too old you can call playerupdate.
If you get status=added you can call playerupdate every 10 seconds to get the current status of your update. You can stop if task.state is finished. Then check task.result. If found, the update was successful.
playerlookup *(for registered apps)
URL:http://api.bf3stats.com/[Platform]/playerlookup/[Platform] can be pc, 360 or ps3playerlookup is a signed request.
Use this request to lookup a player. This means we request the current index data(playerid, name, country) from EA for this player.
You can use this to search a player if the player is not in our database. So use player datagroup first to look if the player is in our database.
On a lookup always follows automatically an update of the player. This means you don't need to use playerupdate after playerlookup.
signed request parameters:
-
timetimestamp in seconds -
identUnique ident of your app -
playername of a player
Return parameters:
-
statuscan containerror,added,notfound,pifound,nobackend,timedout,noplatform,noname,noworker,exists,full,task,notask
-
erroris only returned ifstatusiserrorand can containinvalid_platform,invalid_time,invalid_name,over_update_limit,no_update_right,noresponse,invalid_request,invalid_ident,ident_not_found,ident_locked,signature_wrong,invalid_json_data
-
posif thestatusisaddedorexiststhis is the queue position. If the lookup is in progress or finished,poswill be negative.
-
taskis only returned ifstatusisadded,taskorexists
task.statecan containqueued,started,finishedtask.resultcan contain after task.state is finished:notfound,found
Limiting
This request is limited for your app key.Only requests which result in status=added are counted towards your lookup limit.
The limit is counted per hour. The counter gets reseted 60 minutes after your first request.
How playerlookup can be used
If you requested a player from DataGroupplayer or playerlist and the stats are not found call playerlookup.
If you get status=added you can call playerlookup every 10 seconds to get the current status of your lookup. You can stop if task.state is finished. Then check task.result. If found, the lookup was successful.
setupkey *(for registered apps)
URL:http://api.bf3stats.com/[Platform]/setupkey/[Platform] must be globalsetupkey is a signed request.
If your app has the right to generate keys, you can do it with this request.
You should use this if a software runs at the users device like mobile apps, or desktop applications.
So you can generate an individual key for every installation. This is important, because you should never give your secret key out to another system.
signed request parameters:
-
timetimestamp in seconds -
identUnique ident of your app -
clientident*(optional) New unique ident to create. If not given, we define a random string for this. -
name*(optional) name for the new key. Get's displayed in your key overview just for information.
Return parameters:
-
statuscan containerror,ok
-
erroris only returned ifstatusiserrorand can containinvalid_platform,invalid_time,no_genkey_right,invalid_clientident,invalid_name,clientident_in_use,db_save_error,invalid_request,invalid_ident,ident_not_found,ident_locked,signature_wrong,invalid_json_data
identIdent of your new keyparentParent ident(your app ident) of your new keykeyYour new keynameName of your new keylockedIs the key locked, true or false. Will be always true for creation.canupdateHas right to update, true or falsecanlookupHas right to lookup, true or falseupdate_limitcount of allowed updates per hourlookup_limitcount of allowed lookups per hour
getkey *(for registered apps)
URL:http://api.bf3stats.com/[Platform]/getkey/[Platform] must be globalgetkey is a signed request.
This request can be used to get information about a existing client key or your own key.
signed request parameters:
-
timetimestamp in seconds -
identUnique ident of your app -
clientidentIdent to lookup
Return parameters:
-
statuscan containerror,ok
-
erroris only returned ifstatusiserrorand can containinvalid_platform,invalid_time,invalid_clientident,clientident_notfound,clientident_notallowed,invalid_request,invalid_ident,ident_not_found,ident_locked,signature_wrong,invalid_json_data
identIdent of your keyparentParent ident(your app ident) of your keykeyYour keynameName of your keylockedIs the key locked, true or false.canupdateHas right to update, true or falsecanlookupHas right to lookup, true or falseupdate_limitcount of allowed updates per hourlookup_limitcount of allowed lookups per hourupdate_leftcount of allowed updates per hour leftlookup_leftcount of allowed lookups per hour left
playerOutputOptions
We have two different types of options: presets and every single option.
Presets
-
clearsets all options to false -
indexreturns only index data, all other options are ignored -
allis the default option with nextranks:true and imgInfo:true -
noinfosets all *Info options to false -
nounlockssets all *Unlocks options to false
Options
scoresdefault: trueglobaldefault: truenextranksdefault: falserankdefault: trueimgInfodefault: falselastseendefault: falseurlsdefault: falsekeysdefault: falserawdefault: falsenozerodefault: falsecoopdefault: truecoopInfodefault: truecoopMissionsdefault: truegamemodesdefault: truegamemodesInfodefault: trueweaponsdefault: trueweaponsNamedefault: trueweaponsInfodefault: trueweaponsOnlyUseddefault: falseweaponsUnlocksdefault: trueweaponsRankingdefault: true (only works if ranking:true)weaponsStarsdefault: trueequipmentdefault: trueequipmentNamedefault: trueequipmentInfodefault: trueequipmentRankingdefault: true (only works if ranking:true)equipmentOnlyUseddefault: falsespecializationsdefault: truespecializationsNamedefault: truespecializationsInfodefault: trueteamsdefault: truekitsdefault: truekitsNamedefault: truekitsInfodefault: truekitsStarsdefault: truekitsUnlocksdefault: truevehiclesdefault: truevehiclesNamedefault: truevehiclesInfodefault: truevehiclesRankingdefault: true (only works if ranking:true)vehiclesOnlyUseddefault: falsevehCatsdefault: truevehCatsStarsdefault: truevehCatsUnlocksdefault: truevehCatsGroupdefault: false (Groups both jet categories)vehCatsInfodefault: trueawardsdefault: trueawardsNamedefault: trueawardsInfodefault: trueawardsAwardeddefault: falserankingdefault: falserankingInfodefault: trueassignmentsdefault: falseassignmentsInfodefault: trueassignmentsNamedefault: true
Order how the options are executed
- Options default values
- presets
- options
Value of opt POST parameter
The value of the opt POST parameter can be a comma separated list or a JSON object.All options given in a comma separated list will be set to true.
Examples
- opt=clear,coop,imgInfo
- opt={"clear"%3Atrue%2C"coop"%3Atrue%2C"imgInfo"%3Atrue}
How to reduce traffic to a minimum
The optionskeys, raw, nozero help you to reduce the traffic per request to a minimum.You only need one big request which contains the big data structure. You should do that with the
player DataGroup.Example:
opt=all,keysAfter that you can request one
player or a playerlist with following opt:Example:
opt=clear,raw,nozeroNow you use the structure from the first request and replace all values which begin with
stats. or coop. with the right values from the stats or coop object from the second request.For stars and medals you also need to calc the
needed value again with needed+count*needed
signed request
A signed request is a POST request with two POST parameters data and sig.
Basicly you need to generate a signature with the data and your secret key.
To get your secret key, you need to register your app
POST parameters
datais a base64url encoded JSON object of signed request parameterssigis a base64url encoded SHA256 hmac signature ofdataand your secret key
Example
This PHP Example shows you all 4 types of signed requests you can do.Note: The timestamp you give us with signed request parameters should not have more than 1 minute difference to current time. So the time on your server should be correct.
