Overview
This article explains how to use the API to fetch an estimated time of arrival (ETA) from the ETA service for each stop of a booking. The fetched ETAs are ready to be shown in your customer app, on external tracking pages, or on a custom dashboard.
- Prerequisites
- Best practices for fetching ETAs for a single booking
- Best practices for fetching ETAs for multiple bookings
Prerequisites
- A valid API key has been created by an Admin via the MotionTools Dashboard.
- At least one booking has been created via the Dashboard or API.
Best practices for fetching ETAs for a single booking
- Subscribe to the hailing_booking.etas_recalculated webhook to receive an event every time an ETA is recalculated for a booking. Refer to ETA service page for more information on when ETAs are recalculated.
- Use the #EstimateBookingStopsArrivals endpoint to fetch the latest ETA for stops of the booking. The ETAs are returned as fixed timestamps in UTC indicating when a driver is expected to arrive at each stop. Note that the ETAs aren’t recalculated each time the endpoint is called.
- Refetch the ETAs once a webhook event is received for the booking.
Best practices for fetching ETAs for multiple bookings
- Subscribe to the hailing_booking.etas_recalculated webhook to receive an event every time an ETA is recalculated for a booking. Refer to ETA service page for more information on when ETAs are recalculated.
- Use the #ListBookings endpoint to fetch bookings for which you need to get ETAs.
- Use the #EstimateBookingsStopsArrivals endpoint to fetch ETAs in bulk for stops of each booking. The ETAs are returned as fixed timestamps in UTC indicating when a driver is expected to arrive at each stop. Note that the ETAs aren’t recalculated each time the endpoint is called.
- When a webhook event is received for one of the bookings you’re tracking, refetch the ETAs using the #EstimateBookingStopsArrivals endpoint.