Getting Ticket Data

Getting information about a ticket is very straightforward and involves calling either one of two endpoints - one for getting all the tickets, and the other one for getting only the selected ticket.

📘

Examples below

The examples below are written in Python and are using requests library for communication with the API. The response from the API will be represented as JSON.

The examples below were tested, and they do work, so you can easily follow along.

🚧

API Keys

The API keys used in the examples below are random, and they do not work - use your own API keys.

Getting all tickets

The URL that the API request has to be sent to is https://platform-api.wastehero.io/api/v3/ticket/ and next to the X-API-Key in the header, an accept and/or content-type is required.

Because we want to get all tickets data, we are going to use Get Tickets

In this case, the endpoint also allows us to paginate the results - meaning we can specify the range from which we want to get the tickets' data. The pagination is achieved by sending the limit and offset fields as params. The values provided in these fields have to be integers.

By default, the pagination is set to limit = 10 and offset = 0. The limit cannot exceed 50 for performance reasons. So if you want to get all of your tickets, you have to adjust the offset accordingly and make several calls.

🚧

Response time

Note that in some cases, the response may take some time - especially if you requested all ticket data.

import requests

url = "https://platform-api.wastehero.io/api/v3/ticket/"

headers = {
    "accept": "application/json",
  	"content-type": "application/json",
    "X-API-Key": "<YOUR-API-KEY-HERE>"
}

params = {
	"limit": 10,
	"offset": 0
}

response = requests.get(url, params=params, headers=headers)

print(response.json())
curl --request GET \
     --url 'https://platform-api.wastehero.io/api/v3/ticket/?limit=10&offset=20' \
     --header 'X-API-Key: <YOUR-API-KEY-HERE>' \
     --header 'accept: application/json'

The successful response (200) payload that you get back should look like this (of course multiplied by the number of tickets that you wanted to get).

[
  "items": [
    {
      "ticket_type": {
        "id": "string",
        "name": "string",
        "service_type": "string"
      },
      "property": {
        "location": {
          "longitude": 0,
          "latitude": 0,
          "name": "string"
        },
        "unique_number": "string",
        "note": "string",
        "meta_data": {},
        "created_at": "2022-08-31T10:24:18.022Z"
      },
      "location": {
        "longitude": 0,
        "latitude": 0,
        "name": "string"
      },
      "container": {
        "container_type": {
          "project": {
            "id": "string",
            "name": "string",
            "description": "string",
            "creating_demo_data": false
          },
          "pickup_setting": {
            "id": "string",
            "project": {
              "id": "string",
              "name": "string",
              "description": "string",
              "creating_demo_data": false
            },
            "name": "string",
            "pickup_method": "string",
            "container_status": "string",
            "emptying_interval_from": "string",
            "emptying_interval_to": "string",
            "exclude_days": [
              "string"
            ],
            "fixed_pickups_period": "string",
            "pickup_interval": "string",
            "pickup_repeat_period": 0,
            "allowed_hours_from": "string",
            "allowed_hours_to": "string",
            "amount_days_between_pickups": 0,
            "minimum_days_between_pickup": 0,
            "collection_per_week": 0,
            "first_collection": "2022-08-31"
          },
          "name": "string",
          "emplacement": "string",
          "mobility": "string",
          "vehicle_coupling": [
            "string"
          ],
          "container_access": "string",
          "emptying_time": 0,
          "width": 0,
          "height": 0,
          "length": 0,
          "diameter": 0,
          "is_cylindrical": false
        },
        "container_group": {
          "project": {
            "id": "string",
            "name": "string",
            "description": "string",
            "creating_demo_data": false
          },
          "location": {
            "longitude": 0,
            "latitude": 0,
            "name": "string"
          },
          "created_at": true,
          "name": "string",
          "updated_at": "string"
        },
        "stored_at_depot": {
          "id": "string",
          "location": {
            "longitude": 0,
            "latitude": 0,
            "name": "string"
          },
          "name": "string",
          "description": "string",
          "geofence_radius": 0,
          "opening_time": "string",
          "closing_time": "string",
          "time_to_unload_truck": "string",
          "time_to_leave_the_facility": "string",
          "amount_of_trucks": 0,
          "capacity_of_trucks": 0,
          "workshop_service_description": "string",
          "workshop_type": "string"
        },
        "location": {
          "longitude": 0,
          "latitude": 0,
          "name": "string"
        },
        "waste_fraction": {
          "id": "string",
          "project": {
            "id": "string",
            "name": "string",
            "description": "string",
            "creating_demo_data": false
          },
          "name": "string",
          "waste_type": "string",
          "waste_category": "string",
          "waste_substance": "string",
          "weight_factor": 0
        },
        "project": {
          "id": "string",
          "name": "string",
          "description": "string",
          "creating_demo_data": false
        },
        "measurement": {
          "fill_level_measurement_meta": {
            "created_at": "2022-08-31T10:24:18.022Z",
            "protocol": "string",
            "json_version": 0,
            "transmit_count": 0,
            "gwt": "",
            "battery_level": 0,
            "rsi": 0,
            "register_time": 0,
            "snr": 0,
            "header_version": 0,
            "text": "string",
            "ccid": "string",
            "crc": "string",
            "act": "string",
            "oper": "string",
            "ch": 0,
            "cid": "string",
            "lac": "string",
            "ant": "string",
            "old_status_code": 0,
            "battery_percentage": 0
          },
          "fill_level": 0,
          "raw_measurements": [
            0
          ],
          "fill_percentage": 0,
          "temperature": 0,
          "dev_id": "",
          "created_at": "2022-08-31T10:24:18.022Z"
        },
        "container_id": "string",
        "status": "string",
        "allowed_hours_start": "string",
        "allowed_hours_end": "string",
        "description": "string",
        "show_on_route": false,
        "pickup_method": "string",
        "sensor_fill_level": 0,
        "prioritize_in_start_of_route": false,
        "updated_at": "2022-08-31T10:24:18.022Z",
        "created_at": "2022-08-31T10:24:18.022Z"
      },
      "assignee": {
        "id": "string",
        "active_token": "string",
        "external_crm_id": "string",
        "phone_number": "string",
        "language": "string",
        "is_sms": false,
        "is_email": false,
        "is_push": true,
        "created_at": "2022-08-31T10:24:18.022Z",
        "updated_at": "2022-08-31T10:24:18.022Z",
        "demo_expire_date": "2022-08-31",
        "is_superuser": false,
        "is_demo": false,
        "is_reseller": false,
        "is_master": false,
        "is_beta": false,
        "active_projects": [
          0
        ]
      },
      "requested_by": {
        "anonymous": false,
        "token": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "name": "string",
        "email": "string",
        "phone_number": "string",
        "phone_number_token": "string",
        "language": "string",
        "created_at": "2022-08-31T10:24:18.022Z"
      },
      "status": 0,
      "priority": 0,
      "description": "string",
      "migrated_from_id": "string",
      "time_spent": 0,
      "waste_weight_estimate": 0,
      "waste_volume_estimate": 0,
      "deadline": "2022-08-31T10:24:18.022Z",
      "requested_by_other": "string",
      "preferred_date": "2022-08-31",
      "ignore_service_fee": false,
      "id": "string",
      "created_at": "2022-08-31T10:24:18.022Z",
      "updated_at": "2022-08-31T10:24:18.022Z",
      "reporter": {
        "id": "string",
        "active_token": "string",
        "external_crm_id": "string",
        "phone_number": "string",
        "language": "string",
        "is_sms": false,
        "is_email": false,
        "is_push": true,
        "created_at": "2022-08-31T10:24:18.022Z",
        "updated_at": "2022-08-31T10:24:18.022Z",
        "demo_expire_date": "2022-08-31",
        "is_superuser": false,
        "is_demo": false,
        "is_reseller": false,
        "is_master": false,
        "is_beta": false,
        "active_projects": [
          0
        ]
      },
      "status_open_at": "2022-08-31T10:24:18.022Z",
      "status_pending_at": "2022-08-31T10:24:18.022Z",
      "status_on_hold_at": "2022-08-31T10:24:18.022Z",
      "status_in_progress_at": "2022-08-31T10:24:18.022Z",
      "status_completed_at": "2022-08-31T10:24:18.022Z",
      "status_rejected_at": "2022-08-31T10:24:18.022Z",
      "container_price": {
        "id": "string",
        "pickup_setting": {
          "id": "string",
          "project": {
            "id": "string",
            "name": "string",
            "description": "string",
            "creating_demo_data": false
          },
          "name": "string",
          "pickup_method": "string",
          "container_status": "string",
          "emptying_interval_from": "string",
          "emptying_interval_to": "string",
          "exclude_days": [
            "string"
          ],
          "fixed_pickups_period": "string",
          "pickup_interval": "string",
          "pickup_repeat_period": 0,
          "allowed_hours_from": "string",
          "allowed_hours_to": "string",
          "amount_days_between_pickups": 0,
          "minimum_days_between_pickup": 0,
          "collection_per_week": 0,
          "first_collection": "2022-08-31"
        },
        "waste_fraction": {
          "id": "string",
          "project": {
            "id": "string",
            "name": "string",
            "description": "string",
            "creating_demo_data": false
          },
          "name": "string",
          "waste_type": "string",
          "waste_category": "string",
          "waste_substance": "string",
          "weight_factor": 0
        },
        "container_type": {
          "project": {
            "id": "string",
            "name": "string",
            "description": "string",
            "creating_demo_data": false
          },
          "pickup_setting": {
            "id": "string",
            "project": {
              "id": "string",
              "name": "string",
              "description": "string",
              "creating_demo_data": false
            },
            "name": "string",
            "pickup_method": "string",
            "container_status": "string",
            "emptying_interval_from": "string",
            "emptying_interval_to": "string",
            "exclude_days": [
              "string"
            ],
            "fixed_pickups_period": "string",
            "pickup_interval": "string",
            "pickup_repeat_period": 0,
            "allowed_hours_from": "string",
            "allowed_hours_to": "string",
            "amount_days_between_pickups": 0,
            "minimum_days_between_pickup": 0,
            "collection_per_week": 0,
            "first_collection": "2022-08-31"
          },
          "name": "string",
          "emplacement": "string",
          "mobility": "string",
          "vehicle_coupling": [
            "string"
          ],
          "container_access": "string",
          "emptying_time": 0,
          "width": 0,
          "height": 0,
          "length": 0,
          "diameter": 0,
          "is_cylindrical": false
        },
        "name": "string",
        "invoice_name": "string",
        "amount": 0,
        "start_date": "2022-08-31",
        "end_date": "2022-08-31",
        "recurring_interval": 12,
        "created_at": "2022-08-31T10:24:18.022Z"
      }
    },
  "total": 100,
  "limit": 10,
  "offset": 0,
  "has_next": true,
  "has_previous": true
]

The bad request (422) will result in the following payload being returned.

{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}

Getting a single ticket

Getting a single ticket is very similar to getting data for all tickets. The main difference is that a ticket ID needs to be provided in the request path.

How to find a ticket ID?

  1. You can get a specific ticket ID by getting all the tickets first and then filtering the data to get only the requested ticket.
  2. On the platform you can navigate to the tickets page, select a specific ticket, and use the ID which is a part of the URL. The end of the URL should look like this (the ID is marked with bold): /app/tickets/W0OsTnc9zvznxF+8kzzkWw==/information

For getting the single ticket, the code example looks like this. Note, that getting a single ticket request does not support the pagination (because, there is no reason to). Therefore, there are no params that could be used for the query. The ticket ID has to be passed as a path parameter. Thus, it is just added at the end of the URL.

import requests

url = "https://platform-api.wastehero.io/api/v3/ticket/W0OsTnc9zvznxF+8kzzkWw=="

headers = {
    "accept": "application/json",
  	"content-type": "application/json",
    "X-API-Key": "<YOUR-API-KEY-HERE>"
}

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

print(response.json())

The response, either 200 or 400, from this request looks the same as the response shown in getting all tickets data section.