Passing current datetime in request parameter in Builder API

Summary

Exploring how to include the current datetime in a request parameter for the Builder API in Airbyte


Question

<@U04SE163WC8>
How can i pass current datetime in request parameter in builder api airbyte



This topic has been created from a Slack thread to give it more visibility.
It will be on Read-Only mode here. Click here if you want to access the original thread.

Join the conversation on Slack

["passing-current-datetime", "request-parameter", "builder-api", "airbyte"]

In Airbyte, you can pass the current datetime in the request parameter using the incremental sync feature in the connector builder. This feature allows you to specify how the records will represent the “last changed” / “updated at” timestamp, the initial time range to fetch records for, and how to request records from a certain time range. Here’s how you can do it: - The “Cursor field” is the property in the record that defines the date and time when the record got changed. It’s used to decide which records are synced already and which records are “new”. - The “Datetime format” specifies the format the cursor field is using to specify date and time. Check out the YAML reference for a full list of supported formats. - The “Start datetime” is the initial start date of the time range to fetch records for. When doing incremental syncs, the second sync will overwrite this date with the last record that got synced so far. - The “End datetime” is the end date of the time range to fetch records for. In most cases, it’s set to the current date and time when the sync is started to sync all changes that happened so far. - The “Inject start/end time into outgoing HTTP request” defines how to request records that got changed in the time range to sync. In most cases, the start and end time is added as a query parameter or body parameter. For more details, you can refer to the Incremental Sync Configuration section in the Airbyte documentation.

<@U04SE163WC8>
I am using builder of airbyte to sync api data.
My api takes start and end date as query params. So, i used user input field to get start and end date which is added manually. But i want end date to be current date, so how can i add current date in enddate user input or request params

A message from http://kapa.ai|kapa.ai

In Airbyte, you can set the end date to the current date when configuring incremental syncs. This is done by setting the “End datetime” to the current date and time when the sync is started. This will sync all changes that happened up to the current date. However, if you need to inject the current date into the URL path or as a query parameter, you can use the stream_interval.end_time placeholder. This placeholder represents the end time of the interval that’s currently being synced. Here’s an example of how you can use it: yaml query: end_date: "{{ stream_interval.end_time }}" In this example, end_date is the query parameter that your API uses to specify the end date. The {{ stream_interval.end_time }} placeholder will be replaced with the current date when the sync is started. For more details, you can refer to the Incremental Sync Example and Custom Parameter Injection sections in the Airbyte documentation.

Hi <@U05HW0ZEB9T>, you just need to use {{ today_utc() }} method. You just use normal Jinja Template configuraiotn if you want to give the timestamp a format (strftime for example)