Skip to main content
GET
/
v1
/
logistics
/
requests
Get Logistics Requests
const options = {
  method: 'GET',
  headers: {'x-organization-id': '<x-organization-id>', 'x-api-key': '<api-key>'}
};

fetch('https://api.dcycle.io/v1/logistics/requests', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "page": 1,
  "size": 50,
  "total": 100,
  "items": [
    {
      "id": "<string>",
      "load_unit": "<string>",
      "created_at": "2023-11-07T05:31:56Z",
      "origin": "<string>",
      "destination": "<string>",
      "distance_km": 123,
      "load": 123,
      "toc": "<string>",
      "cleaning": true,
      "status": "active",
      "movement_id": "<string>",
      "client": "<string>",
      "shipment_date": "2023-12-25",
      "movement_stretch": "<string>",
      "movement_stage": "<string>",
      "vehicle_license_plate": "<string>",
      "trailer_license_plate": "<string>",
      "subcontractor": true,
      "hub_id": "<string>",
      "tkm": 123,
      "kgco2e": 123,
      "emission_intensity": 123,
      "error_messages": [
        "<string>"
      ],
      "estimated_data": [
        "<string>"
      ],
      "file_name": "<string>",
      "uploaded_by": {
        "first_name": "<string>",
        "last_name": "<string>",
        "profile_img_url": "<string>"
      },
      "linked_projects": [
        {
          "project_id": "<string>",
          "project_name": "<string>",
          "organization_id": "<string>",
          "organization_name": "<string>"
        }
      ]
    }
  ],
  "filter_hash": "<string>"
}

Get Logistics Requests

Retrieve logistics requests created by your organization with pagination and filtering support.
New API: This endpoint is part of the new API architecture with improved design and maintainability.

Example

curl --get "https://api.dcycle.io/v1/logistics/requests" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  --data-urlencode "page=1" \
  --data-urlencode "size=50" \
  --data-urlencode "search=MOV-2024" \
  --data-urlencode "trip_date_from=2024-01-01" \
  --data-urlencode "trip_date_until=2024-12-31" \
  --data-urlencode "clients[]=Acme Logistics"

Use Cases

List All Logistics Requests

Retrieve every page of logistics requests:
def get_all_logistics_requests(headers):
    """Retrieve all logistics requests with pagination."""
    all_requests = []
    page = 1

    while True:
        response = requests.get(
            "https://api.dcycle.io/v1/logistics/requests",
            headers=headers,
            params={"page": page, "size": 500},
        )
        response.raise_for_status()

        data = response.json()
        all_requests.extend(data["items"])

        if page * data["size"] >= data["total"]:
            break

        page += 1

    return all_requests

Filter by Project and Date

Scope logistics requests to a project and shipment date range:
def get_project_requests(headers, project_id):
    """Retrieve logistics requests linked to a project for 2024."""
    response = requests.get(
        "https://api.dcycle.io/v1/logistics/requests",
        headers=headers,
        params={
            "page": 1,
            "size": 100,
            "project_id": project_id,
            "trip_date_from": "2024-01-01",
            "trip_date_until": "2024-12-31",
        },
    )
    response.raise_for_status()
    return response.json()

Export to CSV

Export the current filtered page to a CSV file:
import csv


def export_logistics_to_csv(headers, filename="logistics_requests.csv"):
    """Export a page of logistics requests to CSV."""
    response = requests.get(
        "https://api.dcycle.io/v1/logistics/requests",
        headers=headers,
        params={"page": 1, "size": 500, "trip_status": "active"},
    )
    response.raise_for_status()

    data = response.json()
    fields = [
        "id",
        "movement_id",
        "client",
        "shipment_date",
        "origin",
        "destination",
        "distance_km",
        "load",
        "load_unit",
        "toc",
        "status",
        "kgco2e",
        "emission_intensity",
        "created_at",
    ]

    with open(filename, "w", newline="") as csvfile:
        writer = csv.DictWriter(csvfile, fieldnames=fields)
        writer.writeheader()

        for item in data["items"]:
            writer.writerow({field: item.get(field) for field in fields})

    return len(data["items"])

Create Logistics Request

Calculate emissions for a new leg

Get Packages

Retrieve all packages with aggregated emissions

Get Package by ID

Get a package with all its legs

Get Available Vehicle Types

Retrieve all available TOCs

Authentication Guide

Learn how to get your API key

Authorizations

x-api-key
string
header
required

Headers

x-api-key
string
x-organization-id
string<uuid>
required

Query Parameters

page
integer
default:1
Required range: x >= 1
size
integer
default:10
Required range: 1 <= x <= 500
project_id
string<uuid>

Search across movement ID and stretch ID

clients[]
string[]

Filter by client name(s)

trip_date_from
string

Filter by trip date >= (YYYY-MM-DD)

trip_date_until
string

Filter by trip date <= (YYYY-MM-DD)

vehicle_type[]
string[]

Filter by vehicle type(s)

trip_status
string

Filter by trip status

uploaded_by[]
string<uuid>[]

Filter by uploader user ID(s)

file_id[]
string<uuid>[]

Filter by file ID(s)

created_at_from
string

Filter by created_at >= (YYYY-MM-DD)

created_at_to
string

Filter by created_at <= (YYYY-MM-DD)

Response

Successful Response

Response schema for paginated logistics requests.

page
integer
required

Current page number

Example:

1

size
integer
required

Number of items per page

Example:

50

total
integer
required

Total number of items

Example:

100

items
GetLogisticsRequestOut · object[]
required

List of logistics requests

filter_hash
string

Hash of the applied filters