Skip to content

Instantly share code, notes, and snippets.

@ampvchen
Last active November 22, 2021 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ampvchen/a02cfbe26146d4e14b560ebd3cd74daa to your computer and use it in GitHub Desktop.
Save ampvchen/a02cfbe26146d4e14b560ebd3cd74daa to your computer and use it in GitHub Desktop.
import os
import requests
headers = {
'Content-Type': 'application/json',
'apikey': os.environ['SGAPI']
}
query = """
query($after: Int, $date: DateTime) {
search(filter:{
address: {
city: "Los Angeles"
iso_country_code: "US"
}} first: 500, after: $after) {
placekey
safegraph_weekly_patterns(date: $date) {
poi_cbg
visitor_home_aggregation
}
}
}
"""
req = requests.post(
'https://api.safegraph.com/v1/graphql',
json={
'query': query,
'variables': { "first": 500, "after":0, "date":"2020-03-02"}
},
headers=headers
)
r_json = req.json()
for i in r_json['data']['search']:
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment