Hello! I’m trying to get my head around the usage ...
# troubleshooting
g
Hello! I’m trying to get my head around the usage of HATEOAS Pagination from the SDK docs. However, I have some questions about the example used:
Copy code
# New implementation

from singer_sdk.pagination import BaseHATEOASPaginator

class MyPaginator(BaseHATEOASPaginator):
    def get_next_url(self, response, previous_token):
        data = response.json()
        return data.get("next")


class MyStream(RESTStream):
    def get_new_paginator(self) -> RESTPaginator:
        return BaseHATEOASPaginator()

    def get_url_params(self, context, next_page_token):
        params = {}

        # Next page token is a URL, so we can to parse it to extract the query string
        if next_page_token:
            params.update(parse_qsl(next_page_token.query))

        return params
MyPaginator
doesn’t appear to be used after it is defined - should it be used in the
get_new_paginator
method? •
RESTPaginator
isn’t imported - I’m assuming this is from
singer_sdk.pagination
too? •
parse_qsl
isn’t imported in this example - including for completeness but this is an easy fix. Thanks in advance 😄
o
Hi Gemma 👋 I just faced this issue as well. • Your
get_new_paginator
method should return a
MyPaginator
object, not the
BaseHATEOASPaginator
• I'm not sure about the
RESTPaginator
. I was able to return a
BaseHATEOASPaginator
object from my
get_new_paginator
method, because that's what the
MyPaginator
class is derived from.
g
Thanks - really appreciate your help here. That’s what it seemed like, so I’ll give it a go.
e
Yeah, a few errors in that example but it seems like you folks got it sorted out 👍