mahesh_kalani
12/02/2023, 1:39 PM/query endpoint. This is how pagination is supported. I am clueless about how to make this happen in my custom tap development.
import requests
import json
url = "<https://api.domain.com/v4/endpoint/query>"
payload = json.dumps({
"options": {
"page": 2
}
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
output of above request give back below details along with data
"totalDocs": 205,
"limit": 10,
"totalPages": 21,
"page": 2,
"hasPrevPage": true,
"hasNextPage": true,
"prevPage": 1,
"nextPage": 3
FYI , to get data without pagination , i have to make /GET request without any payloadHenning Holgersen
12/02/2023, 8:45 PMmahesh_kalani
12/02/2023, 11:51 PMmahesh_kalani
12/03/2023, 12:29 AMHenning Holgersen
12/03/2023, 11:17 AMprepare_request_payload , but the principle is the same. And you need to specify rest_method="POST" in the stream class, like this: https://github.com/radbrt/tap-prefect/blob/85428f4443700fa53a49d5d5e072968f783ea441/tap_prefect/streams.py#L46
I see that class also has a prepare_request_payload method you can look at.edgar_ramirez_mondragon
12/04/2023, 5:15 PMfrom singer_sdk.pagination import BasePageNumberPaginator
class MyAPIPaginator(BasePageNumberPaginator):
def has_more(self, response):
data = response.json()
return data["totalDocs"]["hasNextPage"]
class MyStream(RESTStream):
def get_new_paginator(self):
return MyAPIPaginator(start_value=1) # first page is 1
https://sdk.meltano.com/en/latest/reference.html#paginationmahesh_kalani
12/04/2023, 5:55 PM