Fetching Data

Anatomy of a Request

To learn how the data endpoint works, let's break down the anatomy of an example API request. In this case we're looking at the products exported by Spain in 2023:
https://api-v2.oec.world/tesseract/data.jsonrecords?cube=trade_i_baci_a_22&drilldowns=HS4,Exporter+Country,Importer+Country,Year&measures=Trade+Value&include=Exporter+Country:euesp;Year:2023&limit=100,0&token=6b540954e368f971

1. Root URL

https://api-v2.oec.world/tesseract/data.jsonrecords
This is the root URL for the API. It will be the same for all requests. This will return a JSON object with a list of records. If you prefer a different format, you can change the extension to .csv, .xlsx, or .parquet.

2. Cube (or dataset)

?cube=trade_i_baci_a_22
This is the dataset you want to query. You can find the list of all available datasets by querying the cubes endpoint.

3. Drilldowns

&drilldowns=HS4,Exporter+Country,Importer+Country,Year
This is the drilldown you want to add to your query. Drilldowns represent the columns (or dimensions) that you want to see in the response. You can find the list of all available drilldowns for this specific cube (or dataset) by querying the trade_i_baci_a_22 cube endpoint.

4. Measures

&measures=Trade+Value
This is the measure you want to add to your query. Measures represent the columns (or metrics) that you want to see in the response. You can find the list of all available measures for this specific cube (or dataset) by querying the trade_i_baci_a_22 cube endpoint. It is important to note that measures will automatically be aggregated by the cube's default aggregation function.

5. Include (or filter)

&include=Exporter+Country:euesp;Year:2023
These are the filters you want to add to your query. Any column (or dimensions) availble to the specified cube can be used to filter the response. Multiple filters can be added by separating them with a semicolon. Filters take 2 parameters: the column name and the value you want to filter by. To find the available values for a specific column, you can query the members endpoint for that cube along with the level parameter. For example, to find the available values for the Exporter Country column, you can query the 'Exporter Country' members endpoint for the trade_i_baci_a_22 cube.

6. Limit and Offset

&limit=100,0
This is the limit you want to add to your query where the first number is the limit and the second number is the offset. It is used to limit the number of records returned in the response.

7. Token

&token=6b540954e368f971
This is the token you want to add to your query. It is used to authenticate your request. You can find your token by signing in and clicking the Account link in the top right corner of the page.
Have questions, comments, or concerns?
Send us an e-mail: support@oec.world
Follow @OECtoday on
Created, Designed, and Developed by:
In collaboration with