/v1/bulk/observations/series/linked
Returns observations of multiple variables for entities linked to an ancestor entity by the same property.
More specifically, in the following diagram:
The property containedInPlace
is linked. Buenos Aires is contained in
Argentina, which is itself contained in South America – implying Buenos Aires
is also contained in South America. With this endpoint, you could query for
countries in South America (returning observations for Argentina) or for cities
in South America (returning observations for Buenos Aires).
This is useful for retrieving observations for all places within an ancestor place. For example, this could be getting the population of women for all states in the United States.
Currently, this endpoint only supports the
containedInPlace
property and Place
entities. Support for other properties and entity types will be added in the future.
To get a series of observations for a single place, see /v1/observations/series.
To get single observations for all places within an ancestor place, see /v1/bulk/observations/point/linked.
Request
Path Parameters
There are no path parameters for this endpoint.
Query Parameters
Name | Type | Description |
---|---|---|
key |
string | Your API key. See the page on authentication for a demo key, as well as instructions on how to get your own key. |
linked_entity |
list | DCID of the ancestor place to query. |
entity_type |
string | Type of place to query for (e.g. city, county, state, etc.). For a list of available values, see the Knowledge Graph page on Place. |
variables |
list | DCIDs of the variables to query. |
linked_property |
string | DCID of the property to query. Must be containedInPlace . |
all_facets |
boolean | Whether to return data from all facets available. If true, data from all facets available will be returned. If false, only data from the preferred facet will be returned. Defaults to false. |
Response
The response looks like:
{
"observationsByVariable":
[
{
"variable": "variable_dcid_1",
"observationsByEntity":
[
{
"entity": "entity_dcid_1",
"seriesByFacet":
[
{
"series":
[
{
"date": "YYYY-MM-DD",
"value": 1234
}, ...
],
"facet": 0123456789
}
]
}, ...
]
}, ...
],
"facets":
{
"0123456789":
{
"importName": "import_name_here",
"provenanceUrl": "https://provenance.url/here",
"measurementMethod": "measurement_method_here",
"observationPeriod": "P<N>Y"
}
}
}
Response fields
Name | Type | Description |
---|---|---|
observationsByVariable | list | List of observations organized by variable. These are further organized by entity, and then by facet. Observations are returned in chronological order. |
facets | object | Metadata on the facet(s) the data came from. Can include things like provenance, measurement method, and units. |
Examples
Example 1: Get observations for all places within an ancestor place.
Get the population (DCID: Count_Person
) for all counties in the US state of Delaware (DCID: geoId/10
).
-
Request:
$ curl --request GET --url \ 'https://api.datacommons.org/v1/bulk/observations/series/linked?linked_entity=geoId/10&linked_property=containedInPlace&variables=Count_Person&entity_type=County&key=AIzaSyCTI4Xz-UW_G2Q2RfknhcfdAnTHq5X5XuI'
-
Request:
$ curl --request POST \ --url https://api.datacommons.org/v1/bulk/observations/series/linked \ --header 'X-API-Key: AIzaSyCTI4Xz-UW_G2Q2RfknhcfdAnTHq5X5XuI' \ --data '{"linked_entity":"geoId/10", "linked_property":"containedInPlace", "entity_type":"County", variables:"Count_Person"}'
Response:
{
"observationsByVariable":
[
{
"variable": "Count_Person",
"observationsByEntity":
[
{
"entity": "geoId/10001",
"seriesByFacet":
[
{
"series":
[
{
"date": "1970",
"value": 81892
},
< ... output truncated for brevity ... >
{
"date": "2021",
"value": 184149
}
],
"facet": 2176550201
}
]
},
{
"entity": "geoId/10003",
"seriesByFacet":
[
{
"series":
[
{
"date": "1970",
"value": 385856
},
< ... output truncated for brevity ... >
{
"date": "2021",
"value": 571708
}
],
"facet": 2176550201
}
]
},
{
"entity": "geoId/10005",
"seriesByFacet":
[
{
"series":
[
{
"date": "1970",
"value": 80356
},
< ... output truncated for brevity ... >
{
"date": "2021",
"value": 247527
}
],
"facet": 2176550201
}
]
}
]
}
],
"facets":
{
"2176550201":
{
"importName": "USCensusPEP_Annual_Population",
"provenanceUrl": "https://www2.census.gov/programs-surveys/popest/tables",
"measurementMethod": "CensusPEPSurvey",
"observationPeriod": "P1Y"
}
}
}
Page last updated: December 17, 2024 • Send feedback about this page