Skip to main content
GET
https://api.dcycle.io
/
v1
/
business-travels
List Business Travels
const options = {
  method: 'GET',
  headers: {Authorization: '<authorization>', 'x-organization-id': '<x-organization-id>'}
};

fetch('https://api.dcycle.io/v1/business-travels', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "items": {
    "id": "<string>",
    "travel_date": "<string>",
    "transport_type": "<string>",
    "distance_km": 123,
    "origin": {},
    "destination": {},
    "travel_number": 123,
    "round_trip": true,
    "vehicle_size": {},
    "fuel_type": {},
    "flight_type": {},
    "cabin_class": {},
    "status": "<string>",
    "co2e": 123,
    "created_at": {},
    "updated_at": {}
  },
  "total": 123,
  "page": 123,
  "size": 123,
  "pages": 123
}

List Business Travels

Retrieve a paginated list of business travel records in your organization with support for filtering by transport type, status, and date range.

Request

Headers

Authorization
string
required
Bearer token for authenticationExample: Bearer sk_live_1234567890abcdef
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa

Query Parameters

transport_type
array[string]
Filter by transport typeAvailable values: car, metro, train, trolleybus, bus, motorbike, aircraft, ferryExample: transport_type=train&transport_type=aircraft
status
array[string]
Filter by statusAvailable values: active, pending, errorExample: status=active
start_date
date
Filter by minimum travel date (inclusive)Format: YYYY-MM-DDExample: 2024-01-01
end_date
date
Filter by maximum travel date (inclusive)Format: YYYY-MM-DDExample: 2024-12-31
page
integer
default:"1"
Page number for paginationExample: 2
size
integer
default:"50"
Number of items per page (max 100)Example: 50

Response

items
array[object]
Array of business travel objects
total
integer
Total number of records matching the filter
page
integer
Current page number
size
integer
Number of items per page
pages
integer
Total number of pages

Example

curl -X GET "https://api.dcycle.io/v1/business-travels?page=1&size=50&status=active" \
  -H "Authorization: Bearer ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}"

Successful Response

{
  "items": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "travel_date": "2024-12-01",
      "transport_type": "train",
      "distance_km": 621.5,
      "origin": "Madrid, Spain",
      "destination": "Barcelona, Spain",
      "travel_number": 2,
      "round_trip": false,
      "vehicle_size": null,
      "fuel_type": null,
      "flight_type": null,
      "cabin_class": null,
      "status": "active",
      "co2e": 24.86,
      "created_at": "2024-12-01T10:30:00Z",
      "updated_at": "2024-12-01T10:30:00Z"
    },
    {
      "id": "550e8400-e29b-41d4-a716-446655440001",
      "travel_date": "2024-11-15",
      "transport_type": "aircraft",
      "distance_km": 1250.0,
      "origin": "Madrid, Spain",
      "destination": "London, UK",
      "travel_number": 1,
      "round_trip": true,
      "vehicle_size": null,
      "fuel_type": null,
      "flight_type": "short_haul_international",
      "cabin_class": "economy",
      "status": "active",
      "co2e": 385.5,
      "created_at": "2024-11-15T08:00:00Z",
      "updated_at": "2024-11-15T08:00:00Z"
    }
  ],
  "total": 42,
  "page": 1,
  "size": 50,
  "pages": 1
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{
  "detail": "Invalid API key",
  "code": "INVALID_API_KEY"
}
Solution: Verify your API key is valid and active.

404 Not Found

Cause: Organization not found
{
  "code": "ORGANIZATION_NOT_FOUND",
  "detail": "Organization with id=UUID('...') not found"
}
Solution: Verify that the x-organization-id header contains a valid organization UUID.

Use Cases

Get Annual Business Travel Emissions

def get_annual_emissions(year: int):
    """Get total business travel emissions for a year"""
    all_travels = []
    page = 1

    while True:
        response = requests.get(
            "https://api.dcycle.io/v1/business-travels",
            headers=headers,
            params={
                "page": page,
                "size": 100,
                "status": ["active"],
                "start_date": f"{year}-01-01",
                "end_date": f"{year}-12-31"
            }
        )
        data = response.json()
        all_travels.extend(data["items"])

        if page >= data["pages"]:
            break
        page += 1

    total_co2e = sum(t["co2e"] for t in all_travels)
    return total_co2e, len(all_travels)

emissions, count = get_annual_emissions(2024)
print(f"Total: {emissions} kg CO2e from {count} trips")

Group by Transport Type

from collections import defaultdict

def emissions_by_transport():
    """Group emissions by transport type"""
    response = requests.get(
        "https://api.dcycle.io/v1/business-travels",
        headers=headers,
        params={"status": ["active"], "size": 100}
    )

    by_type = defaultdict(lambda: {"co2e": 0, "count": 0})

    for travel in response.json()["items"]:
        t_type = travel["transport_type"]
        by_type[t_type]["co2e"] += travel["co2e"]
        by_type[t_type]["count"] += 1

    for t_type, data in sorted(by_type.items(), key=lambda x: -x[1]["co2e"]):
        print(f"{t_type}: {data['co2e']:.1f} kg CO2e ({data['count']} trips)")

emissions_by_transport()