Skip to main content

Endpoint

curl --request GET \
  --url 'https://api.example.com/flota/catalogos' \
  --header 'Authorization: Bearer <access_token>'

Authentication

Authorization
string
required
Bearer token for authentication. Format: Bearer <access_token>

Description

This endpoint retrieves all vehicle-related catalog data in a single request. The catalogs are used to populate dropdown menus and provide reference data when creating or updating vehicle records. All catalogs are fetched in parallel for optimal performance.

Response

Returns an object containing five catalog arrays.
marcas
array
Array of vehicle brand objects from the cat_marca table
tipos
array
Array of vehicle type objects from the cat_tipo_vehiculo table
clases
array
Array of vehicle class objects from the cat_clase_vehiculo table
combustibles
array
Array of fuel type objects from the cat_combustible table
marcasCompactadora
array
Array of compactor brand objects from the cat_marca_compactadora table

Response Example

{
  "marcas": [
    {
      "id": 1,
      "nombre": "Toyota"
    },
    {
      "id": 2,
      "nombre": "Chevrolet"
    },
    {
      "id": 3,
      "nombre": "Nissan"
    },
    {
      "id": 4,
      "nombre": "Kenworth"
    },
    {
      "id": 5,
      "nombre": "Freightliner"
    }
  ],
  "tipos": [
    {
      "id": 1,
      "nombre": "Carga"
    },
    {
      "id": 2,
      "nombre": "Pasajeros"
    },
    {
      "id": 3,
      "nombre": "Especial"
    },
    {
      "id": 4,
      "nombre": "Mixto"
    }
  ],
  "clases": [
    {
      "id": 1,
      "nombre": "Automóvil"
    },
    {
      "id": 2,
      "nombre": "Camioneta"
    },
    {
      "id": 3,
      "nombre": "Camión"
    },
    {
      "id": 4,
      "nombre": "Volqueta"
    },
    {
      "id": 5,
      "nombre": "Compactadora"
    },
    {
      "id": 6,
      "nombre": "Tractocamión"
    }
  ],
  "combustibles": [
    {
      "id": 1,
      "nombre": "Diesel"
    },
    {
      "id": 2,
      "nombre": "Gasolina"
    },
    {
      "id": 3,
      "nombre": "Eléctrico"
    },
    {
      "id": 4,
      "nombre": "Gas Natural"
    },
    {
      "id": 5,
      "nombre": "Híbrido"
    }
  ],
  "marcasCompactadora": [
    {
      "id": 1,
      "nombre": "Heil"
    },
    {
      "id": 2,
      "nombre": "McNeilus"
    },
    {
      "id": 3,
      "nombre": "Labrie"
    },
    {
      "id": 4,
      "nombre": "Pak-Mor"
    }
  ]
}

Examples

Get all catalogs

curl --request GET \
  --url 'https://api.example.com/flota/catalogos' \
  --header 'Authorization: Bearer <access_token>'

Using in a Form

The catalog data is typically used to populate dropdown menus in vehicle forms:
// Fetch catalogs
const response = await fetch('https://api.example.com/flota/catalogos', {
  headers: {
    'Authorization': `Bearer ${accessToken}`
  }
});

const catalogs = await response.json();

// Populate brand dropdown
const brandSelect = document.getElementById('brand');
catalogs.marcas.forEach(marca => {
  const option = document.createElement('option');
  option.value = marca.id;
  option.textContent = marca.nombre;
  brandSelect.appendChild(option);
});

// Populate fuel type dropdown
const fuelSelect = document.getElementById('fuel');
catalogs.combustibles.forEach(combustible => {
  const option = document.createElement('option');
  option.value = combustible.id;
  option.textContent = combustible.nombre;
  fuelSelect.appendChild(option);
});

Error Responses

401 Unauthorized

{
  "error": "Unauthorized",
  "details": "Invalid or missing access token"
}

500 Internal Server Error

{
  "error": "Internal Server Error",
  "details": "Supabase client not initialized in request"
}

Performance

  • All five catalog queries are executed in parallel using Promise.all() for optimal performance
  • Typical response time is under 200ms
  • The catalogs are relatively static and can be cached on the client side
  • Consider implementing client-side caching with a reasonable TTL (e.g., 1 hour) to reduce API calls

Catalog Relationships

These catalogs are used in the vehiculo_caracteristicas table:
  • marcasvehiculo_caracteristicas.marca_id
  • tiposvehiculo_caracteristicas.tipo_vehiculo_id
  • clasesvehiculo_caracteristicas.clase_vehiculo_id
  • combustiblesvehiculo_caracteristicas.combustible_id
  • marcasCompactadoravehiculo_caracteristicas.marca_compactadora_id

Notes

  • All catalogs return complete datasets (no pagination required)
  • The marcasCompactadora catalog is only relevant for vehicles with class “Compactadora”
  • Catalog data is maintained separately and should be managed through administrative interfaces
  • The response includes all fields from the catalog tables (typically just id and nombre)
  • Empty arrays will be returned if a catalog table has no records

Build docs developers (and LLMs) love