# Bencina en Línea Chile – Precios de Combustibles (API CNE) (`better-llama/bencina-en-linea-chile`) Actor

Official fuel prices for every gas station in Chile (CNE Bencina en Línea API): gasoline 93/95/97, diesel, kerosene, LPG and CNG, filtered by region, commune, brand or distance and sorted by price. No account needed (your own free CNE account optional). Not affiliated with the CNE.

- **URL**: https://apify.com/better-llama/bencina-en-linea-chile.md
- **Developed by:** [Francisco Rubio](https://apify.com/better-llama) (community)
- **Categories:** Developer tools, AI
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 resultado entregado / delivered results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Bencina en Línea Chile – Precios de Combustibles (API CNE)

**ES** · Precios **oficiales** de **bencina 93, 95 y 97, diésel, kerosene (parafina), GLP y GNC** en **cada estación de servicio de Chile**, desde la **API de Bencina en Línea de la Comisión Nacional de Energía (CNE)**. Filtra por región, comuna, marca o distancia a un punto y obtén **la más barata primero**. No necesitas cuenta (puedes usar la tuya, gratuita).
**EN** · Official **fuel prices for every gas station in Chile** (gasoline 93/95/97, diesel, kerosene, LPG, CNG) from the **CNE Bencina en Línea API**, filtered by region, commune, brand or distance and sorted by price. No account needed (you can still use your own free CNE account).

> 🔓 **No necesitas cuenta / No account needed.** Sin credenciales, el Actor usa una cuenta compartida del operador (1 inicio de sesión y 1 consulta por ejecución, reintentos limitados). **Igual puedes usar la tuya** (gratis en <https://api.cne.cl/register>, email y contraseña) si prefieres no depender de la cuenta compartida. Soporte de la API: soporteapi@cne.cl.
>
> ⚠️ **No afiliado / Not affiliated.** Proyecto independiente. **No está afiliado, patrocinado ni aprobado por la Comisión Nacional de Energía ni por Bencina en Línea**. El nombre se usa solo para describir la fuente.
>
> **Fuente / Data source:** Comisión Nacional de Energía, Bencina en Línea (<https://www.bencinaenlinea.cl>). Los precios los informa **cada estación**, que es responsable de su exactitud; revisa `priceUpdatedAt`.

### Uso con agentes de IA (MCP)

```
https://mcp.apify.com/?tools=better-llama/bencina-en-linea-chile
```

Ejemplos: *«¿Dónde está más barata la bencina 95 en Ñuñoa?»*, *«Diésel más barato a 5 km de -33.45, -70.66»*, *«Precio de la parafina en estaciones Copec de Temuco»*.

### Qué entrega

| `output` | Una fila por | Uso típico |
|---|---|---|
| `precios` (defecto) | estación × combustible × tipo de atención | ranking de precios, comparación, alertas |
| `estaciones` | estación, con su lista de `prices` | mapas, catálogos, servicios y medios de pago |

- **Filtros:** `fuels` (93, 95, 97, DI, KE, GLP, GNC; también acepta «diésel», «parafina»…), `serviceType` (asistido / autoservicio), `regions` (código o nombre; «RM» funciona), `comunas`, `brands`, `latitude` + `longitude` + `radiusKm`.
- **Orden:** `precio` (más barato primero), `distancia` (si das un punto) o `ninguno`.
- **Estaciones en mantenimiento** se omiten salvo `includeMaintenance`.
- **Volumen:** la API entrega todo el país en **una sola consulta** (~1.800 estaciones); el filtrado se hace en el Actor y **solo se cobra lo entregado**.

### Comportamiento

- Inicio de sesión (cuenta compartida o la tuya) (`POST /api/login`) → token temporal (≈1 h) → `GET /api/v4/estaciones`. Si el token vence, se renueva una vez.
- Reintentos con espera exponencial ante errores de red, 429 y 5xx. **Errores claros** para credenciales inválidas («invalid Credentials», «Token is Invalid»).
- Credenciales en campos **secretos** (cifrados por Apify), nunca escritas en logs.
- **Privacidad (Ley 19.628 / 21.719):** la razón social del operador se muestra solo si es claramente una persona jurídica (S.A., SpA, Ltda., etc.); si podría ser una **persona natural**, se oculta (`operator: null`, `redacted: true`), también en `raw`.

### Precio / Pricing

Pago por resultado (*pay per event*): solo el evento `result` por cada fila **entregada**. Puedes fijar un gasto máximo por ejecución.

### Input

Bencina 93 más barata en Providencia:

```json
{ "fuels": ["93"], "comunas": ["Providencia"], "maxItems": 20 }
```

Diésel de autoservicio a 5 km de un punto:

```json
{ "email": "tu@correo.cl", "password": "TU-CONTRASEÑA", "fuels": ["DI"], "serviceType": "autoservicio", "latitude": "-33.4489", "longitude": "-70.6693", "radiusKm": 5 }
```

Todas las estaciones Copec de la región del Biobío:

```json
{ "email": "tu@correo.cl", "password": "TU-CONTRASEÑA", "output": "estaciones", "regions": ["Biobío"], "brands": ["Copec"] }
```

### Output

```json
{
  "kind": "precio",
  "stationCode": "co110101",
  "brand": "COPEC",
  "operator": "COMPAÑIA DE PETROLEOS DE CHILE COPEC S.A.",
  "fuelCode": "93",
  "fuelName": "Gasolina 93",
  "serviceType": "autoservicio",
  "price": 1289,
  "unit": "$/L",
  "priceUpdatedAt": "2026-11-12T08:15:00",
  "region": "Metropolitana de Santiago",
  "comuna": "Providencia",
  "address": "Av. Providencia 1234",
  "latitude": -33.4263,
  "longitude": -70.617,
  "distanceKm": null,
  "mapsUrl": "https://www.google.com/maps/search/?api=1&query=-33.4263,-70.617",
  "redacted": false,
  "officialUrl": "https://www.bencinaenlinea.cl",
  "dataSource": "Comisión Nacional de Energía (CNE), Bencina en Línea – precios informados por cada estación de servicio"
}
```

*(valores ilustrativos)*

| Campo | ES | EN |
|---|---|---|
| `stationCode`, `brand`, `operator`, `redacted`, `personType` | Estación, marca y operador | Station and operator |
| `fuelCode`, `fuelName`, `apiFuelKey`, `serviceType` | Combustible y tipo de atención | Fuel and service |
| `price`, `unit`, `priceUpdatedAt` | Precio (CLP), unidad y última actualización (hora de Chile) | Price |
| `region`, `regionCode`, `comuna`, `comunaCode`, `address`, `latitude`, `longitude`, `distanceKm`, `mapsUrl` | Ubicación | Location |
| `inMaintenance`, `openingHours`, `services`, `paymentMethods`, `evCharging` | Detalles de la estación | Station details |
| `prices` | Lista de precios (modo `estaciones`) | Price list |
| `officialUrl`, `dataSource`, `retrievedAt`, `raw` | Atribución, consulta y objeto original | Attribution |

### English summary

Official per-station fuel prices for all of Chile from the CNE Bencina en Línea API: gasoline 93/95/97, diesel, kerosene, LPG and CNG, with region/commune/brand/fuel/service filters, distance from a point and cheapest-first sorting. Bring your own free CNE API account (<https://api.cne.cl/register>). Operator names that may belong to natural persons are redacted. Pay only per delivered result. Not affiliated with the CNE.

### Más conectores de Chile / More Chilean data connectors

Este Actor es parte de **Better Llama**, una colección de conectores de datos públicos y empresariales de Chile (licitaciones, UF y dólar, energía, bencina, envíos, bolsa y más) con JSON limpio y pago por resultado. Catálogo completo: <https://betterllama.com>.

Part of **Better Llama**, a collection of Chilean data connectors for developers and AI agents. Full catalog: <https://betterllama.com/en/>.

# Changelog

This Actor's version history is a separate document: https://apify.com/better-llama/bencina-en-linea-chile/changelog.md

# Actor input Schema

## `email` (type: `string`):

Opcional. Si lo dejas vacío se usa la cuenta compartida. El email con que te registraste en https://api.cne.cl/register. Cifrado; nunca se registra en logs.

## `password` (type: `string`):

Se usa solo para obtener un token temporal (≈1 hora) en cada ejecución. Cifrada; nunca se registra.

## `apiToken` (type: `string`):

Opcional: un token ya emitido por /api/login. Vence en cerca de 1 hora, por lo que se recomienda usar email y contraseña.

## `output` (type: `string`):

precios = una fila por estación y combustible (ideal para «¿dónde está más barata?»); estaciones = una fila por estación con todos sus precios.

## `fuels` (type: `array`):

Vacío = todos.

## `serviceType` (type: `string`):

Filtra por precio asistido o de autoservicio.

## `regions` (type: `array`):

Código CNE (13) o nombre (Valparaíso, Biobío, RM…). Sin tildes ni mayúsculas. Vacío = todo Chile.

## `comunas` (type: `array`):

Nombre (Providencia, Ñuñoa…) o código. Vacío = todas.

## `brands` (type: `array`):

Copec, Shell, Aramco, Petrobras, Abastible… Vacío = todas.

## `latitude` (type: `string`):

Opcional: punto de referencia para calcular distancia (p. ej. -33.4263).

## `longitude` (type: `string`):

Opcional (p. ej. -70.6170).

## `radiusKm` (type: `integer`):

Opcional: solo estaciones dentro de este radio del punto.

## `sortBy` (type: `string`):

Por defecto: distancia si das un punto; si no, precio (precios) o sin orden (estaciones).

## `includeMaintenance` (type: `boolean`):

Por defecto se omiten.

## `includeRaw` (type: `boolean`):

Agrega `raw` con el objeto de la API (sin razón social ni datos de contacto).

## `maxItems` (type: `integer`):

Tope de filas entregadas y cobradas. Chile tiene ~1.800 estaciones y ~8.000 precios. Por defecto 1000.

## `maxRetries` (type: `integer`):

Reintentos ante errores transitorios. Por defecto 4.

## Actor input object example

```json
{
  "output": "precios",
  "serviceType": "todos",
  "includeMaintenance": false,
  "includeRaw": false,
  "maxItems": 1000,
  "maxRetries": 4
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("better-llama/bencina-en-linea-chile").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("better-llama/bencina-en-linea-chile").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call better-llama/bencina-en-linea-chile --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,better-llama/bencina-en-linea-chile"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/wC75IaYo8p2Vwfw4n/builds/wZYpzrkmYpDEvxlhH/openapi.json
