May 6, 2020 • 3 min read

How to Add On-Demand Delivery to your Ridehail Service

rideOS recently launched Adapt Delivery, a free program providing delivery services for local businesses. In addition, we also announced our partnership with Alto, to support both ride share and delivery services in Dallas. Starting with this post, I’ll show how you can leverage rideOS fleet optimization APIs to satisfy several delivery use cases, while still maintaining your customized frontend UI. In the first part of the series, I’ll discuss on-demand delivery.

On-Demand Delivery

The concept behind on-demand delivery is quite simple: you send each delivery request to a driver whenever a customer creates an order. This is called “on-demand” because you do not know when these delivery requests will come in and have no idea where the pick up and drop off location will actually be. One can design an on-demand system for food, grocery, prescription and other goods.

rideOS provides routing, fleet optimization and ridehail APIs that can easily manage your mobility business. I’ll demonstrate how to leverage rideOS’ RideHail API to satisfy two different delivery requests, each with a different pick up and drop off location and assuming only one vehicle in the fleet. The scenario looks like this:

  1. Customer Peter orders a Deluxe Sandwich from Chick-fil-A on your app and requests home delivery.
  2. rideOS assigns Peter’s request to Vehicle A.
  3. While Vehicle A is on its way to pick up the sandwich for Peter, customer Felix also orders 2 burritos from Chipotle on your app. His request is also dispatched to Vehicle A because it has capacity.
  4. Based on the updated requests in the list, rideOS’ fleet optimization algorithm minimizes total travel time and selects the optimal path to first pick up Peter’s order at Chick-fil-A, then pick up Felix’s order at Chipotle, then drop off Peter’s sandwich then finally drop off Felix’s burritos.

Now, let me show you the code!

Initial setup

Before we start taking customer requests, we need to create a fleet and add Vehicle A to it. We only need to set this up once for each fleet.


You can sign up for one here and view it on your profile page, then assign it to the API_KEY variable below:

You are now ready to handle your first order!

Step 1 to 2: Handling the First Order

Customer Peter orders the Deluxe Sandwich using your app, and the delivery request is assigned to Vehicle A based on rideOS’ fleet optimization algorithm.


on-demand-delivery-ordering-peter ordering


Step 3: Route to Pick Up the First Order

Based on the pickup and dropoff locations, rideOS automatically plans the best route for Vehicle A.

on-demand-delivery-ordering-pickup Peters item


Step 4 to 5: Handling the Second Order

rideOS assigns Vehicle A to handle Felix’s request since Vehicle A has enough capacity to pick up another item.


Copy of RideHail API for On Demand Delivery



Step 6 to 9: Merging Two Deliveries with the Optimal Route

rideOS dynamically changes Vehicle A’s route based on newly-added requests. In this case, after Felix’s request is added, rideOS’ fleet optimization algorithm recalculates the optimal route and decides the next stop after the Chick-fil-A pickup will be to also pick up Felix’s order from Chipotle, then drop off Peter’s order and finally drop off Felix’s order.

Copy of RideHail API for On Demand Delivery-2




That's all there is to it! You have now successfully configured your fleet with a vehicle to handle on demand orders that contain multiple pickup and dropoff locations by leveraging rideOS’ RideHail API. The RideHail API automatically adjusts the optimal route based on incoming requests. Depending on your use case, if all the dropoffs are pre-scheduled (eg. not based on demand), you may want to do batch delivery like UPS to maximize overall fleet utilization. I’ll discuss how to achieve batch delivery in a future post.

I hope you find this tutorial helpful. You can find the complete code here. As we are at the beginning stages of this new capability, your feedback is appreciated. Please follow us on twitter and reach out to if you have any questions!