/v1/bulk/triples

Get triples for multiple nodes.

Useful for finding local connections between nodes of the Data Commons knowledge graph.

Request

https://api.datacommons.org/v1/bulk/triples/{EDGE_DIRECTION}?nodes={node_dcid_1}&nodes={node_dcid_2}&key={your_api_key}
URL: https://api.datacommons.org/v1/bulk/triples/{EDGE_DIRECTION} Header: X-API-Key: {your_api_key} JSON Data: { "nodes": [ "{value_1}", "{value_2}", ... ] }

Path Parameters

Name Description
EDGE_DIRECTION
Required
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.

Query Parameters

Name Type Description
key
Required
string Your API key. See the page on authentication for a demo key, as well as instructions on how to get your own key.
nodes
Required
string DCIDs of the nodes to query.

Response

The response looks like:

{
  "data":
  [
    {
      "node": "node_dcid_1",
      "triples":
      {
        "property_of_node":
        {
          "nodes":
          [
            {
              "property_1": "value",
              "property_2": "value",
              ...
            }, ...
          ]
        }, ...

      }
    },
    {
      "node": "node_dcid_2",
      "triples":
      {
        "property_of_node":
        {
          "nodes":
          [
            {
              "property_1": "value",
              "property_2": "value",
              ...
            }, ...
          ]
        }, ...
      }
    }, ...
  ]
}

Response fields

Name Type Description
node string DCID of the node queried.
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 outgoing triples for multiple nodes.

Get triples for the greenhouse gases carbon dioxide (DCID: CarbonDioxide) and methane (DCID: Methane), for edges going away from those nodes.

  • Request:

    $ curl --request GET --url \
    'https://api.datacommons.org/v1/bulk/triples/out?nodes=CarbonDioxide&nodes=Methane&key=AIzaSyCTI4Xz-UW_G2Q2RfknhcfdAnTHq5X5XuI'
    
  • Request:

    $ curl --request POST \
    --url https://api.datacommons.org/v1/bulk/triples/out \
    --header 'X-API-Key: AIzaSyCTI4Xz-UW_G2Q2RfknhcfdAnTHq5X5XuI' \
    --data '{"nodes":["CarbonDioxide", "Methane"]}'
    

Response:

{
  "data": [
    {
      "node": "CarbonDioxide",
      "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"
            }
          ]
        }
      }
    },
    {
      "node": "Methane",
      "triples": {
        "isProvisional": {
          "nodes": [
            {
              "name": "True",
              "types": ["Boolean"],
              "dcid": "True",
              "provenanceId": "dc/5l5zxr1"
            }
          ]
        },
        "name": {
          "nodes": [
            {
              "provenanceId": "dc/5l5zxr1",
              "value": "Methane"
            }
          ]
        },
        "provenance": {
          "nodes": [
            {
              "name": "https://datacommons.org",
              "types": ["Provenance"],
              "dcid": "dc/5l5zxr1",
              "provenanceId": "dc/5l5zxr1"
            }
          ]
        },
        "typeOf": {
          "nodes": [
            {
              "name": "ChemicalCompound",
              "types": ["Class"],
              "dcid": "ChemicalCompound",
              "provenanceId": "dc/5l5zxr1"
            },
            {
              "name": "GreenhouseGas",
              "types": ["Class"],
              "dcid": "GreenhouseGas",
              "provenanceId": "dc/5l5zxr1"
            }
          ]
        }
      }
    }
  ]
}

Example 2: Get incoming triples for multiple nodes.

Get triples for the greenhouse gases carbon dioxide (DCID: CarbonDioxide) and methane (DCID: Methane), for edges going towards those nodes.

  • Request:

    $ curl --request GET --url \
    'https://api.datacommons.org/v1/bulk/triples/in?nodes=geoId/51&nodes=CarbonDioxide&nodes=Methane&key=AIzaSyCTI4Xz-UW_G2Q2RfknhcfdAnTHq5X5XuI'
    
  • Request:

    $ curl --request POST \
    --url https://api.datacommons.org/v1/bulk/triples/in \
    --header 'X-API-Key: AIzaSyCTI4Xz-UW_G2Q2RfknhcfdAnTHq5X5XuI' \
    --data '{"nodes":["CarbonDioxide", "Methane"]}'
    

Response:

{
  "data": [
    {
      "node": "CarbonDioxide",
      "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"
            }
          ]
        }
      }
    },
    {
      "node": "Methane",
      "triples": {
        "contaminant": {
          "nodes": [
            {
              "name": "Whether Atmosphere is contaminated with Methane.",
              "types": ["StatisticalVariable"],
              "dcid": "IsContaminated_Methane_Atmosphere",
              "provenanceId": "dc/d7tbsb1"
            },
            {
              "name": "Whether EPA_OtherContaminatedThing is contaminated with Methane.",
              "types": ["StatisticalVariable"],
              "dcid": "IsContaminated_Methane_EPAOtherContaminatedThing",
              "provenanceId": "dc/d7tbsb1"
            },
            {
              "name": "Whether GroundWater is contaminated with Methane.",
              "types": ["StatisticalVariable"],
              "dcid": "IsContaminated_Methane_GroundWater",
              "provenanceId": "dc/d7tbsb1"
            },
            {
              "name": "Whether LandfillGas is contaminated with Methane.",
              "types": ["StatisticalVariable"],
              "dcid": "IsContaminated_Methane_LandfillGas",
              "provenanceId": "dc/d7tbsb1"
            },
            {
              "name": "Whether Leachate is contaminated with Methane.",
              "types": ["StatisticalVariable"],
              "dcid": "IsContaminated_Methane_Leachate",
              "provenanceId": "dc/d7tbsb1"
            },
            {
              "name": "Whether SoilGas is contaminated with Methane.",
              "types": ["StatisticalVariable"],
              "dcid": "IsContaminated_Methane_SoilGas",
              "provenanceId": "dc/d7tbsb1"
            },
            {
              "name": "Whether Soil is contaminated with Methane.",
              "types": ["StatisticalVariable"],
              "dcid": "IsContaminated_Methane_Soil",
              "provenanceId": "dc/d7tbsb1"
            },
            {
              "name": "Whether SolidWaste is contaminated with Methane.",
              "types": ["StatisticalVariable"],
              "dcid": "IsContaminated_Methane_SolidWaste",
              "provenanceId": "dc/d7tbsb1"
            }
          ]
        },
        "emittedThing": {
          "nodes": [
            {
              "name": "Annual Amount of Emissions: Non Biogenic Emission Source, Methane",
              "types": ["StatisticalVariable"],
              "dcid": "Annual_Emissions_Methane_NonBiogenic",
              "provenanceId": "dc/d7tbsb1"
            }
          ]
        }
      }
    }
  ]
}

Page last updated: December 17, 2024 • Send feedback about this page