# Brazil Fuel Prices (ANP): gasolina, diesel, etanol, GLP (`soleene/preco-de-combustivel-da-anp`) Actor

Brazil fuel prices by state from the official ANP weekly survey: gasoline, ethanol, diesel, GNV and LPG per gas station (last 4 weeks). Preços de combustível da ANP por posto e estado.

- **URL**: https://apify.com/soleene/preco-de-combustivel-da-anp.md
- **Developed by:** [Soleene Dados](https://apify.com/soleene) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.05 / 1,000 registros

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

## Preço de combustível da ANP

Preços de revenda da pesquisa semanal da ANP, a partir do CSV público das últimas quatro semanas. Uma execução baixa um grupo (GLP, diesel/GNV ou gasolina/etanol) e devolve as coletas de um estado.

### O que devolve

Cada item é uma coleta: região, UF, município, revenda, CNPJ, endereço do estabelecimento, produto, data, valor de venda, unidade, bandeira e a URL do arquivo. O valor de compra sai nulo quando a coluna vem vazia, que é o caso da série recente.

O endereço é o do posto ou da revenda, publicado no dado aberto. Em uma minoria de linhas a coluna da revenda é um CPF em vez do nome. Com `mascararCpf` ligado (o padrão), esse CPF sai como `***.456.789-**`. O CNPJ da coluna própria não muda.

Exemplo de um registro real (GLP, Amapá, coleta de outubro de 2026):

```json
{
  "regiao": "N",
  "uf": "AP",
  "municipio": "MACAPA",
  "revenda": "GRAVATINHA GAS LTDA",
  "cnpj": "01.470.539/0001-77",
  "rua": "AVENIDA DOS TIMBIRAS",
  "numero": "839",
  "complemento": null,
  "bairro": "BURITIZAL",
  "cep": "68902-872",
  "produto": "GLP",
  "dataColeta": "2026-10-06",
  "valorVenda": 130.0,
  "valorCompra": null,
  "unidade": "R$ / 13 kg",
  "bandeira": "COPA ENERGIA",
  "arquivoUrl": "https://www.gov.br/anp/pt-br/centrais-de-conteudo/dados-abertos/arquivos/shpc/qus/ultimas-4-semanas-glp.csv"
}
```

### Entrada

| Campo | Obrigatório | Padrão | O que faz |
|---|---|---|---|
| `grupo` | sim | — | `glp`, `diesel-gnv` ou `gasolina-etanol`. Cada um é um arquivo |
| `uf` | sim | — | Sigla do estado. O arquivo é nacional; só este estado sai no resultado |
| `produto` | não | todos do arquivo | Dentro do grupo. Exemplo: `DIESEL S10`, `ETANOL`, `GLP` |
| `municipio` | não | todos | Nome do município, sem diferenciar acento nem maiúscula |
| `dataInicio` / `dataFim` | não | o arquivo inteiro | Datas da coleta, inclusive, no formato `AAAA-MM-DD` |
| `mascararCpf` | não | `true` | Mascara CPF que aparecer no texto |
| `limite` | não | 20 | Teto de 10.000 registros |

O arquivo das últimas quatro semanas só contém as semanas que a ANP publicou nele. Não há escolha de mês antigo nesta versão.

### Preço

Cobrança por evento:

| Evento | Preço para quem executa |
|---|---|
| Início de cada execução | US$ 0,0002 |
| Cada registro devolvido | US$ 0,00005 (US$ 0,05 por mil) |

Vinte registros, o limite padrão, custam US$ 0,0012. Mil registros custam US$ 0,0502. Execução sem registro custa só o início, US$ 0,0002.

### Limites

- Uma execução baixa o arquivo nacional do grupo inteiro (de 2 MB a 8 MB) e corta o estado depois, porque a ANP não pagina nem filtra. Por isso o tempo muda pouco com o filtro: cerca de 6 s para o arquivo de gasolina/etanol sem resultado e cerca de 2 minutos para 10.000 registros.
- Teto de 10.000 registros por execução. Se o estado tiver mais coletas do que o limite, o resultado é cortado nele.
- Só as últimas quatro semanas que a ANP publica nesses arquivos. Não há mês antigo nesta versão.
- Um filtro sem resultado não é erro: a execução termina com a mensagem "Nenhum preço encontrado para esses filtros".

### Fonte

GET direto, sem login, nos arquivos:

- GLP: `https://www.gov.br/anp/pt-br/centrais-de-conteudo/dados-abertos/arquivos/shpc/qus/ultimas-4-semanas-glp.csv`
- Diesel e GNV: `.../ultimas-4-semanas-diesel-gnv.csv`
- Gasolina e etanol: `.../ultimas-4-semanas-gasolina-etanol.csv`

UTF-8 com BOM, separador `;`, sem paginação. Medido em 2026-11-04 nesta máquina: GLP 2.252.571 bytes e 13.258 linhas; diesel/GNV 3.696.500 bytes e 21.759 linhas; gasolina/etanol 8.130.008 bytes e 47.555 linhas. Datas de coleta nesse dia: 05/10/2026 a 30/10/2026.

O Actor não contorna nenhuma proteção e não coleta nada além do que a ANP já publica. Os dados são da ANP: confira na fonte antes de usar em reportagem, decisão ou publicação.

### Como testar

Na pasta deste Actor, com o ambiente virtual criado:

```powershell
.venv\Scripts\python -m pytest -m "not live"
.venv\Scripts\python -m pytest -m live
.venv\Scripts\python run_local.py '{"grupo":"glp","uf":"AP","limite":5}'
```

O teste ao vivo baixa o arquivo nacional de GLP (cerca de 2 MB) e devolve 5 coletas do Amapá.

***

### English summary

Brazil fuel prices from the official **ANP** (Agência Nacional do Petróleo) weekly retail price survey: **gasoline, ethanol, diesel, GNV (natural gas) and LPG/GLP (cooking gas)**, per gas station or reseller, by state. Reads ANP's public open-data CSV for the last four weeks and returns clean JSON, CSV or Excel rows with stable field names (in Portuguese).

- **Input**: `grupo` (`glp` | `diesel-gnv` | `gasolina-etanol`, required), `uf` (state code such as `SP`, required), optional `produto`, `municipio`, `dataInicio` / `dataFim` (`YYYY-MM-DD`), `mascararCpf` (default on), `limite` (default 20, max 10,000).
- **Output**: one row per price collection: region, state, city, reseller name and CNPJ, address, product, collection date, sale price (`valorVenda`), unit, brand (`bandeira`) and source file URL. `valorCompra` (purchase price) is empty in recent files.
- **Pricing** (pay per event): US$ 0.0002 per run start and US$ 0.00005 per record (US$ 0.05 per 1,000). A default run of 20 records costs US$ 0.0012.
- **Limits**: ANP does not paginate or filter the file, so each run downloads the national file for the chosen group (2 to 8 MB) and filters by state locally. Only the last four weeks that ANP publishes in these files. Up to 10,000 records per run.
- **Personal data**: in a small share of rows the reseller column holds an individual's CPF instead of a business name. It is masked by default (`mascararCpf`). CNPJ (company id) is not changed. You are responsible for lawful use of the data.
- **Source**: public data from ANP (`gov.br/anp`). This Actor does not bypass any protection and is not affiliated with ANP. Always verify against the source before publishing.

# Actor input Schema

## `grupo` (type: `string`):

Qual arquivo baixar. glp é o menor. diesel-gnv junta diesel e GNV. gasolina-etanol junta gasolina e etanol.

## `uf` (type: `string`):

Sigla do estado. O arquivo é nacional; a execução só devolve este estado.

## `produto` (type: `string`):

Dentro do grupo. GLP. No diesel: DIESEL, DIESEL S10 ou GNV. Na gasolina: GASOLINA, GASOLINA ADITIVADA ou ETANOL. Em branco devolve todos os produtos do arquivo.

## `municipio` (type: `string`):

Nome do município como no arquivo. Ignora acento e maiúscula.

## `dataInicio` (type: `string`):

Data da coleta, inclusive, no formato AAAA-MM-DD. O arquivo só traz as semanas que a ANP publicou nele.

## `dataFim` (type: `string`):

Data da coleta, inclusive, no formato AAAA-MM-DD.

## `mascararCpf` (type: `boolean`):

Ligado por padrão. Em algumas linhas a coluna da revenda é um CPF em vez do nome do estabelecimento. Nesse caso sai mascarado (\***.456.789-**). O CNPJ da coluna própria não muda. Desligue para manter o texto como a fonte publica.

## `limite` (type: `integer`):

Máximo de coletas nesta execução. O padrão é pequeno para teste. O teto é 10.000. A ANP não pagina o arquivo: o grupo inteiro é baixado e o corte acontece depois.

## Actor input object example

```json
{
  "grupo": "glp",
  "uf": "AP",
  "mascararCpf": true,
  "limite": 20
}
```

# Actor output Schema

## `precos` (type: `string`):

Um item por coleta. A visão em tabela está no schema do dataset.

# 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 = {
    "grupo": "glp",
    "uf": "AP"
};

// Run the Actor and wait for it to finish
const run = await client.actor("soleene/preco-de-combustivel-da-anp").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 = {
    "grupo": "glp",
    "uf": "AP",
}

# Run the Actor and wait for it to finish
run = client.actor("soleene/preco-de-combustivel-da-anp").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 '{
  "grupo": "glp",
  "uf": "AP"
}' |
apify call soleene/preco-de-combustivel-da-anp --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,soleene/preco-de-combustivel-da-anp"
        }
    }
}
```

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/ZR5EfQqxrVO8eTbxv/builds/eJCcSo53vv0rExazG/openapi.json
