> ## Documentation Index
> Fetch the complete documentation index at: https://code.dcycle.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Totals

> Get aggregated CO2e emissions and quantity totals for transport routes

# Get Totals

Return aggregated totals for transport routes — total CO2e emissions, total quantity transported (in kg), record count, and percentage change compared to the same period in the previous year. Supports the same filters as the list endpoint.

## Request

### Headers

<ParamField header="x-api-key" type="string" required>
  Your API key for authentication

  **Example:** `sk_live_1234567890abcdef`
</ParamField>

<ParamField header="x-organization-id" type="string" required>
  Your organization UUID

  **Example:** `a8315ef3-dd50-43f8-b7ce-d839e68d51fa`
</ParamField>

### Query Parameters

<ParamField query="search" type="string">
  Free-text search (min 1, max 255 characters)
</ParamField>

<ParamField query="from_date" type="string">
  Filter routes with dates on or after this date (ISO 8601)

  **Example:** `2025-01-01`
</ParamField>

<ParamField query="to_date" type="string">
  Filter routes with dates on or before this date (ISO 8601)

  **Example:** `2025-12-31`
</ParamField>

<ParamField query="status" type="string[]">
  Filter by calculation status: `pending`, `active`, `error`
</ParamField>

<ParamField query="transport_direction" type="string">
  Filter by direction: `downstream` or `upstream`
</ParamField>

<ParamField query="file_id" type="string[]">
  Filter by bulk-upload file UUIDs
</ParamField>

<ParamField query="created_at_from" type="string">
  Filter routes created on or after this datetime (ISO 8601)
</ParamField>

<ParamField query="created_at_to" type="string">
  Filter routes created on or before this datetime (ISO 8601)
</ParamField>

<ParamField query="co2e_status" type="string">
  Filter by CO2e calculation status
</ParamField>

## Response

<ResponseField name="total_co2e" type="number">
  Sum of CO2e emissions across all matching routes (tCO2e). Default: `0.0`
</ResponseField>

<ResponseField name="total_quantity_kg" type="number">
  Sum of transported quantity across all matching routes (kg). Default: `0.0`
</ResponseField>

<ResponseField name="count" type="integer">
  Number of matching transport routes. Default: `0`
</ResponseField>

<ResponseField name="co2e_pct_change" type="number | null">
  Percentage change in CO2e vs the same period in the previous year. `null` if no prior-year data exists.
</ResponseField>

<ResponseField name="quantity_kg_pct_change" type="number | null">
  Percentage change in quantity (kg) vs the same period in the previous year. `null` if no prior-year data exists.
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl "https://api.dcycle.io/v1/transports/totals?from_date=2025-01-01&to_date=2025-12-31&transport_direction=downstream" \
    -H "x-api-key: ${DCYCLE_API_KEY}" \
    -H "x-organization-id: ${DCYCLE_ORG_ID}"
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  import requests
  import os

  response = requests.get(
      "https://api.dcycle.io/v1/transports/totals",
      headers={
          "x-api-key": os.getenv("DCYCLE_API_KEY"),
          "x-organization-id": os.getenv("DCYCLE_ORG_ID"),
      },
      params={
          "from_date": "2025-01-01",
          "to_date": "2025-12-31",
          "transport_direction": "downstream",
      },
  )

  totals = response.json()
  print(f"Total CO2e: {totals['total_co2e']:.2f} tCO2e")
  print(f"Total quantity: {totals['total_quantity_kg']:.0f} kg")
  print(f"Routes: {totals['count']}")
  if totals["co2e_pct_change"] is not None:
      print(f"YoY change: {totals['co2e_pct_change']:+.1f}%")
  ```

  ```javascript JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
  const axios = require('axios');

  const { data: totals } = await axios.get('https://api.dcycle.io/v1/transports/totals', {
    headers: {
      'x-api-key': process.env.DCYCLE_API_KEY,
      'x-organization-id': process.env.DCYCLE_ORG_ID,
    },
    params: {
      from_date: '2025-01-01',
      to_date: '2025-12-31',
      transport_direction: 'downstream',
    },
  });

  console.log(`Total CO2e: ${totals.total_co2e.toFixed(2)} tCO2e`);
  console.log(`Total quantity: ${totals.total_quantity_kg} kg`);
  console.log(`Routes: ${totals.count}`);
  if (totals.co2e_pct_change !== null) {
    console.log(`YoY change: ${totals.co2e_pct_change > 0 ? '+' : ''}${totals.co2e_pct_change.toFixed(1)}%`);
  }
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "total_co2e": 245.78,
  "total_quantity_kg": 1500000.0,
  "count": 342,
  "co2e_pct_change": -12.5,
  "quantity_kg_pct_change": 8.3
}
```

## Common Errors

### 401 Unauthorized

**Cause:** Missing or invalid API key

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}
```

### 403 Forbidden

**Cause:** The authenticated user is not a member of the organization

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="List Transport Routes" icon="list" href="/api-reference/transport/list">
    Retrieve all transport routes with filtering and pagination
  </Card>

  <Card title="Get Route Counts" icon="chart-bar" href="/api-reference/transport/counts">
    Count routes grouped by calculation status
  </Card>
</CardGroup>
