> ## 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.

# List Commuting Periods

> Retrieve all commuting periods for an employee

# List Commuting Periods

Retrieve a paginated list of commuting periods for a specific employee. Each period contains detailed transport information and calculated CO2e emissions.

## 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="employee_id" type="string" required>
  The employee UUID to get commuting periods for

  **Example:** `550e8400-e29b-41d4-a716-446655440000`
</ParamField>

<ParamField query="page" type="integer" default="1">
  Page number for pagination

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

<ParamField query="size" type="integer" default="50">
  Number of items per page (max 100)

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

## Response

<ResponseField name="items" type="array[object]">
  Array of commuting period objects

  <Expandable title="Commuting Period Object">
    <ResponseField name="id" type="string">
      Unique identifier (UUID)
    </ResponseField>

    <ResponseField name="employee_id" type="string">
      Employee UUID this period belongs to
    </ResponseField>

    <ResponseField name="start_date" type="date">
      Period start date (YYYY-MM-DD)
    </ResponseField>

    <ResponseField name="end_date" type="date">
      Period end date (YYYY-MM-DD)
    </ResponseField>

    <ResponseField name="commuting_type" type="string">
      Type: `in_itinere` (home-work) or `in_labore` (during work)
    </ResponseField>

    <ResponseField name="transport_type" type="string | null">
      Mode of transport
    </ResponseField>

    <ResponseField name="vehicle_size" type="string | null">
      For cars: `small`, `medium`, `large`
    </ResponseField>

    <ResponseField name="fuel_type" type="string | null">
      Fuel type for motorized transport
    </ResponseField>

    <ResponseField name="renewable_energy" type="string | null">
      For electric: `yes`, `no`, `do_not_know`
    </ResponseField>

    <ResponseField name="total_km" type="number | null">
      One-way distance in kilometers
    </ResponseField>

    <ResponseField name="weekly_travels" type="array | null">
      Days of week employee commutes (0=Mon, 6=Sun)
    </ResponseField>

    <ResponseField name="daily_trips" type="integer">
      Round trips per day
    </ResponseField>

    <ResponseField name="carpool" type="boolean">
      Whether employee carpools
    </ResponseField>

    <ResponseField name="situation" type="string">
      Period status: `active`, `inactive`, `terminated`
    </ResponseField>

    <ResponseField name="origin" type="string | null">
      Origin address
    </ResponseField>

    <ResponseField name="destination" type="string | null">
      Destination address
    </ResponseField>

    <ResponseField name="response_medium" type="string | null">
      Data source: `manual`, `qr`, `form`
    </ResponseField>

    <ResponseField name="co2e" type="number">
      Calculated CO2 equivalent emissions in kg
    </ResponseField>

    <ResponseField name="created_at" type="datetime">
      Creation timestamp
    </ResponseField>

    <ResponseField name="updated_at" type="datetime | null">
      Last update timestamp
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="total" type="integer">
  Total number of periods
</ResponseField>

<ResponseField name="page" type="integer">
  Current page
</ResponseField>

<ResponseField name="size" type="integer">
  Items per page
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
  curl -X GET "https://api.dcycle.io/v1/employee-historic?employee_id=550e8400-e29b-41d4-a716-446655440000" \
    -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

  headers = {
      "x-api-key": os.getenv("DCYCLE_API_KEY"),
      "x-organization-id": os.getenv("DCYCLE_ORG_ID")
  }

  employee_id = "550e8400-e29b-41d4-a716-446655440000"

  response = requests.get(
      "https://api.dcycle.io/v1/employee-historic",
      headers=headers,
      params={"employee_id": employee_id}
  )

  result = response.json()
  for period in result["items"]:
      print(f"{period['start_date']} - {period['end_date']}")
      print(f"  Transport: {period['transport_type']}")
      print(f"  CO2e: {period['co2e']} kg")
  ```

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

  const headers = {
    'x-api-key': process.env.DCYCLE_API_KEY,
    'x-organization-id': process.env.DCYCLE_ORG_ID
  };

  const employeeId = '550e8400-e29b-41d4-a716-446655440000';

  axios.get(
    'https://api.dcycle.io/v1/employee-historic',
    { headers, params: { employee_id: employeeId } }
  )
  .then(response => {
    response.data.items.forEach(period => {
      console.log(`${period.start_date} - ${period.end_date}`);
      console.log(`  Transport: ${period.transport_type}`);
      console.log(`  CO2e: ${period.co2e} kg`);
    });
  });
  ```
</CodeGroup>

### Successful Response

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "items": [
    {
      "id": "660e8400-e29b-41d4-a716-446655440000",
      "employee_id": "550e8400-e29b-41d4-a716-446655440000",
      "start_date": "2024-01-01",
      "end_date": "2024-06-30",
      "commuting_type": "in_itinere",
      "transport_type": "car",
      "vehicle_size": "medium",
      "fuel_type": "petrol",
      "renewable_energy": null,
      "total_km": 15,
      "weekly_travels": [0, 1, 2, 3, 4],
      "daily_trips": 1,
      "carpool": false,
      "situation": "active",
      "origin": "Home",
      "destination": "Office",
      "response_medium": "form",
      "co2e": 622.75,
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:30:00Z"
    },
    {
      "id": "660e8400-e29b-41d4-a716-446655440001",
      "employee_id": "550e8400-e29b-41d4-a716-446655440000",
      "start_date": "2024-07-01",
      "end_date": "2024-12-31",
      "commuting_type": "in_itinere",
      "transport_type": "train",
      "vehicle_size": null,
      "fuel_type": "electric",
      "renewable_energy": "yes",
      "total_km": 15,
      "weekly_travels": [0, 1, 2, 3, 4],
      "daily_trips": 1,
      "carpool": false,
      "situation": "active",
      "origin": "Home",
      "destination": "Office",
      "response_medium": "form",
      "co2e": 156.20,
      "created_at": "2024-07-01T09:00:00Z",
      "updated_at": "2024-07-01T09:00:00Z"
    }
  ],
  "total": 2,
  "page": 1,
  "size": 50
}
```

## Common Errors

### 404 Not Found

**Cause:** Employee not found

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "code": "EMPLOYEE_NOT_FOUND",
  "detail": "Employee with id=UUID('...') not found"
}
```

## Related Endpoints

<CardGroup cols={2}>
  <Card title="Create Commuting Period" icon="plus" href="/api-reference/employees/commuting-periods/create">
    Add a new period
  </Card>

  <Card title="Get Employee" icon="user" href="/api-reference/employees/get">
    Get employee with all periods
  </Card>
</CardGroup>
