The OECD provides programmatic access to OECD data through an application programming interface (API) based on the SDMX standard.
These APIs are free of charge and are offered subject to your acceptance of OECD Terms and Conditions.
Retrieving content via the API query builder
Select the data you need in the OECD Data Explorer, click on the Developer API icon located above the data table. This will display the API queries for both the Data and its Structure.
To use them, simply click Copy code and include the syntax in your API calls.
The Data query retrieves the dataset's actual data, while the Structure query provides descriptive details, such as the dataset's dimensions and attributes, also known as structural metadata.
Syntax of the API data query
The API data query is a URL composed by the following elements:
{Host URL}/{Agency identifier},{Dataset identifier},{Dataset version}/{Data selection}?{other optional parameters}
The elements composing the API data query
Required parameters:
Parameter name | Use |
---|---|
Host URL | Fixed part of the request related to the host site |
Agency identifier | The identifier of the agency owning the dataset to be queried. |
Dataset identifier | The identifier of the dataset to be queried. |
Optional parameters:
Parameter name | Use |
---|---|
Dataset version | The version of the structural definition of the dataset to be queried. If left empty, the currently latest dataset version is used. While this often allows getting newer data, be aware that new dataflow versions may contain non-backward compatible structural changes (e.g. added/removed/renamed dimensions). |
Data selection | Using their identifiers, the list of desired dimension values to be included in the response. They are separated by a dot (“.”) and for each dimension values are be separated by the plus sign (“+”). If for a particular dimension, no dimension value identifiers are specified, then all available values of this dimension will be returned. To get unfiltered content, use the “all” keyword. Examples:
To obtain the list of dimensions and dimension values, use a structure query as explained below. The Time period parameter is not included here. |
Time period parameters | startPeriod The start time period, for which results should be supplied (inclusive). If not specified data are returned from the first available time period. endPeriod The end time period for which results should be supplied (inclusive). If not specified, data is returned until the last currently available time period. For both parameters the value can be expressed using dateTime, Gregorian time periods or SDMX reporting periods. Examples: (‘2015’, ‘2015-A1’, ‘2015-S1’, ‘2015-Q1’, ‘2015-M01’, ‘2015-01’, ‘2015-01-01’, ‘2015-01-01T00:00:00’) |
Refer to the comprehensive API documentation for details on additional optional parameters
Syntax of the API structure query
{Host URL}/{Agency identifier},{Dataset identifier},{Dataset version}?Data structure parameters
To obtain the full list of datasets, use the following syntax:
Data access with R and Python
R Example: Download CSV Data from API
This example shows how to download and read a CSV file as a DataFrame in R, including labels and Series IDs, directly from an API.
url = "https://sdmx.oecd.org/public/rest/data/OECD.SDD.STES,DSD_STES@DF_CLI/.M.LI...AA...H?startPeriod=2023-02&dimensionAtObservation=AllDimensions&format=csvfilewithlabels" df<-read.csv(url)
Python Example: Download CSV Data from API
This example shows how to download and read a CSV file as a DataFrame in Python, including labels and Series IDs, directly from an API.
import pandas as pd
url = 'https://sdmx.oecd.org/public/rest/data/OECD.SDD.STES,DSD_STES@DF_CLI/.M.LI...AA...H?startPeriod=2023-02&dimensionAtObservation=AllDimensions&format=csvfilewithlabels' df = pd.read_csv(url)
Response formats: XML, JSON or CSV
XML
To download data in XML format, add format=genericdata to your API call:
https://sdmx.oecd.org/public/rest/data/OECD.SDD.NAD,DSD_NAAG@DF_NAAG_I?format=genericdata
JSON
To download data in Json format, add format=jsondata to your API call:
https://sdmx.oecd.org/public/rest/data/OECD.SDD.NAD,DSD_NAAG@DF_NAAG_I?dimensionAtObservation=AllDimensions&format=jsondata
CSV
To download data in CSV format, add format=csvfile to your API call. If you would like to include both labels and identifier codes in the download, use format=csvfilewithlabels instead:
https://sdmx.oecd.org/public/rest/data/OECD.SDD.NAD,DSD_NAAG@DF_NAAG_I?format=csvfile