Hi thanks for your patience with all of my API questions. I’m trying to get pagination to work, but I keep getting the same results when I adjust the “after” filter in my request. I also noticed that the “after” filter takes in a string, not an int. I get this error when I try to run it as an int:
Output:
Out[29]: {'error': "Query does not pass validation. Violations:\n\nExpected type 'String', found '1000'. String value expected (line 9, column 42):\n results(first: 500, after: 1000) {\n
This is my request when I try to go forward in my search results. I’m getting the same locations every time.
import requests
import json
def sf_gql_request(params):
query = """
query($postal_code: String, $start_date: DateTime!, $end_date: DateTime!) {
search(filter: {
address: {
postal_code: $postal_code
}
}){
weekly_patterns(start_date: $start_date end_date: $end_date) {
results(first: 500, after: "1000") {
pageInfo { hasNextPage endCursor }
edges {
node {
placekey
location_name
postal_code
raw_visit_counts
normalized_visits_by_total_visits
normalized_visits_by_state_scaling
date_range_start
date_range_end
}
}
}
}
}
}
"""
req = requests.post(
'https://api.safegraph.com/v2/graphql',
json={
'query': query,
'variables': params
},
headers=headers
)
return req.json()
params = {
'start_date': '2020-01-06',
'end_date': '2020-01-11',
'postal_code': '94588',
'after': '500'
}
ptown = sf_gql_request(params)
ptown