Skip to main content

List All Balances

Retrieve a paginated list of fuel station balances.
GET /api/saldos-bombas

Query Parameters

page
number
default:"1"
Page number for pagination
limit
number
default:"20"
Number of records per page (max 100)
area_operacion
string
Filter by operational area name (partial match, case-insensitive)
bomba
string
Filter by fuel station name (partial match, case-insensitive)
actividad
string
Filter by status: ACTIVADA or DESACTIVADA (default: ACTIVADA only)
sort_by
string
default:"saldo_disponible"
Field to sort by: saldo_disponible, nombre_bomba, nombre_area_operacion
sort_order
string
default:"desc"
Sort direction: asc or desc

Response

data
array
Array of fuel station balance records
pagination
object
Pagination metadata

Example Request

curl -X GET "https://api.example.com/api/saldos-bombas?page=1&limit=10&sort_by=saldo_disponible&sort_order=asc" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Example Response

{
  "data": [
    {
      "id": 1,
      "bomba_id": 5,
      "nombre_bomba": "Bomba Central",
      "area_operacion_id": 2,
      "nombre_area_operacion": "Zona Norte",
      "saldo_disponible": 1500000,
      "actividad": "ACTIVADA",
      "ultima_actualizacion": "2024-03-04T10:30:00Z"
    },
    {
      "id": 2,
      "bomba_id": 8,
      "nombre_bomba": "Bomba Sur",
      "area_operacion_id": 3,
      "nombre_area_operacion": "Zona Sur",
      "saldo_disponible": 2300000,
      "actividad": "ACTIVADA",
      "ultima_actualizacion": "2024-03-04T09:15:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 25,
    "totalPages": 3
  }
}

Common Use Cases

Find Low Balance Stations

Identify fuel stations with low balances that need replenishment:
curl -X GET "https://api.example.com/api/saldos-bombas?sort_by=saldo_disponible&sort_order=asc&limit=5" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Filter by Operational Area

View balances for a specific operational area:
curl -X GET "https://api.example.com/api/saldos-bombas?area_operacion=Zona%20Norte" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

View All Stations (Including Inactive)

By default, only ACTIVADA stations are shown. To see all:
curl -X GET "https://api.example.com/api/saldos-bombas?actividad=" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Check Specific Station

Find a specific fuel station by name:
curl -X GET "https://api.example.com/api/saldos-bombas?bomba=Central" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Get Filter Options

Retrieve unique values for filter dropdowns.
GET /api/saldos-bombas/filters

Response

areas
array
List of unique operational area names
bombas
array
List of unique fuel station names
actividades
array
List of status values (ACTIVADA, DESACTIVADA)

Example Request

curl -X GET "https://api.example.com/api/saldos-bombas/filters" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Example Response

{
  "areas": ["Zona Norte", "Zona Sur", "Zona Centro"],
  "bombas": ["Bomba Central", "Bomba Norte", "Bomba Sur"],
  "actividades": ["ACTIVADA", "DESACTIVADA"]
}
Filter options are cached for 5 minutes to improve performance. The cache respects Row Level Security (RLS) policies.

Important Notes

Default Behavior: By default, only stations with actividad = 'ACTIVADA' are returned. Pass an empty actividad parameter to see all stations.
Row Level Security: All queries respect RLS policies. Users only see data they have permission to access based on their assigned operational areas.
Performance: Use the limit parameter to control result set size. Smaller page sizes improve response times.

Error Responses

Invalid Sort Field

{
  "error": "Invalid sort_by field"
}
Status: 400

Unauthorized

{
  "error": "Unauthorized"
}
Status: 401

Server Error

{
  "error": "Error fetching saldos bombas"
}
Status: 500

Integration Example

JavaScript Fetch

async function getFuelStationBalances(filters = {}) {
  const params = new URLSearchParams({
    page: filters.page || 1,
    limit: filters.limit || 20,
    sort_by: 'saldo_disponible',
    sort_order: 'asc',
    ...filters
  });
  
  const response = await fetch(`https://api.example.com/api/saldos-bombas?${params}`, {
    headers: {
      'Authorization': `Bearer ${accessToken}`
    }
  });
  
  if (!response.ok) {
    throw new Error('Failed to fetch balances');
  }
  
  return await response.json();
}

// Usage
const lowBalances = await getFuelStationBalances({
  sort_order: 'asc',
  limit: 10
});

console.log('Stations with lowest balances:', lowBalances.data);

Fuel Tracking

Track fuel consumption and refills

Catalogs

Access catalog data for fuel stations

Build docs developers (and LLMs) love