### Retrieve Data with Date Range Source: https://data.ecb.europa.eu/help/api/data This example shows how to retrieve data within a specified start and end date. ```APIDOC ## GET /service/data/EXR/D.USD.EUR.SP00.A?startPeriod=2009-05-01&endPeriod=2009-05-31 ### Description Retrieves data matching the supplied series key and restricting the start and end dates. ### Method GET ### Endpoint https://data-api.ecb.europa.eu/service/data/EXR/D.USD.EUR.SP00.A?startPeriod=2009-05-01&endPeriod=2009-05-31 ``` -------------------------------- ### Retrieve Data in CSV Format Source: https://data.ecb.europa.eu/help/api/data This example demonstrates how to retrieve data in CSV format. ```APIDOC ## GET /service/data/EXR/M.USD.EUR.SP00.A?format=csvdata ### Description Retrieves data in the CSV format. ### Method GET ### Endpoint https://data-api.ecb.europa.eu/service/data/EXR/M.USD.EUR.SP00.A?format=csvdata ``` -------------------------------- ### Retrieve All Data for a Dataflow Source: https://data.ecb.europa.eu/help/api/data This example shows how to retrieve all data for a given dataflow. Be aware of potential processing time for large dataflows. ```APIDOC ## GET /service/data/EXR ### Description Retrieves all the data for the EXR dataflow. Note that this may take significant time to process depending on the dataflow size. ### Method GET ### Endpoint https://data-api.ecb.europa.eu/service/data/EXR ``` -------------------------------- ### Retrieve Data with Wildcard Source: https://data.ecb.europa.eu/help/api/data This example demonstrates retrieving data using a wildcard for one of the dimensions. ```APIDOC ## GET /service/data/EXR/M..EUR.SP00.A ### Description Retrieves data for the EXR dataflow, using a wildcard for the second dimension. ### Method GET ### Endpoint https://data-api.ecb.europa.eu/service/data/EXR/M..EUR.SP00.A ``` -------------------------------- ### Retrieve Time Series Data Source: https://data.ecb.europa.eu/help/api/data This example shows how to retrieve specific time series data for the EXR dataflow. ```APIDOC ## GET /service/data/EXR/M.USD.EUR.SP00.A ### Description Retrieves data for the specified time series. ### Method GET ### Endpoint https://data-api.ecb.europa.eu/service/data/EXR/M.USD.EUR.SP00.A ``` -------------------------------- ### Retrieve Updates with OR Operator Source: https://data.ecb.europa.eu/help/api/data This example shows how to retrieve updates and revisions using the OR operator for a dimension and a specific timestamp. ```APIDOC ## GET /service/data/EXR/M.USD+GBP+JPY.EUR.SP00.A?updatedAfter=2009-05-15T14%3A15%3A00%2B01%3A00 ### Description Retrieves updates and revisions for data matching the series keys, using the OR operator for the second dimension and filtering by update time. ### Method GET ### Endpoint https://data-api.ecb.europa.eu/service/data/EXR/M.USD+GBP+JPY.EUR.SP00.A?updatedAfter=2009-05-15T14%3A15%3A00%2B01%3A00 ``` -------------------------------- ### Download data with wget Source: https://data.ecb.europa.eu/help/api/useful-tips Use wget to download data, specifying the desired format via the Accept header. The output is saved to 'data.xml'. ```bash 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 ``` -------------------------------- ### Download data with curl Source: https://data.ecb.europa.eu/help/api/useful-tips Use curl to download data, specifying the desired format via the Accept header. SSL verification is disabled with -k. The output is saved to 'data.xml'. ```bash 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 ``` -------------------------------- ### Retrieve XML Schema Source: https://data.ecb.europa.eu/help/api/schemas Use this command to download the XML schema for data validation. Ensure you replace placeholders with your specific details. The authorization header is included for authenticated access. ```bash wget -O s.xsd --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/schema/datastructure/ECB/ECB_EXR1/1.0 ``` -------------------------------- ### Retrieve All DSDs and Dataflows using 'all' and 'latest' Source: https://data.ecb.europa.eu/help/api/metadata Fetch all Data Structure Definitions (DSDs) and their Dataflows using the 'all' and 'latest' keywords for the agency. ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/datastructure/ECB/all/latest?references=dataflow ``` -------------------------------- ### Retrieve Latest Structures using 'all' and 'latest' keywords Source: https://data.ecb.europa.eu/help/api/metadata An alternative method to retrieve the latest structures as stubs using the 'all' and 'latest' keywords for the agency. ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/structure/ECB/all/latest?detail=allstubs ``` -------------------------------- ### Retrieve all codelists using 'all' and 'latest' Source: https://data.ecb.europa.eu/help/api/metadata Fetches all codelists using the keywords 'all' and 'latest', returned as stubs. ```APIDOC ## GET /service/codelist/all/all/latest?detail=allstubs ### Description Retrieve all codelists using 'all' for agency, 'all' for ID, and 'latest' for version, returned as stubs. ### Method GET ### Endpoint /service/codelist/all/all/latest?detail=allstubs ### Parameters #### Query Parameters - **detail** (string) - Optional - Specifies the level of detail, 'allstubs' returns metadata without codes. ### Request Example ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/codelist/all/all/latest?detail=allstubs ``` ``` -------------------------------- ### Retrieve Latest Codelists using 'all' and 'latest' keywords Source: https://data.ecb.europa.eu/help/api/metadata An alternative method to retrieve the latest codelists as stubs using the 'all' and 'latest' keywords. ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/codelist/all/all/latest?detail=allstubs ``` -------------------------------- ### Retrieve all artefacts using 'all' and 'latest' Source: https://data.ecb.europa.eu/help/api/metadata Fetches all maintainable artefacts using the keywords 'all' and 'latest', returned as stubs. ```APIDOC ## GET /service/structure/{maintenance_agency}/all/latest?detail=allstubs ### Description Retrieve all maintainable artefacts using 'all' for agency and 'latest' for version, returned as stubs. ### Method GET ### Endpoint /service/structure/ECB/all/latest?detail=allstubs ### Parameters #### Query Parameters - **detail** (string) - Optional - Specifies the level of detail, 'allstubs' returns metadata without codes. ### Request Example ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/structure/ECB/all/latest?detail=allstubs ``` ``` -------------------------------- ### Fetch data using Python requests Source: https://data.ecb.europa.eu/help/api/useful-tips This Python script uses the requests library to fetch data from the ECB API. It sets the Accept header for content negotiation and disables SSL verification. The retrieved data is saved to 'data.xml'. ```python import requests # URL of the time series url = "https://`data-api.ecb.europa.eu`/service/data/EXR/M.NOK.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 disabled response = requests.get(url, headers=headers, verify=False) # Check if the request was successful if 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}") ``` -------------------------------- ### Retrieve Latest Structures (Stubs) Source: https://data.ecb.europa.eu/help/api/metadata Fetch the latest production version of all maintainable artefacts (DSDs, codelists, etc.) maintained by a specific agency, returned as stubs. ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/structure/ECB?detail=allstubs ``` -------------------------------- ### Metadata Retrieval Source: https://data.ecb.europa.eu/help/api/metadata All metadata can be retrieved using the following query string structure. Learn about the SDMX standard and SDMX metadata. ```APIDOC ## Metadata Retrieval Endpoint ### Description Retrieves metadata artifacts from the ECB API. Supports various resource types and detailed query parameters. ### Method GET ### Endpoint `https://data-api.ecb.europa.eu/service/resource/agencyID/resourceID/version?detail=value&references=value` ### Parameters #### Path Parameters - **resource** (string) - Required - The type of metadata artifact to retrieve (e.g., `datastructure`, `codelist`, `dataflow`). - **agencyID** (string) - Required - The identifier of the agency maintaining the metadata. - **resourceID** (string) - Required - The identifier of the metadata resource. - **version** (string) - Optional - The version of the artifact to be returned. If not supplied, the latest version is returned. #### Query Parameters - **detail** (string) - Optional - Specifies the amount of detail to return. Allowed values: `full` (default), `allstubs`, `referencestubs`. - **references** (string) - Optional - Specifies which referenced artifacts to return. Allowed values: `none` (default), `parents`, `parentsandsiblings`, `children`, `descendants`, `all`. Can also be a specific resource type (e.g., `Codelist`). ### Request Example ``` https://data-api.ecb.europa.eu/service/codelist/ECB/CL_FREQ/1.0?detail=full&references=children ``` ### Response #### Success Response (200) - **metadata** (object) - Contains the requested metadata artifact and its related information. ``` -------------------------------- ### Retrieve Latest Codelists (Stubs) Source: https://data.ecb.europa.eu/help/api/metadata Fetch the latest production version of all codelists maintained by any agency, returned as stubs (without codes). ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/codelist?detail=allstubs ``` -------------------------------- ### Retrieve all DSDs and Dataflows using 'all' and 'latest' Source: https://data.ecb.europa.eu/help/api/metadata Fetches all Data Structure Definitions (DSDs) and their Dataflows using the keywords 'all' and 'latest'. ```APIDOC ## GET /service/datastructure/{maintenance_agency}/all/latest?references=dataflow ### Description Retrieve all Data Structure Definitions (DSDs) and their associated Dataflows, using 'all' for agency and 'latest' for version. ### Method GET ### Endpoint /service/datastructure/ECB/all/latest?references=dataflow ### Parameters #### Query Parameters - **references** (string) - Optional - Specifies the references to include, e.g., 'dataflow'. ### Request Example ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/datastructure/ECB/all/latest?references=dataflow ``` ``` -------------------------------- ### Retrieve all maintainable artefacts as stubs Source: https://data.ecb.europa.eu/help/api/metadata Fetches the latest production version of all maintainable artefacts (e.g., DSDs, codelists, concept schemes) maintained by 'ECB', returned as stubs. ```APIDOC ## GET /service/structure/{maintenance_agency}?detail=allstubs ### Description Retrieve the latest production version of all maintainable artefacts maintained by a specific agency, returned as stubs. ### Method GET ### Endpoint /service/structure/ECB?detail=allstubs ### Parameters #### Query Parameters - **detail** (string) - Optional - Specifies the level of detail, 'allstubs' returns metadata without codes. ### Request Example ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/structure/ECB?detail=allstubs ``` ``` -------------------------------- ### Retrieve DSD using 'latest' keyword Source: https://data.ecb.europa.eu/help/api/metadata Fetches the latest production version of the DSD with ID 'ECB_EXR1' maintained by 'ECB' using the 'latest' keyword. ```APIDOC ## GET /service/datastructure/{maintenance_agency}/{datastructure_id}/latest ### Description Retrieve the latest production version of a Data Structure Definition (DSD) using the 'latest' keyword in the version path. ### Method GET ### Endpoint /service/datastructure/ECB/ECB_EXR1/latest ### Request Example ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/datastructure/ECB/ECB_EXR1/latest ``` ``` -------------------------------- ### Retrieve all codelists as stubs Source: https://data.ecb.europa.eu/help/api/metadata Fetches the latest production version of all codelists maintained by any agency, returned as stubs (without codes). ```APIDOC ## GET /service/codelist?detail=allstubs ### Description Retrieve the latest production version of all codelists, returned as stubs (metadata only, without codes). ### Method GET ### Endpoint /service/codelist?detail=allstubs ### Parameters #### Query Parameters - **detail** (string) - Optional - Specifies the level of detail, 'allstubs' returns metadata without codes. ### Request Example ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/codelist?detail=allstubs ``` ``` -------------------------------- ### Retrieve Latest DSD Version using 'latest' keyword Source: https://data.ecb.europa.eu/help/api/metadata An alternative method to retrieve the latest production version of a Data Structure Definition (DSD) using the 'latest' keyword in the URL. ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/datastructure/ECB/ECB_EXR1/latest ``` -------------------------------- ### Metadata Query for Dataflows Source: https://data.ecb.europa.eu/help/api/data This endpoint allows users to query metadata for available dataflows in the ECB Data Portal. ```APIDOC ## GET /service/dataflow ### Description Retrieves a list of available dataflows in the ECB Data Portal. ### Method GET ### Endpoint https://data-api.ecb.europa.eu/service/dataflow ### Parameters This endpoint does not require any specific query parameters for a general listing. ### Request Example ``` https://data-api.ecb.europa.eu/service/dataflow ``` ### Response #### Success Response (200) - A list of dataflows with their identifiers and metadata. #### Response Example ```json { "dataflows": [ { "agencyId": "ECB", "flowId": "EXR", "version": "1.0", "name": "Daily Euro Foreign Exchange Reference Rates" } ] } ``` ``` -------------------------------- ### Retrieve All DSDs and their Dataflows Source: https://data.ecb.europa.eu/help/api/metadata Retrieve all Data Structure Definitions (DSDs) maintained by a specific agency, along with their associated Dataflows. ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/datastructure/ECB?references=dataflow ``` -------------------------------- ### Retrieve all DSDs and their Dataflows Source: https://data.ecb.europa.eu/help/api/metadata Fetches all Data Structure Definitions (DSDs) maintained by 'ECB', along with the Dataflows that use these DSDs. ```APIDOC ## GET /service/datastructure/{maintenance_agency}?references=dataflow ### Description Retrieve all Data Structure Definitions (DSDs) maintained by a specific agency, including their associated Dataflows. ### Method GET ### Endpoint /service/datastructure/ECB?references=dataflow ### Parameters #### Query Parameters - **references** (string) - Optional - Specifies the references to include, e.g., 'dataflow'. ### Request Example ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/datastructure/ECB?references=dataflow ``` ``` -------------------------------- ### Retrieve Specific DSD Version Source: https://data.ecb.europa.eu/help/api/metadata Use this to fetch a specific version of a Data Structure Definition (DSD) including its children (codelists and concepts). ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/datastructure/ECB/ECB_EXR1/1.0?references=children ``` -------------------------------- ### Retrieve DSD latest version without references Source: https://data.ecb.europa.eu/help/api/metadata Fetches the latest production version of the DSD with ID 'ECB_EXR1' maintained by 'ECB', without including codelists and concepts. ```APIDOC ## GET /service/datastructure/{maintenance_agency}/{datastructure_id} ### Description Retrieve the latest production version of a Data Structure Definition (DSD) without its child references. ### Method GET ### Endpoint /service/datastructure/ECB/ECB_EXR1 ### Request Example ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/datastructure/ECB/ECB_EXR1 ``` ``` -------------------------------- ### Retrieve Latest DSD Version Source: https://data.ecb.europa.eu/help/api/metadata Fetch the latest production version of a Data Structure Definition (DSD) without its associated codelists and concepts. ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/datastructure/ECB/ECB_EXR1 ``` -------------------------------- ### Retrieve DSD with specific version and references Source: https://data.ecb.europa.eu/help/api/metadata Fetches a specific version (1.0) of a Data Structure Definition (DSD) with ID 'ECB_EXR1' maintained by 'ECB', including its child references (codelists and concepts). ```APIDOC ## GET /service/datastructure/{maintenance_agency}/{datastructure_id}/{version} ### Description Retrieve a specific version of a Data Structure Definition (DSD) along with its associated codelists and concepts. ### Method GET ### Endpoint /service/datastructure/ECB/ECB_EXR1/1.0?references=children ### Parameters #### Query Parameters - **references** (string) - Optional - Specifies the references to include, e.g., 'children' for codelists and concepts. ### Request Example ```bash wget -O md.xml --header 'authorization: Basic ZXV1c2VybmFtZTpwYXNzd29yZA==' https://data-api.ecb.europa.eu/service/datastructure/ECB/ECB_EXR1/1.0?references=children ``` ``` -------------------------------- ### Data Retrieval Endpoint Source: https://data.ecb.europa.eu/help/api/data This endpoint allows users to retrieve specific data by providing a dataflow reference and optionally filtering by series keys, date ranges, and update times. ```APIDOC ## GET /service/data ### Description Retrieves statistical data based on specified parameters. ### Method GET ### Endpoint https://data-api.ecb.europa.eu/service/data ### Parameters #### Query Parameters - **flowRef** (string) - Required - Defines the dataflow reference in the format `**AGENCY_ID**,**FLOW_ID**,**VERSION**`. Defaults apply if elements are omitted. - **key** (string) - Optional - Specifies the Series key, which is a combination of dimension values separated by dots. Wildcarding and the OR operator (+) are supported. - **startPeriod** (string) - Optional - Defines the start date for the data range. Format depends on frequency (e.g., YYYY, YYYY-MM, YYYY-MM-DD). - **endPeriod** (string) - Optional - Defines the end date for the data range. Format depends on frequency. - **updatedAfter** (string) - Optional - Filters data updated after a specified ISO 8601 timestamp to retrieve deltas. ### Request Example ``` https://data-api.ecb.europa.eu/service/data?flowRef=ECB,EXR,1.0&key=D.USD.EUR.SP00.A&startPeriod=2023-01-01&endPeriod=2023-01-31 ``` ### Response #### Success Response (200) - Data in a structured format (e.g., JSON or CSV, depending on client negotiation). #### Response Example ```json { "data": [ { "key": "D.USD.EUR.SP00.A", "value": "0.93", "date": "2023-01-01" } ] } ``` ``` -------------------------------- ### HTTP Status Codes Source: https://data.ecb.europa.eu/help/api/status-codes The web service returns the following HTTP status codes to indicate the outcome of API requests. ```APIDOC ## HTTP Status Codes ### Description The web service returns the following HTTP status codes to indicate the outcome of API requests. ### Status Codes Table **Code**| **Status**| **Description** ---|---|--- **200**| OK| A 200 HTTP status code will be returned if your query is successfully processed and the data are returned. **304**| No changes| A 304 HTTP status code will be returned if there have been no changes to the data since the timestamp supplied in the `**If-Modified-Since**`header. **400**| Syntax error| If there is a syntactic or semantic issue with the parameters you supplied, a 400 HTTP status code will be returned. **404**| No results found| A 404 HTTP status code will be returned if there are no results matching the query. **406**| Not Acceptable| If you ask for a resource representation that we do not support, a 406 HTTP status code will be returned. To view the supported representations, please see the “Content negotiation” section. **500**| Internal Server Error| When there is an issue on our side, a 500 HTTP status code will be returned. Feel free to try again later or to contact our support hotline. **501**| Not implemented| Our web service offers a subset of the functionality offered by the SDMX RESTful web service specification. When you use a feature that we have not yet implemented, a 501 HTTP status code will be returned. **503**| Service unavailable| If our web service is temporarily unavailable, a 503 HTTP status code will be returned. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.