In this tutorial, you'll learn how to use SmartMonkey's API on Python in a few minutes!

You'll need

cars passing through north and south
Photo by Alexander Popov / Unsplash

Optimize your route

You can optimize your route following these steps:

  1. Import SmartMonkey library
  2. Initialize SmartMonkey's client with your API Key (get it here)
  3. Describe the vehicles
  4. Describe the services (stops)
  5. Optimize
  6. Print result

It can be done as follows:

After executing this code you'll obtain an output like:

You'll find the routes find by the optimizer inside the solutions attribute. These routes contain a series of steps with arrival and departure time, distance and id of the stop. Also, the geometry of the route is provided so it can be displayed on a map as follows:

Obtained route

Congratulations, that's it! You've managed to optimize your first route! Try it yourself with your own places. You can now define more restrictions, just check the documentation to learn more.

In trouble? Feel free to contact us at [email protected]

You may also be interested in our Geo Tools extension for Visual Studio Code.