Welcome to our tutorial about creating a simple API request with Postman. If you are testing the capabilities of SmartMonkey this is a good way to start.

Go to https://www.getpostman.com/downloads/ and download Postman for your system (available for Mac OSX, Windows and Linux). 

First download and install Postman on your system.

1. Get your SmartMonkey API Key

After installing Postman on your computer we will need the SmartMonkey API Key. To find your key go to Flake keys page (https://flake.smartmonkey.io) and select one of your Keys to access to the Key detail page. If you don't have an account yet first you need to register.

Flake keys page

On the key detail page you can see the full API key string to copy it.

Flake. Key details page

Don't forget to select all the characters including the last two equal signs ("==").

Select API key to copy it to Postman

We will use a POST request with the following URL:

https://services.smartmonkey.io/api/v1/optimize?key=YOUR_API_KEY

2. Make a Request with Postman

In Postman paste the copied API Key into the URL field as a parameter after the services:

Enter SmartMonkey Key into Postman

Postman will show the key on the Params Tab:

Postman displays API Keu

In the Body Tab in Postman please enter following JSON code:

{
  "vehicles": [ // Define the vehicles
    {
      "capacity": [84, 71],
      "timewindow": [32400, 57600],
      "start": {
        "lat": 41.374752,
        "lng": 2.14145
      },
      "provides": ["coke", "beer", "sprite"],
      "end": {
        "lat": 41.374752,
        "lng": 2.14145
      },
      "id": "v97499"
    }
  ],
  "services": [ // Define the services
    {
      "requires": ["beer"],
      "timewindows": [[28800, 61200]],
      "location": {
        "lat": 41.376458,
        "lng": 2.128609
      },
      "duration": 1800,
      "reward": 100,
      "optional": true,
      "id": "s2557",
      "size": [7, 5]
    }
  ]
}

This is an example of JSON Input. If you want more examples about the API capabilities check the input section in the documentation.

Select RAW and JSON options in the Body Tab.

Insert JSON code into Postman (Tab Body, raw)

Run the request pressing the button "SEND" and you'll get an Output.

If you get an error message as an Output, please refer to our documentation for more details.

3. The Output

One way to visualize the output of the Optimization is to see it directly in Flake. Flake visualizes the routes with an interactive map. There you can select the different routes, stops and inspect their details.

Result of the optimization in Flake

Postman gets the Output and writes it on the area below. It should look similar to this:

Postman: Output of the Route Optimizer request. 

The most important Output of the optimizer is the geometry polyline:

e_p{FkgaLiBAChCAhAAnBA\[email protected][email protected]|[email protected]@[email protected]@[email protected]@[email protected]|[email protected]@[email protected]\[email protected]@[email protected]}[email protected]@[email protected]@[email protected]@[email protected]@_BBuD?{@[email protected]]zAQxB][email protected]}[email protected]?

The geometry polyline is an Encoded polyline with coordinates that show a route.

You can use our tool Geotools for Visual Studio Code to display the polyline:

Example of polyline visualisation

If you have questions about our API we are happy to help you on [email protected] or our Chat within Flake.