Prerequisites
Before you begin, make sure you have:- A valid MileIQ access token (retrievable via the OAuth authentication flow)
- Python 3.9 or later installed
- The
requestslibrary installed (pip install requests) - The
pytzlibrary installed (pip install pytz)
Pagination Explanation
It’s important to note that the MileIQ External API doesn’t use traditional offset/limit pagination. Instead, it uses a timestamp-based pagination method. To paginate through the results, you need to use themodified_before and modified_after parameters in conjunction with the has_more field in the response body.
Here’s how it works:
- In your initial request, you set
modified_afterto the start of your desired date range andmodified_beforeto the end of the range. - The API returns a batch of results and a
has_moreboolean indicating if there are more results to fetch. - If
has_moreis true, you make another request, but this time you setmodified_beforeto themodifiedtimestamp of the last drive in the previous batch. - You repeat this process until
has_moreis false or you’ve retrieved all the drives you need.