Get records synchronously by date range
This code snippet shows you how to retrieve a set of records using a date range. This is a synchronous call, and so will block until it returns a response. It is used where you want to return a limited number of records (thousands) immediately. If you want to obtain large numbers of records (millions) use Create Report.
Date ranges are limited to a window of 24 hours for synchronous queries.
Example
| Key | Description |
|---|---|
VONAGE_API_KEY | Your Vonage API key (see it on your dashboard). |
VONAGE_API_SECRET | Your Vonage API secret (also available on your dashboard). |
ACCOUNT_ID | The account ID (same as |
REPORT_DIRECTION | Either |
REPORT_PRODUCT | Specifies the product for which reports and records are obtained. Can be one of |
DATE_START | Date of time window from when you want to start gathering records in ISO-8601 format. |
DATE_END | Date of time window from when you want to stop gathering records in ISO-8601 format. |
Run your code
Save this file to your machine and run it:
Try it out
Set the replaceable variables for your account.
For this example, set
REPORT_PRODUCTtoSMS.Using the table as a guide set values for the remaining variables.
Run the script and you receive a response similar to the following: