Skip to main content
GET
https://api.dcycle.io
/
v1
/
employee-historic
List Commuting Periods
const options = {
  method: 'GET',
  headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};

fetch('https://api.dcycle.io/v1/employee-historic', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "items": {
    "id": "<string>",
    "employee_id": "<string>",
    "start_date": "<string>",
    "end_date": "<string>",
    "commuting_type": "<string>",
    "transport_type": {},
    "vehicle_size": {},
    "fuel_type": {},
    "renewable_energy": {},
    "total_km": {},
    "weekly_travels": {},
    "daily_trips": 123,
    "carpool": true,
    "situation": "<string>",
    "origin": {},
    "destination": {},
    "response_medium": {},
    "co2e": 123,
    "created_at": {},
    "updated_at": {}
  },
  "total": 123,
  "page": 123,
  "size": 123,
  "pages": 123
}

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

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

employee_id
string
required
The employee UUID to get commuting periods forExample: 550e8400-e29b-41d4-a716-446655440000
page
integer
default:"1"
Page number for paginationExample: 1
size
integer
default:"50"
Number of items per page (max 100)Example: 50

Response

items
array[object]
Array of commuting period objects
total
integer
Total number of periods
page
integer
Current page
size
integer
Items per page
pages
integer
Total pages

Example

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}"

Successful Response

{
  "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,
  "pages": 1
}

Common Errors

404 Not Found

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