Skip to main content
GET
https://api.dcycle.io
/
v1
/
vehicles
/
market_segments
Market Segments
const options = {
  method: 'GET',
  headers: {'x-api-key': '<x-api-key>', 'x-organization-id': '<x-organization-id>'}
};

fetch('https://api.dcycle.io/v1/vehicles/market_segments', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "array": {}
}

Market Segments

Get a list of all available vehicle market segments. These classifications help categorize vehicles for more accurate emission calculations and fleet analysis.

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

Response

array
array[string]
List of available market segment values

Example

curl -X GET "https://api.dcycle.io/v1/vehicles/market_segments" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}"

Successful Response

[
  "mini",
  "supermini",
  "lower_medium",
  "upper_medium",
  "executive",
  "luxury",
  "sports",
  "dual_purpose_4x4",
  "mpv"
]

Market Segment Definitions

SegmentDescriptionExamples
miniCompact city carsFiat 500, Mini Cooper, Smart Fortwo
superminiSmall hatchback vehiclesFord Fiesta, Vauxhall Corsa, Peugeot 206
lower_mediumEntry-level sedans and hatchbacksFord Focus, Volkswagen Golf, Honda Civic
upper_mediumMid-size sedans and SUVsBMW 3 Series, Mercedes-Benz C-Class, Audi A4
executivePremium sedansBMW 5 Series, Mercedes-Benz E-Class, Audi A6
luxuryLuxury vehiclesBMW 7 Series, Mercedes-Benz S-Class, Rolls-Royce
sportsHigh-performance vehiclesPorsche 911, Lamborghini, Ferrari
dual_purpose_4x4SUVs and off-road vehiclesRange Rover, Toyota 4Runner, Jeep Wrangler
mpvMulti-purpose vehiclesVolkswagen Transporter, Mercedes Sprinter

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. Get a new one from Settings → API.

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

Display Segment Options in UI

Populate a dropdown menu with available market segments:
def get_segment_options():
    """Get all available market segments for UI dropdown"""
    response = requests.get(
        "https://api.dcycle.io/v1/vehicles/market_segments",
        headers=headers
    )

    return response.json()

# Get segments
segments = get_segment_options()
print("Available Market Segments:")
for segment in segments:
    print(f"  - {segment}")

Validate Market Segment Input

Check if a provided segment is valid:
def is_valid_segment(segment_name):
    """Check if provided segment is valid"""
    response = requests.get(
        "https://api.dcycle.io/v1/vehicles/market_segments",
        headers=headers
    )

    valid_segments = response.json()
    return segment_name in valid_segments

# Validate
if is_valid_segment("upper_medium"):
    print("Valid segment")
else:
    print("Invalid segment")

Create Segment Category Map

Map segments to categories for fleet analysis:
def categorize_fleet_by_segment(vehicles):
    """Group fleet vehicles by market segment"""
    response = requests.get(
        "https://api.dcycle.io/v1/vehicles/market_segments",
        headers=headers
    )

    segments = response.json()
    categorized = {segment: [] for segment in segments}

    for vehicle in vehicles:
        segment = vehicle.get("market_segment")
        if segment and segment in categorized:
            categorized[segment].append(vehicle)

    return categorized

# Categorize fleet
# (assuming you have fetched vehicles first)
categorized = categorize_fleet_by_segment(vehicles)

for segment, vehicles_in_segment in categorized.items():
    if vehicles_in_segment:
        avg_co2e = sum(v["co2e"] for v in vehicles_in_segment) / len(vehicles_in_segment)
        print(f"{segment}: {len(vehicles_in_segment)} vehicles, avg CO2e: {avg_co2e:.2f} kg")