【发布时间】:2020-05-04 15:32:38
【问题描述】:
我正在尝试使用 R 从人口普查局下载国际贸易数据。它们提供了一个返回 JSON 数据的 API,如下例所示。我不熟悉 API 和 JSON。如何通过 R 查询 API?
{
"@context": "https://project-open-data.cio.gov/v1.1/schema/catalog.jsonld",
"@id": "https://api.census.gov/data/timeseries/eits/ftd.json",
"@type": "dcat:Catalog",
"conformsTo": "https://project-open-data.cio.gov/v1.1/schema",
"describedBy": "https://project-open-data.cio.gov/v1.1/schema/catalog.json",
"dataset": [
{
"c_dataset": [
"timeseries",
"eits",
"ftd"
],
"c_geographyLink": "https://api.census.gov/data/timeseries/eits/ftd/geography.json",
"c_variablesLink": "https://api.census.gov/data/timeseries/eits/ftd/variables.json",
"c_examplesLink": "https://api.census.gov/data/timeseries/eits/ftd/examples.json",
"c_groupsLink": "https://api.census.gov/data/timeseries/eits/ftd/groups.json",
"c_valuesLink": "https://api.census.gov/data/timeseries/eits/ftd/values.json",
"c_documentationLink": "http://www.census.gov/developer/",
"c_isTimeseries": true,
"c_isCube": true,
"c_isAvailable": true,
"@type": "dcat:Dataset",
"title": "Time Series Economic Indicators Time Series -: U.S. International Trade in Goods and Services",
"accessLevel": "public",
"bureauCode": [
"006:07"
],
"description": "The U.S. Census Bureau.s economic indicator surveys provide monthly and quarterly data that are timely, reliable, and offer comprehensive measures of the U.S. economy. These surveys produce a variety of statistics covering construction, housing, international trade, retail trade, wholesale trade, services and manufacturing. The survey data provide measures of economic activity that allow analysis of economic performance and inform business investment and policy decisions. Other data included, which are not considered principal economic indicators, are the Quarterly Summary of State & Local Taxes, Quarterly Survey of Public Pensions, and the Manufactured Homes Survey. For information on the reliability and use of the data, including important notes on estimation and sampling variance, seasonal adjustment, measures of sampling variability, and other information pertinent to the economic indicators, visit the individual programs' webpages - http://www.census.gov/cgi-bin/briefroom/BriefRm.",
"distribution": [
{
"@type": "dcat:Distribution",
"accessURL": "https://api.census.gov/data/timeseries/eits/ftd",
"description": "API endpoint",
"format": "API",
"mediaType": "application/json",
"title": "API endpoint"
}
],
"contactPoint": {
"fn": "Economic Indicators Mail List",
"hasEmail": "econ.indicators@census.gov"
},
"identifier": "http://api.census.gov/data/id/EITSFTD",
"keyword": [
],
"license": "http://creativecommons.org/publicdomain/zero/1.0/Public Domain",
"modified": "2017-02-23",
"programCode": [
"006:007"
],
"references": [
"http://www.census.gov/developers/"
],
"spatial": "United States",
"temporal": "January 1992 - Current",
"publisher": {
"@type": "org:Organization",
"name": "U.S. Census Bureau",
"subOrganizationOf": {
"@type": "org:Organization",
"name": "U.S. Department Of Commerce",
"subOrganizationOf": {
"@type": "org:Organization",
"name": "U.S. Government"
}
}
}
}
]
}
更多详情:API 可以在这里找到:https://www.census.gov/data/developers/data-sets/international-trade.html
数据可以从这里手动下载,需要登录:https://usatrade.census.gov/
【问题讨论】: