Purpose of ASYNC API
The ASYNC API is a programmatic access for asynchronous responses to large data requests.
For the SDMX APIs, data can be returned either synchronously or asynchronously:
Synchronously: the data is returned directly in the response to the request. This is the default operation
Asynchronously: the data is not returned directly in the response. Instead a key is returned in the response which allows to access the data through the async API to check for its availability and eventually retrieve it once available.
The decision whether to deliver the data synchronously or asynchronously is related to factors such as the complexity of the query and the volume of the data (number of rows) to be returned.
In case the requested filtered data would be to important to be prepared, a client error code 413 is returned with a suggestion to apply more filtering to the request.
<S:Fault xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <faultcode>413</faultcode> <faultstring>EXTRACTION_TOO_BIG: The requested extraction is too big, estimated 420709314 rows, max authorised is 5000000, please change your filters to reduce the extraction size</faultstring> </S:Fault>
How to implement asynchronous requests?
The asynchronous delivery process can be summarised as follows:
Step 1. A client issues a request to one of the SDMX data API. The API returns a response indicating asynchronous delivery pattern, with a unique key
Step 2. The client issues to the asynchronous endpoint at regular interval a request with the unique key, to enquire about the readiness of the requested data
Step 3. Once the data is available, the client can request the data for the provided unique key and receive it
Example
Step 1: Initial request
For an initial data request for which asynchronous delivery pattern must be used, the response is similar to following XML:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Header/> <env:Body> <ns0:syncResponse xmlns:ns0="http://estat.ec.europa.eu/disschain/soap/extraction"> <processingTime>412</processingTime> <queued> <id>98de05ea-540a-43d3-903b-7c9e14faf808</id> <status>SUBMITTED</status> </queued> </ns0:syncResponse> </env:Body> </env:Envelope>
The <id> value, 98de05ea-540a-43d3-903b-7c9e14faf808 in this example is the key to use for checking data availability against the asynchronous API.
Step 2: Get the current status of the request
The status of a request that is processed asynchronously can be one of the following values:
Value | Meaning |
---|---|
SUBMITTED | The request is queued for processing |
PROCESSING | The request is currently being processed |
AVAILABLE | The data is available for download, |
EXPIRED | The data is no longer available. This occurs after a few days or when corresponding dataset content was updated. Please restart from Step 1. |
UNKNOWN_REQUEST | In case the key provided cannot be matched to a request |
ERROR | The request was processed but an unexpected error occurred. Please retry or contact support with id of your request |
The current status of a given request can be obtained via a REST request:
- Request URL: https://<api_base_uri>/1.0/async/status/<id>
- Example of URL request: https://ec.europa.eu/eurostat/api/dissemination/1.0/async/status/98de05ea-540a-43d3-903b-7c9e14faf808
This request may provide different results, depending on the current status of the request:
PROCESSING : As long as the request is not processed/finished, the following result will be returned:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Header/> <env:Body> <ns0:asyncResponse xmlns:ns0="http://estat.ec.europa.eu/disschain/soap/asynchronous" xmlns:ns1="http://estat.ec.europa.eu/disschain/asynchronous"> <ns1:status> <ns1:key>98de05ea-540a-43d3-903b-7c9e14faf808</ns1:key> <ns1:status>PROCESSING</ns1:status> </ns1:status> </ns0:asyncResponse> </env:Body> </env:Envelope>
AVAILABLE: The request is processed/finished. When the query is fully executed, the returned status will be AVAILABLE and the following result will be returned:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Header/> <env:Body> <ns0:asyncResponse xmlns:ns0="http://estat.ec.europa.eu/disschain/soap/asynchronous" xmlns:ns1="http://estat.ec.europa.eu/disschain/asynchronous"> <ns1:status> <ns1:key>98de05ea-540a-43d3-903b-7c9e14faf808</ns1:key> <ns1:status>AVAILABLE</ns1:status> </ns1:status> </ns0:asyncResponse> </env:Body> </env:Envelope>
Step 3: Get the data
When the results are AVAILABLE, it is possible to to download the data. Data can be obtained via a REST request:
Request URL: https://<api_base_uri>/1.0/async/data/<id>
Example of URL request: https://ec.europa.eu/eurostat/api/dissemination/1.0/async/data/98de05ea-540a-43d3-903b-7c9e14faf808
Errors returned
No data
In case the query eventually did not contains any statistical value,
<S:Fault xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <faultcode>100</faultcode> <faultstring>NO_RESULTS: The query that has been sent did not return any results.</faultstring> </S:Fault>
Data not yet ready
As long as the data is not ready as informed by the status service call, the returned XML response will be:
<S:Fault> <faultcode>100</faultcode> <faultstring>DATA_NOT_YET_AVAILABLE: Requested data is not yet available for download. Check the status of your request.</faultstring> </S:Fault>
Invalid key
If the key provided is not valid, the returned SOAP result will be:
<S:Fault> <faultcode>100</faultcode> <faultstring>UNKNOWN_REQUEST: Unknown request.</faultstring> </S:Fault>