Useful tips
You can find the documentation provided by the SDMX Technical Working Group here.
The SDMX Statistical Working Group has published content-oriented guidelines for the SDMX 2.1 standard.
If the documentation does not contain the information you require, or if you have any general comments or feedback regarding our web service, please contact us.
The SDMX Connectors project provides a set of end-user plug-ins for popular data analysis tools (R, SAS, Excel, Matlab, Stata, Java, ), and can also be used to access the ECB web service. Beside this project there are also other different tools supporting the SDMX standard which can be found here.
All example queries can be executed using Python, R or command line tools such as curl or wget.
⚠️❗We do not provide any support on the tools mentioned below or any other tools.
Example using wget or curl with content negotiation
wget -O data.xml \ --header="Accept:application/vnd.sdmx.structurespecificdata+xml;version=2.1" \ https://data-api.ecb.europa.eu/service/data/EXR/M.NOK.EUR.SP00.A |
curl -k -o data.xml \ --header "Accept:application/vnd.sdmx.structurespecificdata+xml;version=2.1" \ https://data-api.ecb.europa.eu/service/data/EXR/M.NOK.EUR.SP00.A |
Content negotiation compressing the output using curl
curl -k -o compressed_data.gz --header "Accept-Encoding: gzip, deflate" https://data-api.ecb.europa.eu/service/data/EXR |
Simple example using Python with content negotiation.
import requests# WS URL and dataset queryurl = "https://data-api.ecb.europa.eu/service/data/EXR/M.USD.EUR.SP00.A"# Headers to store the content negotiation setting for the format of the output file.headers = { "Accept": "application/vnd.sdmx.structurespecificdata+xml;version=2.1"}# Perform the GET request with SSL verification disabledresponse = requests.get(url, headers=headers, verify=False)# Check if the request was successfulif response.status_code == 200: # Write the content to a file called 'data.xml'. with open('data.xml', 'wb') as file: file.write(response.content) print("Data has been written to data.xml")else: print(f"Failed to retrieve data: Status code {response.status_code}") |
Simple example using base R only
# Set the variable url = the web service url including the query returning csv format > url <- "https://data-api.ecb.europa.eu/service/data/EXR/M.USD.EUR.SP00.A?format=csvdata" # Read the response into a R dataframe # Show the reresult in the dataframe |
Simple example using base R with content negotiation
# Set the variable url = the web service url including the query > url <- "https://data-api.ecb.europa.eu/service/data/EXR/M.USD.EUR.SP00.A" # Setting the header content negotiation and querying the data response <- GET( # Format the response to CSV data > csv_text <- content(response, as = "text", encoding = "UTF-8") # Read the csv data into a dataframe > df <- read.csv(text = csv_text) # Show the reresult in the dataframe > head(df) |