batch_lookup allows you to retrieve details of multiple places in a single query. To retrieve details, submit an array of Placekeys as input. You will get details on up to 20 places in each response.

Generate Placekeys of the desired locations from here. Provide an array of Placekeys as query variables. You may request attributes from Safegraph Core, Geometry, or Pattern data sets.

Request Parameters

Parameter

Description

[placekeys]

Array of the Placekeys of the locations

Below is an example of submitting an array of Placekeys to obtain information. You may add up to 20 Placekeys in this array. Add the array under Query variables in the GraphiQL Explorer.

query($placekeys: [Placekey!]) {
  batch_lookup(placekeys: $placekeys) {
    placekey
    safegraph_core {
      location_name
      street_address
      city
      region
      postal_code
      iso_country_code
    }
  }
}
curl --location --request POST 'https://api.safegraph.com/v1/graphql' \
--header 'apikey: {your-api-key}' \
--header 'content-type: application/json' \
--data-raw '{"query":"query($placekeys: [Placekey!]) {\n  batch_lookup(placekeys: $placekeys) {\n    placekey\n    safegraph_core {\n      location_name\n      street_address\n      city\n      region\n      postal_code\n      iso_country_code\n    }\n  }\n}","variables":{"placekeys":["[email protected]","[email protected]","[email protected]","[email protected]","[email protected]"]}}'
# pip install safegraphQL
import safegraphql.client as sgql

sgql_client = sgql.HTTP_Client(apikey = 'your-api-key')

pks = [
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]",
    "[email protected]"
  ]
cols = [
    'location_name',
    'street_address',
    'city',
    'region',
    'postal_code',
    'iso_country_code'
]

sgql_client.lookup(product = 'core', placekeys = pks, columns = cols)
{
  "data": {
    "batch_lookup": [
      {
        "placekey": "[email protected]",
        "safegraph_core": {
          "location_name": "Patrick Baptist Church",
          "street_address": "2006 Parkinson Rd",
          "city": "Ferris",
          "region": "TX",
          "postal_code": "75125",
          "iso_country_code": "US"
        }
      },
      {
        "placekey": "[email protected]",
        "safegraph_core": {
          "location_name": "United States Postal Service (USPS)",
          "street_address": "317 E Main St",
          "city": "Edmore",
          "region": "MI",
          "postal_code": "48829",
          "iso_country_code": "US"
        }
      },
      {
        "placekey": "[email protected]",
        "safegraph_core": {
          "location_name": "Private Ink",
          "street_address": "333 Peterson Rd Ste 250",
          "city": "Libertyville",
          "region": "IL",
          "postal_code": "60048",
          "iso_country_code": "US"
        }
      },
      {
        "placekey": "[email protected]",
        "safegraph_core": {
          "location_name": "Little Italy Pizza Cafe",
          "street_address": "16A N State St",
          "city": "Greenfield",
          "region": "IN",
          "postal_code": "46140",
          "iso_country_code": "US"
        }
      },
      {
        "placekey": "[email protected]",
        "safegraph_core": {
          "location_name": "Tolenas Elementary",
          "street_address": "4500 Tolenas Rd",
          "city": "Fairfield",
          "region": "CA",
          "postal_code": "94533",
          "iso_country_code": "US"
        }
      }
    ]
  },
  "extensions": {
    "row_count": 5,
    "version_date": "1627739802__2021_07"
  }
}