jeffrey_lewis
06/23/2023, 1:31 PMrecords_jsonpath = "$[*]" # Or override `parse_response`.
# Set this value or override `get_new_paginator`.
next_page_token_jsonpath = "$.results.id" # noqa: S105
my get_url_params method:
params: dict = {}
if next_page_token:
params["startingAfter"] = next_page_token
these are the only real changes i've made in my client.pyReuben (Matatika)
06/23/2023, 2:23 PMpagination.py
class ruddrPaginator(BaseAPIPaginator):
def get_next(self, response):
body: dict = response.json()
hasMore = body.get("hasMore")
# if no more results, stop pagination
if not hasMore:
return
# leverage JSONPathPaginator to lookup the id of the last result
return JSONPathPaginator("$.results[-1:].id").get_next(response)
client.py
def get_new_paginator(self):
return ruddrPaginator()
This is similar to what we do in `tap-auth0`:
https://github.com/Matatika/tap-auth0/blob/5f9e34e7d705fe9a72bec6be28a9b4cf53bc4fc4/tap_auth0/pagination.py
https://github.com/Matatika/tap-auth0/blob/5f9e34e7d705fe9a72bec6be28a9b4cf53bc4fc4/tap_auth0/client.py#L38-L39jeffrey_lewis
06/23/2023, 2:25 PMjeffrey_lewis
06/23/2023, 2:27 PMreturn JSONPathPaginator("$.results[-1:].id").get_next(response)
Reuben (Matatika)
06/23/2023, 2:27 PMclient.py
I think you want to set your records_jsonpath
property to $.results
to just return the objects from results
.jeffrey_lewis
06/23/2023, 2:28 PMReuben (Matatika)
06/23/2023, 2:29 PMjeffrey_lewis
06/23/2023, 7:54 PMReuben (Matatika)
06/23/2023, 10:16 PM$.results[-1:].id
, if you want the last result id
. Currently, the expression probably isn't matching anything in the response body, so None
is returned.jeffrey_lewis
06/24/2023, 1:14 AMjeffrey_lewis
06/24/2023, 1:15 AMreturn JSONPathPaginator("$.results[-1:].id").get_next(response)
Reuben (Matatika)
06/24/2023, 9:14 AM