Prerequisites
Before you begin, make sure you have:- A MileIQ API key
- Python 3.9 or later installed
- The
requests
library installed (pip install requests
) - The
pytz
library 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_after
to the start of your desired date range andmodified_before
to the end of the range. - The API returns a batch of results and a
has_more
boolean indicating if there are more results to fetch. - If
has_more
is true, you make another request, but this time you setmodified_before
to themodified
timestamp of the last drive in the previous batch. - You repeat this process until
has_more
is false or you’ve retrieved all the drives you need.