JSON API
mohstats.com offers an API for fetching all MOH Stats data from our database.
This API can be used by software engineers to integrate MOH Stats into their software.
If you use this API, please set a link back to mohstats.com like: Powered by mohstats.com
Commercial use is not permitted.
This API can be used by software engineers to integrate MOH Stats into their software.
If you use this API, please set a link back to mohstats.com like: Powered by mohstats.com
Commercial use is not permitted.
Accessing the API
You can access the API via. HTTP GET or POST over following URL:
As
You are limited to a maximum of 30 requests per minute.
So please cache the data on your side and don't call this API on every hit on your website.
I recommend to access this API via. cronjobs. Sometimes this API can return a HTTP Status 500, this is when it's overloaded.
http://api.mohstats.com/api/[Platform]As
[Platform] you can use following:
- pc
- ps3
- 360
You are limited to a maximum of 30 requests per minute.
So please cache the data on your side and don't call this API on every hit on your website.
I recommend to access this API via. cronjobs. Sometimes this API can return a HTTP Status 500, this is when it's overloaded.
Get MOH stats of players
URL:
Maxiumum player limit is 100
Following fields for
The returned data looks like this:
You see this if
If players you requested are not in our database, they will be looked up automatically. You will find the reesult in the
http://api.mohstats.com/api/[Platform]?players=[PlayerList]&fields=[FieldList][PlayerList]is a comma separated list of player names e.g. 1ApRiL,The first Animal[FieldList]is a comma separated list of data fields e.g. general,teams,gamemodes
http://api.mohstats.com/api/pc?players=1ApRiL,The%20first%20Animal,Phil,Tim&fields=general,teams,gamemodesMaxiumum player limit is 100
Following fields for
[FieldList] are available:
- all - is an alias for all fields
- basic - only basic data
- general - general stats
- rankings - ranking positions
- kits - kit stats
- teams - team stats
- gamemodes - gamemode stats
- medals - medal stats
- ribbons - ribbon stats
- achievements - achievement stats
- weapons - weapon stats
- descs - descriptions
- imgs - image paths
The returned data looks like this:
{
"players":
[
{
"name":"1ApRiL",
"platform":"pc",
"date_insert":1287519761,
......
},
{
"name":"The first Animal",
"platform":"pc",
"date_insert":1288874640,
......
}
],
"players_lookup":
[
{
"name":"Phil",
"state":"notfound"
},
{
"name":"Tim",
"state":"lookup",
"queue_pos":1,
"queue_count":3
}
],
"requested":4,
"found":2
}
Updating of the player
If the last check of a player is older than 6 hours, the API will automatically try to insert the requested player into the update queue.You see this if
queue_pos for an player is greater than 0.If players you requested are not in our database, they will be looked up automatically. You will find the reesult in the
players_lookup array at your next request.
PHP Example
<?php $url = 'http://api.mohstats.com/api/pc'; $postdata = 'players=1ApRiL,The%20first%20Animal,Phil,Tim&fields=general,teams,gamemodes'; $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); ?>
Search players
URL:
http://api.mohstats.com/api/[Platform]?search=[Playername][Playername]is a soldier name or part of a soldier name
http://api.mohstats.com/api/pc?search=1ApRGlobal stats
You can get global stats, like how many players are in our database and the currently online player stats.
URL:
This call is platform independent, so it doesn't matter what platform you choose.
URL:
http://api.mohstats.com/api/pc?globalstatsThis call is platform independent, so it doesn't matter what platform you choose.
Developer view
If you want to see the structure of the returned data in nice style, append
&dev=1