FANDOM



Overview Edit

The Trade History API provides information about the global trade history, requires an API key to operate.

Access URL Edit

baseurl/trade-history/key={api key}

This API cannot function without an API key being passed through it, it can be found at the bottom of the account page on the website.

Accepted Parameter(s) Edit

By default, it shows you the 1000 most recent trades for all resources, unless you pass the other accepted parameters to change the returned JSON.

The two parameters are:

  • resources = the name of the resource you wish to filter for
  • records = how many trades would you like to request

Resources Edit

The list of acceptable resources can be find on the Resources page, including credits. The names also have to be lowercase and are caps sensitive, so if a resource name isnt working double check if its both correct and is all lowercase.

accessurl&resources={resource name}

You can also filter for multiple resources at once:

accessurl&resources={resource name},{resource name},{resource name}

Unless this is passed then it will return the last 1000 trades for all resources, or however many records you requested for.

Records Edit

accessurl&records={int}

Unless this is passed it will default to 1000. The minimum you can request for is 1 and the max being 10000.

Using both parameters Edit

The order in which you pass the optional parameters does not matter but so both examples below are acceptable.

accessurl&resources={resource name}&records={int}

OR

accessurl&records={int}&resources={resource name}

Returned JSON Edit

Below is the JSON for the request of:

accessurl&resources=credits&records=2
{
    'success': True, 
    'trades': [
        {
                'trade_id': '4440588', 
                'date': '2018-12-17 15:29:12', 
                'offerer_nation_id': '141789', 
                'accepter_nation_id': '53361', 
                'resource': 'credits', 
                'offer_type': 'sell', 
                'quantity': '1', 
                'price': '12999999'
        }, 
        {'trade_id': '4440300', 'date': '2018-12-17 13:34:58', 'offerer_nation_id': '141789', 'accepter_nation_id': '115796', 'resource': 'credits', 'offer_type': 'sell', 'quantity': '1', 'price': '1299999'}
    ]
}

Error JSON Edit

Incorrect resource type:

{
        'success': False, 
        'general_message': 'No valid resource parameters were sent.'
}

Out of bounds records count:

{
        'success': False, 
        'general_message': 'Request is limited to 10,000 records maximum.'
}
Community content is available under CC-BY-SA unless otherwise noted.