Hello. I'm trying to set up a cursor pagination fo...
# help-connector-development
g
Hello. I'm trying to set up a cursor pagination for an API. Everything is working fine, but the next page in the pagination is a link with the next page ID. However, helpfully, the API will only accept the ID, it doesn't want the entire url. I need to extract the id, from, for example: https://api.example.com/payments?from=ID. Does anyone know how i would split this field to just return the ID?
k
A message from kapa.ai
To extract the ID from the URL, you can use the "custom" option for obtaining the next page cursor in the Connector Builder. You can access the URL using the
{{ response }}
or
{{ headers }}
object, depending on where the URL is located in the API response. Here's an example of how you can extract the ID from the URL: 1. Set the cursor value to the URL, for example:
{{ response['next_page_url'] }}
. 2. Use a custom Jinja expression to extract the ID from the URL. You can use the
split
function to split the URL by the
=
character and then access the second part (the ID) using the index
[1]
. Here's an example of how the cursor value expression would look like:
Copy code
{{ response['next_page_url'].split('=')[1] }}
This expression will split the URL by the
=
character and return the ID part. For more information on cursor pagination in Airbyte, you can refer to the following sources: - [Cursor Pagination in Connector Builder UI](https://docs.airbyte.com/connector-development/connector-builder-ui/pagination#cursor-pagination) - [Cursor Pagination in Config-based YAML file](https://docs.airbyte.com/connector-development/config-based/understanding-the-yaml-file/pagination#cursor-pagination)