Browse
API
  • Data
  • Graphs
  • Search
  • Account
  • API
  • Contact us

Data  数据

Basics  基础

All the data stored in the ECB Data Portal can be retrieved using the query string below
ECB 数据门户中存储的所有数据都可以使用下面的查询字符串检索

protocol://wsEntryPoint/resource/flowRef/key?parameters

where parameters are defined as such:
其中 parameters 定义如下:

startPeriod=value&endPeriod=value&updatedAfter=value& firstNObservations=value&lastNObservations=value&detail=value& includeHistory=value

Syntax definition  语法定义

Protocol  协议
As of 28 January 2021 the web service is only available over https. http calls made via a browser will be automatically redirected to https.
截至 2021 年 1 月 28 日,网络服务仅通过 https 提供。通过浏览器进行的 http 调用将自动重定向到 https
wsEntryPoint  ws 入口点
The web service entry point is available at the following location: 
Web 服务入口位于以下位置:

https://data-api.ecb.europa.eu/
resource  资源
The resource for data queries is data.
数据查询的资源是 data
flowRef (Defining the dataflow reference)
流程引用 (定义数据流引用)

A reference to the dataflow describing the data that needs to be returned.
对描述需要返回的数据的数据流的引用。

The syntax is the identifier of the agency maintaining the dataflow, followed by the identifier of the dataflow, followed by the dataflow version, separated by a comma (,). 
语法是 identifier of the agency 保持数据流,后接 identifier of the dataflow ,后接 dataflow version ,用逗号 ( , ) 分隔。

For example: AGENCY_ID,FLOW_ID,VERSION
例如: AGENCY_IDFLOW_IDVERSION

If the parameter contains only one of these three elements, it is considered to be the identifier of the dataflow. The value for the identifier of the agency maintaining the dataflow will default to all, while the value for the dataflow version will default to latest.
如果参数只包含这三个元素中的一个,则它被视为数据流的标识符。维护数据流的机构的标识符的值默认为 all ,而数据流版本的默认值为 latest

If the string contains only two of these three elements, they are the identifier of the agency maintaining the dataflow and the identifier of the dataflow. The value for the dataflow version will default to latest.
如果字符串只包含这三个元素中的两个,则它们分别是维护数据流的机构标识符和数据流标识符。数据流版本的默认值为 latest

In order to see the dataflows available in the ECB Data Portal, a metadata query for all dataflows can be performed: https://data-api.ecb.europa.eu/service/dataflow
为了查看欧洲央行数据门户中可用的数据流,可以执行针对所有数据流的元数据查询: https://data-api.ecb.europa.eu/service/dataflow

resource (Defining the Dimension values)
资源 (定义维度值)

As explained in the Overview section, the combination of Dimensions allows statistical data to be uniquely identified. In SDMX, such a combination is known as a Series key, and this is what needs to be input for the key parameter.
如概述部分所述,维度的组合允许唯一标识统计数据。在 SDMX 中,这种组合被称为系列键,这就是 key 参数需要输入的内容。

For example, let’s say that exchange rates can be uniquely identified by the following:
例如,我们可以用以下方式唯一标识汇率:

  • the frequency at which they are measured (e.g. daily – code   他们被测量的频率(例如,每日——代码D);
  • the currency being measured (e.g. US dollar – code   被测量的货币(例如 美元 – 代码USD);
  • the currency against which the above currency is being measured (e.g. euro – code   参照上述货币计价的货币(例如欧元 - 代码EUR);
  • the type of exchange rates (e.g. foreign exchange reference rates – code   汇率类型(例如,外汇参考汇率——代码SP00);
  • the Time series variation (e.g. average or standardised measure for a given frequency – code   时间序列变化(例如,给定频率的平均值或标准化度量——代码A).

To build the Series key, take the value for each of the Dimensions (following the order in which the Dimensions are defined in the DSD) and join them with a dot (.). The Series key for the example above would therefore be: D.USD.EUR.SP00.A
要构建系列键,请获取每个维度(按照 DSD 中定义维度的顺序)的值,并使用点 ( . ) 将它们连接起来。因此,以上示例的系列键为: D.USD.EUR.SP00.A

Wildcarding is supported by omitting the value for the Dimension to be wildcarded. For example, the following Series key can be used to retrieve the data for all daily currencies against the euro: D..EUR.SP00.A
通配符支持通过省略要通配的维度的值来实现。例如,以下系列键可用于检索所有每日货币相对于欧元的相关数据: D..EUR.SP00.A

The OR operator is supported using the plus (+) sign. For example, the following key can be used to retrieve the exchange rates against the euro for both the US dollar and the Japanese yen (code JPY): D.USD+JPY.EUR.SP00.A
使用加号( + )支持 OR 运算符。例如,可以使用以下密钥来检索美元和日元(代码 JPY )相对于欧元的汇率: D.USD+JPY.EUR.SP00.A

You can combine wildcarding and the OR operator. For example, the following key can be used to retrieve daily or monthly exchange rates (codes D for daily and M for monthly) of any currency against the euro: D+M..EUR.SP00.A
您可以结合通配符和 OR 操作符。例如,以下键可用于检索任何货币相对于欧元的每日或每月汇率(代码 D 用于每日, M 用于每月): D+M..EUR.SP00.A

startPeriod & endPeriod (Defining a date range)
开始日期 & 结束日期 (定义日期范围)

It is possible to define a date range for which Observations are to be returned by using the startPeriod and/or endPeriod parameters. The values should be given according to the syntax defined in ISO 8601 or as SDMX reporting periods. The format will vary depending on the frequency. The supported formats are:
可以使用 startPeriod 和/或 endPeriod 参数来定义需要返回观测值的日期范围。值应根据 ISO 8601 中定义的语法或 SDMX 报告期提供。格式将根据频率而异。支持的格式包括:

  • YYYY for annual data (e.g. 2013);  (例如 2013 年)年度数据;
  • YYYY-S[1-2]  for semi-annual data (e.g. 2013-S1);  用于半年数据(例如 2013-S1);
  • YYYY-Q[1-4]  for quarterly data (e.g. 2013-Q1);  (例如 2013-Q1)季度数据;
  • YYYY-MM  for monthly data (e.g. 2013-01);  用于每月数据(例如 2013-01);
  • YYYY-W[01-53]  for weekly data (e.g. 2013-W01);  (例如 2013-W01)的每周数据;
  • YYYY-MM-DD  for daily data (e.g. 2013-01-01).  用于每日数据(例如 2013-01-01)。
updatedAfter (Retrieving deltas)
updatedAfter (获取增量)

By supplying a percent-encoded ISO 8601 timestamp for the updatedAfter parameter, it is possible to retrieve the latest version of changed values in the database after a certain point in time (i.e. updates and revisions).
通过为 updatedAfter 参数提供百分比编码的 ISO 8601 时间戳,可以检索数据库中特定时间点之后更改值的最新版本(即更新和修订)。

This will include:  这将包括:

  • the Observations that have been  
    已经观察到的
    added  添加  since the supplied timestamp;
    自提供的 时间戳;
  • the Observations that have been  
    已有的观察
    revised  修改版  since the supplied timestamp;
    自提供的 时间戳;
  • the Observations that have been  
    已经观察到的
    deleted  删除  since the supplied timestamp.
    自提供的时间戳以来

For example, the percent-encoded representation for 2009-05-15T14:15:00+01:00 would be: 2009-05-15T14%3A15%3A00%2B01%3A00.
例如, 2009-05-15T14:15:00+01:00 的百分比编码表示为: 2009-05-15T14%3A15%3A00%2B01%3A00

Developers who update their local databases with data stored in the ECB Data Portal should make use of the updatedAfter parameter, as this will significantly improve performance. Instead of systematically downloading data that have not changed, you will only receive the changes that were made in the database after you last performed the same query.
使用 ECB 数据门户存储的数据更新本地数据库的开发人员应使用 updatedAfter 参数,这将显著提高性能。与其系统地下载未更改的数据,您只需接收上次执行相同查询后数据库中所做的更改。

Should you not be able to handle updates and revisions, or if you would prefer to perform a full refresh of your local database when something has changed, you can use an If-Modified-Since header as an alternative to the updatedAfter parameter described above. This triggers a HTTP conditional request, which will return the data only if something has changed since the timestamp supplied in the If-Modified-Since header. If nothing has changed, the server will respond with a HTTP 304 response code.
如果无法处理更新和修订,或者您更希望在发生更改时完全刷新本地数据库,则可以使用 If-Modified-Since 头作为上述 updatedAfter 参数的替代。这会触发 HTTP 条件请求,只有在自 If-Modified-Since 头中提供的时间戳以来数据发生更改时,才会返回数据。如果没有任何更改,服务器将以 HTTP 304 响应代码做出回应。

detail (Defining the amount of detail included)
细节(定义包含的细节数量)

Using the detail parameter, it is possible to specify the desired amount of information to be returned by the web service. Possible options are:
使用 detail 参数,可以指定 Web 服务返回的信息量。可能的选项是:

  • full: the data (Time series and Observations) and the Attributes will be returned. This is the default.
    数据(时间序列和观测值)以及属性将被返回。这是默认设置。
  • dataonly: the Attributes will be excluded from the returned message.
    属性将从返回的消息中排除。
  • serieskeysonly: only the Time series will be returned, excluding the Attributes and the Observations. This can be used to list Time series that match a certain query without returning the actual data.
    仅返回时间序列,不包括属性和观测值。这可用于列出与特定查询匹配的时间序列,而无需返回实际数据。
  • nodata: the Time series will be returned, including the Attributes, but the Observations will not.
    时间序列将返回,包括属性,但不包括观测值。
firstNObservations & lastNObservations (Defining the number of Observations)
首 N 个观测值 & 末 N 个观测值 (定义观测次数)
Using the firstNObservations and/or lastNObservations parameters, it is possible to specify the maximum number of Observations to be returned for each of the matching Time series, starting from the first Observation (firstNObservations) or counting back from the most recent Observation (lastNObservations).
使用 firstNObservations 和/或 lastNObservations 参数,可以指定为每个匹配的时间序列返回的最大观测数,从第一个观测值( firstNObservations )开始,或从最近的观测值( lastNObservations )倒数。
includeHistory (Retrieving historical data)
包含历史数据 (Retrieving historical data)

Using the includeHistory parameter, you can instruct the web service to return previous versions of the matching data. This allows you to see how the data have evolved over time (i.e. see when new data were released, revised or deleted). Possible options are:
使用 includeHistory 参数,您可以指示 Web 服务返回匹配数据的先前版本。这使您可以查看数据随时间推移的演变情况(例如,查看何时发布、修订或删除新数据)。可能的选项是:

  • false: only the version currently in production will be returned. This is the default.
    目前仅返回正在生产的版本。这是默认设置。
  • true: the version currently in production and all previous versions will be returned.
    当前生产版本及所有之前的版本都将返回。
format (Retrieving data in different formats)
格式 (检索不同格式的数据)

Using the format parameter, you can instruct the web service to return data in different formats (see also the content negotiation tab). Possible options are:
使用 format 参数,您可以指示 Web 服务以不同的格式返回数据(另请参阅内容协商选项卡)。可能的选项包括:

  • csvdata: comma-separated values  逗号分隔值
  • jsondata: JSON  JSON
  • structurespecificdata: SDMX-ML 2.1 Structure Specific Data format
    SDMX-ML 2.1 结构特定数据格式
  • genericdata: SDMX-ML 2.1 Generic Data
    SDMX-ML 2.1 通用数据

Examples  示例

Please refer to the Useful tips section to see examples of these queries with command line tools such as curl or wget.
请参考“实用技巧”部分,查看使用诸如 curlwget 等命令行工具的这些查询示例。

Retrieve the data for the time series M.USD.EUR.SP00.A for the EXR dataflow
检索 M.USD.EUR.SP00.A 时间序列的 EXR 数据流数据
https://data-api.ecb.europa.eu/service/data/EXR/M.USD.EUR.SP00.A
Retrieve the data for the EXR dataflow, matching the supplied Series keys, using wildcarding for the second Dimension
检索 EXR 数据流的数据,匹配提供的系列键,使用通配符匹配第二个维度
https://data-api.ecb.europa.eu/service/data/EXR/M..EUR.SP00.A
Retrieve the updates and revisions for the data matching the supplied Series keys, using the OR operator for the second Dimension. As mentioned previously, the ISO 8601 timestamp needs to be percent-encoded.
检索与提供的系列键匹配的数据的更新和修订,使用 OR 运算符作为第二维度。如前所述,ISO 8601 时间戳需要进行百分比编码。
https://data-api.ecb.europa.eu/service/data/EXR/M.USD+GBP+JPY.EUR.SP00.A?updatedAfter=2009-05-15T14%3A15%3A00%2B01%3A00
Retrieve the data matching the supplied Series key and restricting the start and end dates.
检索与提供的系列键匹配的数据,并限制起始日期和结束日期。
https://data-api.ecb.europa.eu/service/data/EXR/D.USD.EUR.SP00.A?startPeriod=2009-05-01&endPeriod=2009-05-31
Retrieve all the data for the EXR dataflow. Please note that depending on the dataflow size, retrieving all its data could take a significant amount of time to process.
检索 EXR 数据流的所有数据。请注意,根据数据流的大小,检索所有数据可能需要大量时间进行处理。
https://data-api.ecb.europa.eu/service/data/EXR
Retrieve data in the CSV format
检索 CSV 格式的数据
https://data-api.ecb.europa.eu/service/data/EXR/M.USD.EUR.SP00.A?format=csvdata