Starting and completing a Route

You have created a route and populated it with stops. Now you are ready to go, so let's start the route.

Starting a route

As always, you need your API key, and route ID. Once you have those, you are already almost done. Starting a route is as simple as making a PUT request to the Start Route endpoint. No need for any body or query parameters, just put the route ID in the endpoint URL, and the API key in the header (as always) and you are good to go.

import requests

route_id = "WW91ciBjaG9zZW4gUm91dGUgSUQ="

url = "https://platform-api.wastehero.io/api/v3/route/" + route_id + "/start"

headers = {
    "Accept": "application/json",
    "X-API-Key": "YOUR-API-KEY-HERE"
}

response = requests.put(url, headers=headers)

print(response.text)

Completing a stop

Completing a stop is only slightly more complicated than starting (and completing, see below) a route. When completing a stop you need not only the route ID; but also the ID of the stop you are completing. If you have followed this guide, you should have a list of all your stops. If not, see Get route information to learn how to get the information you need.

When completing a stop you can add a payload to the request body. This payload can contain information about the stop, such as fill level and time completed. For full details about the payload see Complete Stop On Route.

🚧

Optional Prerequisites

In the case of additional data (stop_data) that can be added when a stop is completed, you need to have a correct setup of a route scheme for your route. Data for a route scheme can be configured under Operation Management -> Route Scheme on the WasteHero platform.

Note, that when the configuration is not done correctly, the values sent with the request will not be saved.

import requests

route_id = "WW91ciBjaG9zZW4gUm91dGUgSUQ="
stop_id = "VGhpcyBpcyBhIHN0b3BfaWQ="

url = "https://platform-api.wastehero.io/api/v3/route/" + route_id +  "/" + stop_id + "/complete"

headers = {
    "Accept": "application/json",
    "X-API-Key": "YOUR-API-KEY-HERE"
}
payload = {
    "stop_data": {
        "completed_at": "2022-09-01",
        "weight": 55,
        "fill_level": 60
    }
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)

πŸ“˜

No payload is necessary

The Complete stop on route API call does not require a payload. You do not need to send anything if you don't have something to add

Sometimes it's not possible to complete the stop, or something happens that needs further action. For these cases, it is possible to attach a ticket to the stop. To do this you must first create a ticket (see Create ticket for how to do this). Once you have created your ticket, you should have a ticket ID. Add this to the payload under the "with_ticket" keyword as "ticket_id". If the stop was not completed properly, set the "ticket_id_stop_completed" value to False, and if the stop was successful set it to True

import requests

route_id = "WW91ciBjaG9zZW4gUm91dGUgSUQ="
stop_id = "VGhpcyBpcyBhIHN0b3BfaWQ="

url = "https://platform-api.wastehero.io/api/v3/route/" + route_id +  "/" + stop_id + "/complete"

headers = {
    "Accept": "application/json",
    "X-API-Key": "YOUR-API-KEY-HERE"
}
payload = {
  "with_ticket": {"ticket_id": "VGlja2V0IElEIGhlcmU="
                  "ticket_id_stop_completed": False}
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)

Completing a route

To complete a route is nearly the same as starting a route. The only difference is the endpoint (replace "start" with "complete" in the URL and you are set). See Complete Route for more info.

import requests

route_id = "WW91ciBjaG9zZW4gUm91dGUgSUQ="

url = "https://platform-api.wastehero.io/api/v3/route/" + route_id + "/complete"

headers = {
    "Accept": "application/json",
    "X-API-Key": "YOUR-API-KEY-HERE"
}

response = requests.put(url, headers=headers)

print(response.text)

What’s Next

Last thing we need to learn: how to rearrange the route.