Time Parameters in API Data Source
The attributes under Time Parameters of Data Source API are:
- Today Format
- Yesterday Format
- Rolling Time Format
- Rolling Frequency
- Time Offset Value
These parameters are needed when the user does not have any means of retrieving data from an API with a given time window. Below are the cases where API architecture has shortfall in retrieving data:
User needs to retrieve data between two time windows. Example: From current timestamp to last 1 hour or last 15 minutes etc.
User needs to retrieve data from yesterday’s transactions only and the API does not provide any means to filter dynamically.
User needs to retrieve data from today’s transactions only and the API does not provide any means to filter dynamically.
User needs to retrieve the data by adjusting the Time Zone with dataset time-based attributes like create_date, update_date, invoice_date, due_date etc.
There are four reserved keywords which can be used in any API request to filter the time-based data. These keywords can be used in API params, headers, JSON body, pre-request scripts, etc. of any API request call:
Keywords: today, yesterday, min_time, max_time
Today Format
A date format that returns today’s date. Use the keyword today with any date field in the dataset:
invoice_date = {%today%}
Yesterday Format
A date format that returns previous day’s date. Use the keyword yesterday with any date field:
invoice_date = {%yesterday%}
Rolling Time Format
A date format that matches the attribute format which the user needs to filter data based on a time window. Example: Filter invoices for past 15 minutes:
%Y-%m-%dT%H:%M:00.000
Rolling Frequency
The time window in seconds between the current timestamp and frequency input by the user. Example: 900 seconds = Rolling 15 minutes based on invoice_date.
Time Offset Value
Time Offset Value is a numerical representation of the time difference between two points in time (in seconds). Used for time zone conversions, scheduling, and calculating durations between events.
Example Queries with Keywords
Example 1: Use today and yesterday in JSON body:
"query": "SELECT * FROM table_name WHERE column_name = '{%today%}' OR column_name = '{%yesterday%}'"
Example 2: Use min_time and max_time in JSON body:
"query": "SELECT * FROM table_name WHERE column_name BETWEEN '{%min_time%}' AND '{%max_time%}'"
Example GET request using time window:
GET https://example.com/api/orders?start_date={%min_time%}&end_date={%max_time%}
