NAV
bash php ruby python javascript

Introduction

Welcome to the CommoPrices API Documentation v1.0!

You can use our API to access CommoPrices API endpoints, which can get information on prices of more than 1,600 commodities in our database.

Before starting

If you do not know what we do, please visit :

We are providing (for the API) price series coming from two different sources :

Want to use our widget ?

Sign Up to get all the instructions in your dashboard and start using it anywhere : website, intranet, etc.

Want to test requests ?

We recommend the use of the awesome Postman which will allow you to simulate a HTTP request. You will then be able to generate code for your own programming language (click on “Generate Code” in the app to do so).

Authentication

To authorize, use this code:

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "api_endpoint_here",
  "method": "GET",
  "headers": {
    "authorization": "Bearer myApiToken",
    "accept": "application/json"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
import http.client

conn = http.client.HTTPConnection("https://api.commoprices.com")

headers = {
    'authorization': "Bearer myApiToken",
    'accept': "application/json"
    }

conn.request("GET", "end_point_without_domain_name", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("api_endpoint_here")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer myApiToken'
request["accept"] = 'application/json'

response = http.request(request)
puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "api_endpoint_here",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Bearer myApiToken"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
curl "api_endpoint_here"
  -H "Authorization: Bearer myApiToken"
  -H "Accept: application/json"

Make sure to replace myApiToken with your API key.

CommoPrices uses API token to allow access to the API. You can register a new CommoPrices API token by registering.

CommoPrices expects for the API key to be included in all API requests to the server in a header that looks like the following:

Authorization: Bearer myApiToken

Commodity Prices (regular)

CommoPrices provides prices from different databases.

“Regular” means that all thoses databases render JSON with the same structure.

Those databases have different endpoints :

database endpoint availability
IMF /v1/imf open
COM /v1/com premium
COP /v1/cop premium
CRP /v1/crp premium
FAG /v1/fag premium
INP /v1/inp premium
SOE /v1/soe premium
ALY* /v1/aly premium

INFO on all commodities

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.commoprices.com/v1/imf",
  "method": "GET",
  "headers": {
    "authorization": "Bearer myApiToken",
    "accept": "application/json"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
import http.client

conn = http.client.HTTPConnection("https://api.commoprices.com")

headers = {
    'authorization': "Bearer myApiToken",
    'accept': "application/json"
    }

conn.request("GET", "/v1/imf", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.commoprices.com/v1/imf")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer myApiToken'
request["accept"] = 'application/json'

response = http.request(request)
puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.commoprices.com/v1/imf",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Bearer myApiToken"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
curl "https://api.commoprices.com/v1/imf"
  -H "Authorization: Bearer myApiToken"
  -H "Accept: application/json"

The above command returns JSON structured like this:


{
  "status": "success",
  "data": [
    {
      "database": "imf",
      "code": "PALUM",
      "name": "Aluminum, 99.5% minimum purity, spot, CIF UK ports",
      "original_currency": {
        "name": "US Dollar",
        "code": "USD",
        "symbol": "$",
        "prefix": null,
        "base_code": "USD"
      },
      "original_unit": {
        "name": "metric ton",
        "abbr": "mt",
        "prefix": null,
        "suffix": null,
        "base_abbr": "mt"
      },
      "original_price_unit": {
        "name": "US Dollar per metric ton",
        "abbr": "$ / mt"
      },
      "source": "LME via IMF",
      "oldest_available_date": "2012-01-01",
      "frequency": "M",
      "spec": null
    },
    {
      "database": "imf",
      "code": "PBANSOP",
      "name": "Bananas, Central American and Ecuador, FOB U.S. Ports",
      "original_currency": {
        "name": "US Dollar",
        "code": "USD",
        "symbol": "$",
        "prefix": null,
        "base_code": "USD"
      },
      "original_unit": {
        "name": "metric ton",
        "abbr": "mt",
        "prefix": null,
        "suffix": null,
        "base_abbr": "mt"
      },
      "original_price_unit": {
        "name": "US Dollar per metric ton",
        "abbr": "$ / mt"
      },
      "source": "IMF",
      "oldest_available_date": "2012-01-01",
      "frequency": "M",
      "spec": null
    }
  ]
}

IMF database will be used in right panel as an example.

This endpoint retrieves the information concerning the database (listed above).

HTTP Request

GET https://api.commoprices.com/v1/<database>

URL Parameters

Parameter Description
database The code of the database to retrieve.
imf / com / cop / crp / fag / inp / soe / aly

Query Parameters

Parameter Default Description
lang en Define the language of the response.
Use : ‘fr’ (french) and ‘en’ (english) are available at the moment.

INFO on a specific commodity

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.commoprices.com/v1/imf/PALUM",
  "method": "GET",
  "headers": {
    "authorization": "Bearer myApiToken",
    "accept": "application/json"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
import http.client

conn = http.client.HTTPConnection("https://api.commoprices.com")

headers = {
    'authorization': "Bearer myApiToken",
    'accept': "application/json"
    }

conn.request("GET", "/v1/imf/PALUM", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.commoprices.com/v1/imf/PALUM")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer myApiToken'
request["accept"] = 'application/json'

response = http.request(request)
puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.commoprices.com/v1/imf/PALUM",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Bearer myApiToken"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
curl "https://api.commoprices.com/v1/imf/PALUM"
  -H "Authorization: Bearer myApiToken"
  -H "Accept: application/json"

The above command returns JSON structured like this:

{
  "status": "success",
  "data": {
    "database": "imf",
    "code": "PALUM",
    "name": "Aluminum, 99.5% minimum purity, spot, CIF UK ports",
    "original_currency": {
      "name": "US Dollar",
      "code": "USD",
      "symbol": "$",
      "prefix": null,
      "base_code": "USD"
    },
    "original_unit": {
      "name": "metric ton",
      "abbr": "mt",
      "prefix": null,
      "suffix": null,
      "base_abbr": "mt"
    },
    "original_price_unit": {
      "name": "US Dollar per metric ton",
      "abbr": "$ / mt"
    },
    "source": "LME via IMF",
    "oldest_available_date": "2012-01-01",
    "frequency": "M",
    "spec": null
  }
}

IMF database will be used in the right panel as an example.

This endpoint retrieves the information concerning a single commodity.

HTTP Request

GET https://api.commoprices.com/v1/<database>/<code>

URL Parameters

Parameter Description
database The code of the database to retrieve.
imf / com / cop / crp / fag / inp / soe / aly
code The code of the commodity to retrieve

Query Parameters

Parameter Default Description
lang en Define the language of the response.
Use :’fr’ (french) and ‘en’ (english) are available at the moment.

PRICES for a specific commodity

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.commoprices.com/v1/imf/PALUM/data",
  "method": "GET",
  "headers": {
    "authorization": "Bearer myApiToken",
    "accept": "application/json"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
import http.client

conn = http.client.HTTPConnection("https://api.commoprices.com")

headers = {
    'authorization': "Bearer myApiToken",
    'accept': "application/json"
    }

conn.request("GET", "/v1/imf/PALUM/data", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.commoprices.com/v1/imf/PALUM/data")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer myApiToken'
request["accept"] = 'application/json'

response = http.request(request)
puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.commoprices.com/v1/imf/PALUM/data",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Bearer myApiToken"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
curl "https://api.commoprices.com/v1/imf/PALUM/data"
  -H "Authorization: Bearer myApiToken"
  -H "Accept: application/json"

The above command returns JSON structured like this:

{
  "status": "success",
  "data": {
    "info": {
      "database": "imf",
      "code": "PALUM",
      "name": "Aluminum, 99.5% minimum purity, spot, CIF UK ports",
      "original_currency": {
        "name": "US Dollar",
        "code": "USD",
        "symbol": "$",
        "prefix": null,
        "base_code": "USD"
      },
      "original_unit": {
        "name": "metric ton",
        "abbr": "mt",
        "prefix": null,
        "suffix": null,
        "base_abbr": "mt"
      },
      "original_price_unit": {
        "name": "US Dollar per metric ton",
        "abbr": "$ / mt"
      },
      "source": "LME via IMF",
      "oldest_available_date": "2012-01-01",
      "frequency": "M",
      "spec": null
    },
    "request": {
      "start_date": "2012-01-01",
      "order": "asc",
      "frequency": "M",
      "currency": {
        "name": "US Dollar",
        "code": "USD",
        "symbol": "$",
        "prefix": null,
        "base_code": "USD"
      },
      "unit": {
        "name": "metric ton",
        "abbr": "mt",
        "prefix": null,
        "suffix": null,
        "base_abbr": "mt"
      },
      "price_unit": {
        "name": "US Dollar per metric ton",
        "abbr": "$ / mt"
      },
      "column_names": [
        "date",
        "price"
      ],
      "dataseries": [
        [
          "2012-01-31",
          2151
        ],
        [
          "2012-02-29",
          2208
        ],
        [
          "YYYY-MM-DD",
          XXXX
        ],
        [
          "2016-01-31",
          1481
        ],
        [
          "2016-02-29",
          1531
        ],
        [
          "2016-03-31",
          1531
        ]
      ]
    }
  }
}

IMF database will be used in right panel as an example.

This endpoint retrieves the prices of a single commodity of the database.

HTTP Request

GET https://api.commoprices.com/v1/<database>/<code>/data

URL Parameters

Parameter Description
database The code of the database to retrieve.
imf / com / cop / crp / fag / inp / soe / aly
code The code of the commodity to retrieve

Query Parameters

Parameter Default Description
lang en Define the language of the response.
use : ‘fr’ (french) and ‘en’ (english) are available at the moment.
currency original_currency Define the currency of the response.
use : ‘EUR’, ‘USD’, ‘AUD’, ‘BGN’, ‘BRL’, ‘CAD’, ‘CHF’, ‘CNY’, ‘CZK’, ‘DKK’, ‘GBP’, ‘HKD’, ‘HRK’, ‘HUF’, ‘IDR’, ‘ILS’, ‘INR’, ‘JPY’, ‘KRW’, ‘MXN’, ‘MYR’, ‘NOK’, ‘NZD’, ‘PHP’, ‘PLN’, ‘RON’, ‘RUB’, ‘SEK’, ‘SGD’, ‘THB’, ‘TRY’, ‘ZAR’ are available at the moment.
start_date oldest_available_date Define the starting date of the response.
use : ‘YYYY-MM-DD’

Indexes

CommoPrices provides indexes from different databases.

Those databases have different endpoints :

database endpoint availability
INI /v1/ini premium
CRI /v1/cri premium
LLO /v1/llo premium

INFO on all indexes

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.commoprices.com/v1/llo",
  "method": "GET",
  "headers": {
    "authorization": "Bearer myApiToken",
    "accept": "application/json"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
import http.client

conn = http.client.HTTPConnection("https://api.commoprices.com")

headers = {
    'authorization': "Bearer myApiToken",
    'accept': "application/json"
    }

conn.request("GET", "/v1/llo", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.commoprices.com/v1/llo")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer myApiToken'
request["accept"] = 'application/json'

response = http.request(request)
puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.commoprices.com/v1/llo",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Bearer myApiToken"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
curl "https://api.commoprices.com/v1/llo"
  -H "Authorization: Bearer myApiToken"
  -H "Accept: application/json"

The above command returns JSON structured like this:


{
  "status": "success",
  "data": [
    {
      "database": "llo",
      "code": "LLO-BDI",
      "name": "Baltic Dry Index | World ",
      "index": {
        "base": null,
        "date_reference": null
      },
      "source": "Lloyds' List",
      "oldest_available_date": "2009-03-16",
      "frequency": "D",
      "spec": null
    },
    {
      "database": "llo",
      "code": "LLO-BCI",
      "name": "Baltic Capesize Index | ",
      "index": {
        "base": null,
        "date_reference": null
      },
      "source": "Lloyds' List",
      "oldest_available_date": "2009-03-16",
      "frequency": "D",
      "spec": null
    },
  ]
}

LLO database will be used in right panel as an example.

This endpoint retrieves the information concerning the database (listed above).

HTTP Request

GET https://api.commoprices.com/v1/<database>

URL Parameters

Parameter Description
database The code of the database to retrieve.
llo / ini / cri

Query Parameters

Parameter Default Description
lang en Define the language of the response.
Use : ‘fr’ (french) and ‘en’ (english) are available at the moment.

INFO on a specific index

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.commoprices.com/v1/llo/LLO-BDI",
  "method": "GET",
  "headers": {
    "authorization": "Bearer myApiToken",
    "accept": "application/json"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
import http.client

conn = http.client.HTTPConnection("https://api.commoprices.com")

headers = {
    'authorization': "Bearer myApiToken",
    'accept': "application/json"
    }

conn.request("GET", "/v1/llo/LLO-BDI", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.commoprices.com/v1/llo/LLO-BDI")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer myApiToken'
request["accept"] = 'application/json'

response = http.request(request)
puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.commoprices.com/v1/llo/LLO-BDI",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Bearer myApiToken"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
curl "https://api.commoprices.com/v1/llo/LLO-BDI"
  -H "Authorization: Bearer myApiToken"
  -H "Accept: application/json"

The above command returns JSON structured like this:

{
  "status": "success",
  "data": {
    "info": {
      "database": "llo",
      "code": "LLO-BDI",
      "name": "Baltic Dry Index | World ",
      "index": {
        "base": null,
        "date_reference": null
      },
      "source": "Lloyds' List",
      "oldest_available_date": "2009-03-16",
      "frequency": "D",
      "spec": null
    }
  }
}

LLO database will be used in the right panel as an example.

This endpoint retrieves the information concerning a single index.

HTTP Request

GET https://api.commoprices.com/v1/<database>/<code>

URL Parameters

Parameter Description
database The code of the database to retrieve.
llo / ini / cri
code The code of the index to retrieve

Query Parameters

Parameter Default Description
lang en Define the language of the response.
Use :’fr’ (french) and ‘en’ (english) are available at the moment.

VALUES for a specific index

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.commoprices.com/v1/llo/LLO-BDI/data",
  "method": "GET",
  "headers": {
    "authorization": "Bearer myApiToken",
    "accept": "application/json"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
import http.client

conn = http.client.HTTPConnection("https://api.commoprices.com")

headers = {
    'authorization': "Bearer myApiToken",
    'accept': "application/json"
    }

conn.request("GET", "/v1/llo/LLO-BDI/data", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.commoprices.com/v1/llo/LLO-BDI/data")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer myApiToken'
request["accept"] = 'application/json'

response = http.request(request)
puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.commoprices.com/v1/llo/LLO-BDI/data",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Bearer myApiToken"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
curl "https://api.commoprices.com/v1/llo/LLO-BDI/data"
  -H "Authorization: Bearer myApiToken"
  -H "Accept: application/json"

The above command returns JSON structured like this:

{
  "status": "success",
  "data": {
    "info": {
       "database": "llo",
       "code": "LLO-BDI",
       "name": "Baltic Dry Index | World ",
       "index": {
         "base": null,
         "date_reference": null
       },
       "source": "Lloyds' List",
       "oldest_available_date": "2009-03-16",
       "frequency": "D",
       "spec": null
    },
    "request": {
      "start_date": "2009-03-16",
      "order": "asc",
      "frequency": "D",
      "column_names": [
       "date",
       "index"
      ],
      "dataseries": [
        [
         "2009-03-16",
         2058
        ],
        [
         "2009-03-17",
         1974
        ],
        [
        "YYYY-MM-DD",
        XXXX
        ],
        [
          "2016-05-26",
          601
        ],
        [
          "2016-05-27",
          606
        ]
      ]
    }
  }
}

LLO database will be used in right panel as an example.

This endpoint retrieves the values of a single index of the database.

HTTP Request

GET https://api.commoprices.com/v1/<database>/<code>/data

URL Parameters

Parameter Description
database The code of the database to retrieve.
llo / ini / cri
code The code of the index to retrieve

Query Parameters

Parameter Default Description
lang en Define the language of the response.
use : ‘fr’ (french) and ‘en’ (english) are available at the moment.
start_date oldest_available_date Define the starting date of the response.
use : ‘YYYY-MM-DD’

Trade Data (FR)

CommoPrices provides more than 1,600 price series of trade data from France.

Those prices are only accessible for premium users.

Please contact us to learn more about our pricing

INFO on all commodities

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.commoprices.com/v1/tfr",
  "method": "GET",
  "headers": {
    "authorization": "Bearer myApiToken",
    "accept": "application/json"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
import http.client

conn = http.client.HTTPConnection("https://api.commoprices.com")

headers = {
    'authorization': "Bearer myApiToken",
    'accept': "application/json"
    }

conn.request("GET", "/v1/tfr", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.commoprices.com/v1/tfr")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer myApiToken'
request["accept"] = 'application/json'

response = http.request(request)
puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.commoprices.com/v1/tfr",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Bearer myApiToken"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
curl "https://api.commoprices.com/v1/tfr"
  -H "Authorization: Bearer myApiToken"
  -H "Accept: application/json"

The above command returns JSON structured like this:

{
  "status": "success",
  "data": [
    {
      "database": "tfr",
      "code": 18010000,
      "name": "Cocoa - beans or broken beans, raw or roasted",
      "original_currency": {
        "name": "Euro",
        "code": "EUR",
        "symbol": "€",
        "prefix": null,
        "base_code": "EUR"
      },
      "original_unit": {
        "name": "metric ton",
        "abbr": "mt",
        "prefix": null,
        "suffix": null,
        "base_abbr": "mt"
      },
      "original_price_unit": {
        "name": "Euro per metric ton",
        "abbr": "€ / mt"
      },
      "source": "Eurostat / CommoPrices [France]",
      "oldest_available_date": "2012-01-01",
      "frequency": "M",
      "spec": {
        "flows": {
          "available": [
            "import",
            "export"
          ],
          "default": "import"
        },
        "reference_country": "France"
      }
    },
    {
      "database": "tfr",
      "code": 9011100,
      "name": "Coffee - non-roasted, not decaffeinated",
      "original_currency": {
        "name": "Euro",
        "code": "EUR",
        "symbol": "€",
        "prefix": null,
        "base_code": "EUR"
      },
      "original_unit": {
        "name": "metric ton",
        "abbr": "mt",
        "prefix": null,
        "suffix": null,
        "base_abbr": "mt"
      },
      "original_price_unit": {
        "name": "Euro per metric ton",
        "abbr": "€ / mt"
      },
      "source": "Eurostat / CommoPrices [France]",
      "oldest_available_date": "2012-01-01",
      "frequency": "M",
      "spec": {
        "flows": {
          "available": [
            "import",
            "export"
          ],
          "default": "import"
        },
        "reference_country": "France"
      }
    }
  ]
}

This endpoint retrieves the information concerning all traded commodities.

HTTP Request

GET https://api.commoprices.com/v1/tfr

Query Parameters

Parameter Default Description
lang en Define the language of the response.
Use : ‘fr’ (french) and ‘en’ (english) are available at the moment.

INFO on a specific commodity

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.commoprices.com/v1/tfr/12074090",
  "method": "GET",
  "headers": {
    "authorization": "Bearer myApiToken",
    "accept": "application/json"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
import http.client

conn = http.client.HTTPConnection("https://api.commoprices.com")

headers = {
    'authorization': "Bearer myApiToken",
    'accept': "application/json"
    }

conn.request("GET", "/v1/tfr/12074090", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.commoprices.com/v1/tfr/12074090")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer myApiToken'
request["accept"] = 'application/json'

response = http.request(request)
puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.commoprices.com/v1/tfr/12074090",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Bearer myApiToken"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
curl "https://api.commoprices.com/v1/tfr/12074090"
  -H "Authorization: Bearer myApiToken"
  -H "Accept: application/json"

The above command returns JSON structured like this:

{
  "status": "success",
  "data": {
    "info": {
      "database": "tfr",
      "code": 12074090,
      "name": "Sesame - seeds, whether or not broken",
      "original_currency": {
        "name": "Euro",
        "code": "EUR",
        "symbol": "€",
        "prefix": null,
        "base_code": "EUR"
      },
      "original_unit": {
        "name": "metric ton",
        "abbr": "mt",
        "prefix": null,
        "suffix": null,
        "base_abbr": "mt"
      },
      "original_price_unit": {
        "name": "Euro per metric ton",
        "abbr": "€ / mt"
      },
      "source": "Eurostat / CommoPrices [France]",
      "oldest_available_date": "2012-01-01",
      "frequency": "M",
      "spec": {
        "flows": {
          "available": [
            "import",
            "export"
          ],
          "default": "import"
        },
        "reference_country": "France"
      }
    }
  }
}

This endpoint retrieves the information concerning a single traded commodity.

HTTP Request

GET https://api.commoprices.com/v1/tfr/<code>

URL Parameters

Parameter Description
code The code of the Customs commodity to retrieve

Query Parameters

Parameter Default Description
lang en Define the language of the response.
Use : ‘fr’ (french) and ‘en’ (english) are available at the moment.

PRICES for a specific commodity

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://api.commoprices.com/v1/tfr/12074090/data",
  "method": "GET",
  "headers": {
    "authorization": "Bearer myApiToken",
    "accept": "application/json"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
});
import http.client

conn = http.client.HTTPConnection("https://api.commoprices.com")

headers = {
    'authorization': "Bearer myApiToken",
    'accept': "application/json"
    }

conn.request("GET", "/v1/tfr/12074090/data", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.commoprices.com/v1/tfr/12074090/data")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Bearer myApiToken'
request["accept"] = 'application/json'

response = http.request(request)
puts response.read_body
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.commoprices.com/v1/tfr/12074090/data",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "authorization: Bearer myApiToken"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
curl "https://api.commoprices.com/v1/tfr/12074090/data"
  -H "Authorization: Bearer myApiToken"
  -H "Accept: application/json"

The above command returns JSON structured like this:

{
  "status": "success",
  "data": {
    "info": {
      "database": "tfr",
      "code": 12074090,
      "name": "Sesame - seeds, whether or not broken",
      "original_currency": {
        "name": "Euro",
        "code": "EUR",
        "symbol": "€",
        "prefix": null,
        "base_code": "EUR"
      },
      "original_unit": {
        "name": "metric ton",
        "abbr": "mt",
        "prefix": null,
        "suffix": null,
        "base_abbr": "mt"
      },
      "original_price_unit": {
        "name": "Euro per metric ton",
        "abbr": "€ / mt"
      },
      "source": "Eurostat / CommoPrices [France]",
      "oldest_available_date": "2012-01-01",
      "frequency": "M",
      "spec": {
        "flows": {
          "available": [
            "import",
            "export"
          ],
          "default": "import"
        },
        "reference_country": "France"
      }
    },
    "request": {
      "start_date": "2012-01-01",
      "order": "asc",
      "frequency": "M",
      "country": "Global",
      "currency": {
        "name": "Euro",
        "code": "EUR",
        "symbol": "€",
        "prefix": null,
        "base_code": "EUR"
      },
      "unit": {
        "name": "metric ton",
        "abbr": "mt",
        "prefix": null,
        "suffix": null,
        "base_abbr": "mt"
      },
      "price_unit": {
        "name": "Euro per metric ton",
        "abbr": "€ / mt"
      },
      "flow": "import",
      "major_countries": [
        "IN": "India",
        "ML": "Mali",
        "NL": "The Netherlands",
        "BE": "Belgium",
        "PY": "Paraguay",
        "GT": "Guatemala",
        "DE": "Germany",
        "ET": "Ethiopia",
        "GB": "United Kingdom"
      ],
      "column_names": [
        "date",
        "price",
        "volume"
      ],
      "dataseries": [
        [
          "2012-01-31",
          1404,
          615.1
        ],
        [
          "2012-02-29",
          1416,
          763.5
        ],
        [
          "YYYY-MM-DD",
          98765
          12345
        ],
        [
          "2016-02-29",
          1608,
          868.3
        ]
      ]
    }
  }
}

This endpoint retrieves the prices and volumes of a single traded commodity.

HTTP Request

GET https://api.commoprices.com/v1/tfr/<code>/data

URL Parameters

Parameter Description
code The code of the Customs commodity to retrieve

Query Parameters

Parameter Default Description
lang en Define the language of the response.
Use : ‘fr’ (french) and ‘en’ (english) are available at the moment.
flow default flow in info Define the flow of the trade data you want to analyze.
Use : ‘export’ or ‘import’ are available.
country Global Define the country of the trade data you want to analyze.
Use : 2-letters code of the major_countries.
Nota : By default, we are displaying “Global” which is a weighted average of the major countries.
currency original_currency Define the currency of the response.
use : ‘EUR’, ‘USD’, ‘AUD’, ‘BGN’, ‘BRL’, ‘CAD’, ‘CHF’, ‘CNY’, ‘CZK’, ‘DKK’, ‘GBP’, ‘HKD’, ‘HRK’, ‘HUF’, ‘IDR’, ‘ILS’, ‘INR’, ‘JPY’, ‘KRW’, ‘MXN’, ‘MYR’, ‘NOK’, ‘NZD’, ‘PHP’, ‘PLN’, ‘RON’, ‘RUB’, ‘SEK’, ‘SGD’, ‘THB’, ‘TRY’, ‘ZAR’ are available at the moment.
start_date oldest_available_date Define the starting date of the response.
use : ‘YYYY-MM-DD’

Errors

The CommoPrices API uses the following error codes:

curl "https://api.commoprices.com/v1/imf/POPUM"
  -H "Authorization: Bearer myApiToken"
  -H "Accept: application/json"

The above command returns JSON structured like this:

{
  "status": "error",
  "errors": {
    "message": "This commodity (POPUM) does not exist in IMF's database.",
    "status_code": 404,
    "documentation_url": "https://api.commoprices.com/docs#Errors",
    "email_support": "api@commoprices.com"
  }
}
Error Code Meaning
400 Bad Request – There was an error while processing the request payload (malformed JSON, for instance)
401 Unauthorized – The request is not authenticated, or invalid API key
403 Forbidden – The request is successfully authenticated (see 401), but the action requires a different type of key
404 Not Found – There is no resource behind the URI
429 Too Many Requests – You have sent too many requests in a given amount of time (“rate limiting”)
500 Internal Server Error – We had a problem with our server. Try again later.
503 Service Unavailable – We’re temporarily offline for maintenance. Please try again later.