Retrieve visitor behavior for a list of POIs using batch_lookup and the relevant Placekeys. See the Weekly Patterns documentation for more details on each field.

query($placekeys: [Placekey!]) {
  batch_lookup(placekeys: $placekeys) {
    placekey
    safegraph_weekly_patterns (date: "2021-07-19") {
      location_name
      street_address
      city
      region
      date_range_start
      date_range_end
      raw_visit_counts
      raw_visitor_counts
      visits_by_day
    }
  }
}
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_weekly_patterns (date: \"2021-07-19\") {\n      location_name\n      street_address\n      city\n      region\n      date_range_start\n      date_range_end\n      raw_visit_counts\n      raw_visitor_counts\n      visits_by_day\n    }\n  }\n}","variables":{"placekeys":["[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]"
  ]
cols = [
    'location_name',
    'street_address',
    'city',
    'region',
    'date_range_start',
    'date_range_end',
    'raw_visit_counts',
    'raw_visitor_counts',
    'visits_by_day'
]

sgql_client.lookup(product = 'weekly_patterns', date = '2021-07-19', placekeys = pks, columns = cols)
{
  "data": {
    "batch_lookup": [
      {
        "placekey": "[email protected]",
        "safegraph_weekly_patterns": {
          "location_name": "Patrick Baptist Church",
          "street_address": "2006 Parkinson Rd",
          "city": "Ferris",
          "region": "TX",
          "date_range_start": "2021-07-19T00:00:00-05:00",
          "date_range_end": "2021-07-26T00:00:00-05:00",
          "raw_visit_counts": 20,
          "raw_visitor_counts": 7,
          "visits_by_day": [
            1,
            0,
            7,
            1,
            0,
            2,
            9
          ]
        }
      },
      {
        "placekey": "[email protected]",
        "safegraph_weekly_patterns": {
          "location_name": "United States Postal Service (USPS)",
          "street_address": "317 E Main St",
          "city": "Edmore",
          "region": "MI",
          "date_range_start": "2021-07-19T00:00:00-04:00",
          "date_range_end": "2021-07-26T00:00:00-04:00",
          "raw_visit_counts": 14,
          "raw_visitor_counts": 9,
          "visits_by_day": [
            2,
            4,
            2,
            0,
            4,
            1,
            1
          ]
        }
      },
      {
        "placekey": "[email protected]",
        "safegraph_weekly_patterns": {
          "location_name": "Pier 39",
          "street_address": "39 Pier 39",
          "city": "San Francisco",
          "region": "CA",
          "date_range_start": "2021-07-19T00:00:00-07:00",
          "date_range_end": "2021-07-26T00:00:00-07:00",
          "raw_visit_counts": 665,
          "raw_visitor_counts": 594,
          "visits_by_day": [
            90,
            72,
            76,
            96,
            90,
            126,
            115
          ]
        }
      }
    ]
  },
  "extensions": {
    "row_count": 3,
    "version_date": "1627739802__2021_07"
  }
}