有关指标API
联合国水机制指标API提供了对从各种来源收集的数据的访问权限。这些指标大多可在网上查阅。 API提供了对这些相同数据的编程访问权限。许多数据系列可以追溯到50多年前,可用于开发有趣的应用程序。
指标API提供了对各类数据库的访问权限,包括:
- 世卫组织
- 开发署
- 儿基会
- 粮农组织
- 等等
如何使用指标API
例如:https://sdg6data.org/api/indicator/6.1.1?_format=json
除了使用应用程序或自定义程序调用API之外,您还可以将文档中给出的任何示例API URL端点或您自己的自定义调用放到网络浏览器中中并查看结果。如果您选择接收JSON格式的结果,则可以使用JSON View Firefox插件,直接在Firefox中轻松地查看JSON结果。
还有一些第三方应用程序和库可以根据您的目标来简化API的使用。
请查看下面的基本调用结构:
下面的API文档显示了如何访问这些数据,以便在您的应用程序中加以使用。
https://sdg6data.org/api/indicator/{indicator_code}?_format=xml
请求参数:
{indicator_code} - 这可以是任何SDG 6指标代码。指标代码是API URL的一部分,在API调用中必须传递。
https://sdg6data.org/api/indicator/6.1.1?_format=xml
以上URL将返回6.1.1的所有年份和所有国家的数据。
_format :输出格式。API支持两种格式:xml或json。根据Drupal 8 RESTful Webservice标准,该参数是强制性的。
https://sdg6data.org/api/indicator/6.1.1?_format=xml
https://sdg6data.org/api/indicator/6.1.1?_format=json
per_page : 每页的结果数,用于对结果集进行分页。默认设置是50
https://sdg6data.org/api/indicator/6.1.1?_format=xml&per_page=20
page – 用于对大型结果集进行分页的实用参数。表示从记录集请求的页码。
https://sdg6data.org/api/indicator/6.1.1?_format=xml&page=2
date – 按年、月或季度划分的日期范围,用于界定结果集的范围。使用冒号分隔符表示范围
https://sdg6data.org/api/indicator/6.1.1?_format=xml&date=2000:2001
显示使用多个国家参数进行指标查询时的所有指标数据
https://sdg6data.org/api/indicator/6.1.1?_format=json&country=CAN,ALB
显示进行指标查询时的所有指标数据
https://sdg6data.org/api/indicator/all?_format=json
指标API查询
指标代表的数据包括国家、城市、农村地区、水的供应和使用、水资源管理、死亡人数、失踪人数等等。指标查询在响应中返回以下信息:
- 目标
- 具体目标
- 指标
- 序列代码
- 序列描述
- 地理区域类型
- 地理区域名称
- 地理区域代码
- 时间期限
- 值
- 时间_详情
- 来源
- 脚注
- 性质
- 单位
- 年龄
- 界限
- 频率
- 级别_状况
- 位置
- 报告_类型
- 性别
请求格式样本:指标查询
如要请求所有指标:https://sdg6data.org/api/indicator/all?_format=json
6.1.1
响应格式样本:指标查询
<response> <item key="0"> <page>0</page> <pages>11593</pages> <per_page>50</per_page> <total>579635</total> </item> <item key="1"> <item key="0"> <Goal/> <Target/> <Indicator>6.1.1 </Indicator> <SeriesCode/> <SeriesDescription>饮用水,至少有基本服务</SeriesDescription> <GeoAreaType>国家</GeoAreaType> <GeoAreaName>ABW</GeoAreaName> <GeoAreaCode>533</GeoAreaCode> <TimePeriod>2000</TimePeriod> <Value>94.488806355508</Value> <Time_Detail/> <Source>世卫组织,儿基会</Source> <FootNote/> <Nature/> <Units/> <Age/> <Bounds/> <Frequency/> <Level_Status/> <Location>全国</Location> <Reporting_Type/> <Sex/> <SDG_6_Data_Portal_level><![CDATA]6.1.1 使用得到安全管理的饮用水服务的人口比例(%) > 至少有基本服务 > 全国
[{ "page":0, "pages":11593, "per_page":50, "total":579635 }, [{ "Goal":null, "Target":null, "Indicator":"6.1.1", "SeriesCode":null, "SeriesDescription":"饮用水,至少有基本服务", "GeoAreaType":"国家", "GeoAreaName":"ABW", "GeoAreaCode":"533", "TimePeriod":"2000", "Value":"94.488806355508", "Time_Detail":null, "Source":"世卫组织,儿基会", "FootNote":null, "Nature":null, "Units":null, "Age":null, "Bounds":null, "Frequency":null, "Level_Status":null, "Location":"National", "Reporting_Type":null, "Sex":null, "SDG_6_Data_Portal_level":"6.1.1 使用得到安全管理的饮用水服务的人口比例(%) \u003E 至少有基本服务 \u003E 全国" }] ]
响应格式样本:带有国家筛选器的指标查询:
[{"page":0, "pages":2804, "per_page":50, "total":140199}, [{"Goal":null, "Target":null, "Indicator":"6.1.1", "SeriesCode":null, "SeriesDescription":"饮用水,至少有基本服务", "GeoAreaType":"国家", "GeoAreaName":"ABW", "GeoAreaCode":"533", "TimePeriod":"2000", "Value":"94.488806355508", "Time_Detail":null, "Source":"世卫组织,儿基会", "FootNote":null, "Nature":null, "Units":null, "Age":null, "Bounds":null, "Frequency":null, "Level_Status":null, "Location":"National", "Reporting_Type":null, "Sex":null, "SDG_6_Data_Portal_level":"6.1.1 使用得到安全管理的饮用水服务的人口比例(%) \u003E 至少有基本服务 \u003E 全国"}]
可以在这里下载带有ISO3代码的国家列表
API访问/身份验证
访问API不再需要API密钥和其他身份验证方法。