Optimizing OpenRouteService API for Large Batch Requests

Hello everyone,

I’m currently working on a project that involves processing a large number of route calculations using the OpenRouteService API, and I’m running into some efficiency challenges. I’d love to get insights from the community on best practices for handling batch requests and optimizing response times.

Here’s my setup:

  • I’m using the /v2/directions/driving-car endpoint.
  • The dataset contains thousands of origin-destination pairs that need routing.
  • I’m running requests from a Python script using the requests library.
  • I have an API key with standard limits (not a premium plan).

A few issues I’ve encountered:

  1. Rate Limits & Throttling – Even when I introduce delays between requests, I occasionally get 429 errors. Are there any recommended strategies to handle this efficiently?
  2. Batch Processing – I know OpenRouteService supports batch requests, but I’m unsure how to structure my requests to maximize efficiency. Should I group routes in chunks of 50, 100, or some other number?
  3. Timeouts & Response Speed – Some requests take significantly longer than others. Could this be due to road network complexity, or are there settings I can tweak to improve performance?
  4. Alternative Hosting Options – Would running a local OpenRouteService instance be a good alternative for handling high-volume queries? If so, what hardware specs would be recommended?

I also read this: https://ask.openrouteservice.org/t/how-to-get-distance-using-api–openrouteservice-org-optimization-salesforce-cpq but didn’t get exact info.

I’d appreciate any advice, code snippets, or experiences you can share. Thanks in advance for your help!

Hey,

a few questions beforehand:

  1. What region are your origin-destination pairs in?
    Are they all in the same region/country/…, are there long distances between them, …
  2. Do you need the routes themselves, or could you work with distances/durations as a first step, calculating actual routes as needed?
  3. What do you mean by

Best regards