Skip to main content
GET
/
v1
/
business-travels
/
totals
Get Totals
const options = {
  method: 'GET',
  headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};

fetch('https://api.dcycle.io/v1/business-travels/totals', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "total_co2e": 123,
  "total_km": 123,
  "count": 123
}

Get Totals

Returns aggregated statistics for business travels in your organization: total CO2e emitted, total distance traveled, and record count. Supports the same filters as the list endpoint.

Request

Headers

x-api-key
string
required
Your API key for authenticationExample: 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, loading, completed, 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
name
string
Search by name (case-insensitive substring match)Example: offsite
name[]
array[string]
Filter by exact name values (multi-select, OR logic)Example: name[]=Team offsite&name[]=Client visit
file_id[]
array[uuid]
Filter by source file UUID. Pass 00000000-0000-0000-0000-000000000000 to filter for records with no associated file.Example: file_id[]=3fa85f64-5717-4562-b3fc-2c963f66afa6
created_at_from
datetime
Filter records created on or after this timestamp (inclusive)Format: YYYY-MM-DDTHH:MM:SSZ
created_at_to
datetime
Filter records created on or before this timestamp (inclusive)Format: YYYY-MM-DDTHH:MM:SSZ
co2e_status
string
Filter by CO2e calculation statusAvailable values: calculated, not_calculated

Response

total_co2e
number
Total CO2e in kg across all matching business travels
total_km
number
Total distance in kilometers
count
integer
Number of business travel records matching the filters

Example

curl -X GET "https://api.dcycle.io/v1/business-travels/totals?start_date=2024-01-01&end_date=2024-12-31&status[]=active" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}"

Successful Response

{
  "total_co2e": 14523.87,
  "total_km": 82150.0,
  "count": 127
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}

403 Forbidden

Cause: The authenticated user is not a member of the organization
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}

404 Not Found

Cause: Organization not found
{"detail": "Organization with id=UUID('...') not found", "code": "ORGANIZATION_NOT_FOUND"}

Use Cases

Compare Emissions by Transport Type

transport_types = ["car", "train", "aircraft", "bus"]
for t_type in transport_types:
    response = requests.get(
        "https://api.dcycle.io/v1/business-travels/totals",
        headers=headers,
        params={
            "transport_type[]": [t_type],
            "start_date": "2024-01-01",
            "end_date": "2024-12-31",
            "status[]": ["active"],
        },
    )
    totals = response.json()
    print(f"{t_type}: {totals['total_co2e']:.1f} kg CO2e ({totals['count']} trips, {totals['total_km']:.0f} km)")

List Business Travels

Browse individual travel records

Calculation Steps

See the CO2e breakdown for a specific trip