/v1/triples
Get a triple.
Useful for finding local connections between nodes of the Data Commons knowledge graph.
To query triples for multiple nodes, see the bulk version of this endpoint.
Request
GET Request
http://api.datacommons.org/v1/triples/{EDGE_DIRECTION}/{NODE_DCID}?key={api_key}
Path Parameters
Name | Description |
---|---|
EDGE_DIRECTION |
One of in or out . Denotes direction of edges to get triples for. If in , returns triples with edges pointing toward the node provided. If out , returns triples with edges pointing away from the node provided. |
NODE_DCID |
DCID of the node to query. |
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. |
Response
The response looks like:
{
"triples":
{
"property_describing_node_queried_1":
{
"nodes":
[
{
"property_1": "value",
"property_2": "value",
...
}, ...
]
}, ...
}
}
Response fields
Name | Type | Description |
---|---|---|
triples | object | A nested JSON object containing DCIDs of both properties that describe the node queried, and nodes connected to the queried node via those properties. |
Examples
Example 1: Get triples of outgoing edges
Get triples for the node representing Carbon Dioxide (DCID: CarbonDioxide
),
where edges point away from the node for Carbon Dioxide.
Request:
$ curl --request GET --url \
'https://api.datacommons.org/v1/triples/out/CarbonDioxide?key=AIzaSyCTI4Xz-UW_G2Q2RfknhcfdAnTHq5X5XuI'
Response:
{
"triples": {
"description": {
"nodes": [
{
"provenanceId": "dc/5l5zxr1",
"value": "A colorless gas consisting of a carbon atom covalently double bonded to two oxygen atoms."
}
]
},
"descriptionUrl": {
"nodes": [
{
"provenanceId": "dc/5l5zxr1",
"value": "https://en.wikipedia.org/wiki/Carbon_dioxide"
}
]
},
"name": {
"nodes": [
{
"provenanceId": "dc/5l5zxr1",
"value": "Carbon Dioxide"
},
{
"provenanceId": "dc/5l5zxr1",
"value": "CarbonDioxide"
}
]
},
"provenance": {
"nodes": [
{
"name": "https://datacommons.org",
"types": ["Provenance"],
"dcid": "dc/5l5zxr1",
"provenanceId": "dc/5l5zxr1"
}
]
},
"typeOf": {
"nodes": [
{
"name": "GasType",
"types": ["Class"],
"dcid": "GasType",
"provenanceId": "dc/5l5zxr1"
},
{
"name": "GreenhouseGas",
"types": ["Class"],
"dcid": "GreenhouseGas",
"provenanceId": "dc/5l5zxr1"
}
]
}
}
}
Example 2: Get triples of incoming edges
Get triples for the node representing Carbon Dioxide (DCID: CarbonDioxide
),
where edges point towards the node Carbon Dioxide.
Request:
$ curl --request GET --url \
'https://api.datacommons.org/v1/triples/in/CarbonDioxide?key=AIzaSyCTI4Xz-UW_G2Q2RfknhcfdAnTHq5X5XuI'
Response:
{
"triples": {
"emittedThing": {
"nodes": [
{
"name": "CO2 Emissions Per Capita",
"types": ["StatisticalVariable"],
"dcid": "Amount_Emissions_CarbonDioxide_PerCapita",
"provenanceId": "dc/d7tbsb1"
},
{
"name": "Annual Amount of Emissions: Biogenic Emission Source, Carbon Dioxide",
"types": ["StatisticalVariable"],
"dcid": "Annual_Emissions_CarbonDioxide_Biogenic",
"provenanceId": "dc/d7tbsb1"
},
{
"name": "Annual Amount of Emissions: Non Biogenic Emission Source, Carbon Dioxide",
"types": ["StatisticalVariable"],
"dcid": "Annual_Emissions_CarbonDioxide_NonBiogenic",
"provenanceId": "dc/d7tbsb1"
},
{
"types": ["StatisticalVariable"],
"dcid": "dc/pelkj2pkyww1",
"provenanceId": "dc/6zzrcr2"
}
]
}
}
}
Page last updated: December 17, 2024 • Send feedback about this page