JSON API
bfbcs.com offers an API for fetching all BFBC2 Stats data from our database.
This API can be used by software engineers to integrate BFBC2 Stats into their software.
If you use this API, please set a link back to bfbcs.com like: Powered by bfbcs.com
Commercial use is not permitted.
Accessing
You can access the API via. HTTP GET or POST over following URL:
http://api.bfbcs.com/api/[Platform]
Available Platforms
- pc
- ps3
- 360
Parameters for GET and POST
Following parmeters can appended to the URL for GET requests:
- players - array or comma separated list of players
- fields - array or comma separated list of field groups
http://api.bfbcs.com/api/pc?players=1ApRiL,ContraViZe&fields=general,onlineValues for fields parameter
- all - alias for: general,kits,teams,weapons,vehicles,gadgets,specializations,insiginias,pins,achievements
- general - some general data
- kits - data about kits
- teams - data about teams(attacker, defender)
- weapons
- vehicles
- gadgets
- specializations
- insiginias
- pins
- achievements
- dogtags
- grimg - get img key with path to image files
- basic - all other fields will be ignored, only basic info
- online - online status of player
- progress - get progress for rank, kits and stars
- misc - some other data not included in aboves data
- raw - all data in raw format
Return format
All data is returned in JSON format. » Learn more about JSON
If you are using PHP, you can use the php function json_decode to convert the returned data into an object or an array.
Data structure
{
"players":
[
{
"name":"1ApRiL",
"rank":13,
"rank_name":"STAFF SERGEANT I",
"veteran":4,
"score":195385,
"level":164,
"kills":821,
"deaths":736,
"time":49090.766,
"elo":118.936,
"form":1,
"date_lastupdate":"2010-03-21T02:02:49+01:00",
"count_updates":17,
"general":{},
......
},
......
],
"requested":2,
"found":0
}
PHP Example
<?php
$url = 'http://api.bfbcs.com/api/pc';
$postdata = 'players=1ApRiL,ContraViZe&fields=all';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$data = curl_exec($ch);
curl_close($ch);
$data = json_decode($data,true);
print_r($data);
?>
Player updating
All players you try to pull will be automatically added to the update queue and get their update.
This is limited to 3 hours since last update check.
Every player has a queue attribute containing the queue position or false if not in queue or limit conflicted.
The players_nodata array contains players of which we have no data in our database and gets updated soon.
The players_unknown array contains unknown players that get inserted into the search queue to find them.
Global Stats
You can get global stats by following URL:
http://api.bfbcs.com/api/pc?globalstats
Search players
You can search players using the search parameter:
Example: http://api.bfbcs.com/api/pc?search=1A