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.
So to get next page you need to submit the endCursor of the previous page in the after . So for the first request omit after or submit empty string and then the next page can be accessed the value in the response payload. Looking at the script, the endCursor should be found at ptown['data']['search']['weekly_patterns']['results']['pageInfo']['endCursor'] . Use that value in after to get the next page
The json response doesn’t appear to be returning an end cursor
[1] "{\"data\":{\"search\":{\"places\":{\"results\":{\"edges\":[{\"node\":{\"safegraph_core\":{\"placekey\":\"222-222@63r-6bk-2x5\",\"latitude\":38.91756,\"longitude\":-76.964755,\"street_address\":\"2850 New York Ave NE\",\"city\":\"Washington\",\"region\":\"DC\",\"postal_code\":\"20002\",\"iso_country_code\":\"US\",\"parent_placekey\":null,\"location_name\":\"Washington Times The\",\"brands\":[],\"top_category\":null,\"sub_category\":null,\"naics_code\":3399,\"phone_number\":null,\"open_hours\":null,\"category_tags\":[],\"opened_on\":null,\"closed_on\":null,\"tracking_closed_since\":\"2019-07-01\",\"geometry_type\":\"POLYGON\"}}}]}}}},\"extensions\":{\"row_count\":1,\"version_date\":[\"safegraph_core: 1645948803__2022_02\",\"safegraph_geometry: 1645948803__2022_02\",\"safegraph_weekly_patterns2: 2022_01_11\",\"safegraph_monthly_patterns: 2022_01_11\"]}}"
Hello! Another problem we’re running into, is that we’re getting a bunch of rows back in the JSON that are all NULLS. Here’s the JSON response for five retailers in the 20002 zip area code:
[1] "{\"data\":{\"search\":{\"places\":{\"results\":{\"edges\":[{\"node\":{\"safegraph_core\":null}},{\"node\":{\"safegraph_core\":null}},{\"node\":{\"safegraph_core\":null}},{\"node\":{\"safegraph_core\":null}},{\"node\":{\"safegraph_core\":{\"placekey\":\"222-222@63r-6bk-4d9\",\"latitude\":38.917605,\"longitude\":-76.965407,\"street_address\":\"2800 New York Ave NE\",\"city\":\"Washington\",\"region\":\"DC\",\"postal_code\":\"20002\",\"iso_country_code\":\"US\",\"parent_placekey\":null,\"location_name\":\"Times Color Graphics\",\"brands\":[],\"top_category\":null,\"sub_category\":null,\"naics_code\":3399,\"phone_number\":\"+12026354035\",\"open_hours\":null,\"category_tags\":[],\"opened_on\":null,\"closed_on\":null,\"tracking_closed_since\":\"2019-07-01\",\"geometry_type\":\"POLYGON\"}}}]}}}},\"extensions\":{\"row_count\":1,\"version_date\":[\"safegraph_core: 1645948803__2022_02\",\"safegraph_geometry: 1645948803__2022_02\",\"safegraph_weekly_patterns2: 2022_01_11\",\"safegraph_monthly_patterns: 2022_01_11\"]}}"