# Diesel ANP — Preço do Diesel por Município/UF (`kman-br/diesel-anp`) Actor

Preços médios, mínimos e máximos semanais do diesel (S10/S500) direto do levantamento oficial da ANP, por UF ou município, com número de postos, variação semanal e link da planilha de origem.

- **URL**: https://apify.com/kman-br/diesel-anp.md
- **Developed by:** [Kman](https://apify.com/kman-br) (community)
- **Categories:** Business, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 preço regionals

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

## Diesel ANP — Preço do Diesel por Município/UF

### Português

Preços semanais **oficiais** do diesel S10 e S500 direto do Levantamento de Preços de Combustíveis da ANP, por município ou por posto (pessoa jurídica). Cada linha traz preço médio, mínimo e máximo, número de postos pesquisados, variação semanal e o link da planilha oficial de origem.

#### Para que serve

- Acompanhar o preço do diesel na sua cidade ou UF, semana a semana.
- Comparar regiões e alertar sobre variações fortes.
- Alimentar planilhas de custo de frete e frota.

#### Input

| Campo | Padrão | Descrição |
| --- | --- | --- |
| `produto` | `diesel_s10` | `diesel_s10`, `diesel_s500` ou `todos` (os dois tipos). |
| `ufs` | `[]` | Siglas de UF, como `SP` e `PR`. Vazio = todas. |
| `municipios` | `[]` | Nomes de municípios (sem diferenciar acentos/maiúsculas). Vazio = todos. |
| `nivel` | `municipio` | `municipio` (médias) ou `posto` (preço por posto pessoa jurídica). |
| `semanas` | `1` | Últimas N semanas publicadas pela ANP. |
| `alertaVariacaoPct` | — | Opcional: registra no resumo as variações iguais ou acima do limite. |

#### Saída

Campos: `semana_inicio`, `semana_fim`, `uf`, `municipio`, `produto`, `preco_medio`, `preco_min`, `preco_max`, `n_postos`, `variacao_semana_pct`, `source_url`, `retrieved_at`, `source_name`, `warnings`, `status`. No nível posto: `revenda_cnpj`, `revenda_nome`, `bandeira` e `preco`.

```json
{
  "semana_inicio": "2026-10-04",
  "semana_fim": "2026-10-10",
  "uf": "PR",
  "municipio": "CURITIBA",
  "produto": "diesel_s10",
  "preco_medio": 7.24,
  "preco_min": 6.89,
  "preco_max": 8.54,
  "n_postos": 28,
  "variacao_semana_pct": null,
  "source_url": "https://www.gov.br/anp/pt-br/assuntos/precos-e-defesa-da-concorrencia/precos/arquivos-lpc/2026/resumo_semanal_lpc_2026-10-04_2026-10-10.xlsx",
  "source_name": "ANP - Levantamento de Preços de Combustíveis",
  "warnings": ["variacao_semana_pct: semana anterior comparável indisponível"],
  "status": "parcial"
}
```

`status`: `ok` (completo), `parcial` (algum campo indisponível, com aviso) ou `erro` (falha da fonte, com diagnóstico gratuito). Valores ausentes ficam `null` com aviso; nada é inventado. Para a variação semanal na primeira coleta, use `semanas` ≥ 2. Runs seguintes sem semana nova terminam rápido e sem itens.

#### Privacidade

Somente dados públicos da ANP. No nível posto, só entram postos com CNPJ; razões sociais que parecem nome de pessoa física (MEI/empresário individual) são mascaradas, e endereços ou contatos não são coletados.

#### Preço

**US$ 1 por 1.000 linhas de preço válidas** (US$ 0,001 por evento `regional-price`). Você paga só pelos resultados válidos: erros, diagnósticos e execuções sem semana nova ou sem resultado são gratuitos. O teto de gasto definido por você é respeitado. Sem custo de plataforma para o usuário.

### English

Official weekly **diesel S10/S500 prices** from Brazil's ANP fuel price survey, by city or by fuel station (companies only). Each row has average, minimum and maximum price, number of stations surveyed, week-over-week change and a link to the official source spreadsheet.

**Input:** `produto` (`diesel_s10`, `diesel_s500`, `todos`), `ufs`, `municipios`, `nivel` (`municipio` or `posto`), `semanas` (last N weeks) and optional `alertaVariacaoPct`.

**Output:** see the fields and example above. Status is `ok`, `parcial` or `erro`; missing values are `null` with a warning, never invented. Unchanged runs finish quickly with zero rows. Station names that look like a person's name are masked (LGPD).

**Pricing:** **US$1 per 1,000 valid price rows** (US$0.001 per `regional-price` event). You pay only for valid results; errors, diagnostics and unchanged or empty runs are free. Your spending limit is respected. No platform usage cost for users.

Data source: [ANP — Levantamento de Preços de Combustíveis](https://www.gov.br/anp/pt-br/assuntos/precos-e-defesa-da-concorrencia/precos). This Actor is independent and not affiliated with the Brazilian government.

# Actor input Schema

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

todos inclui somente os dois tipos de diesel.

## `ufs` (type: `array`):

Siglas das UFs, por exemplo SP e PR; vazio inclui todas.

## `municipios` (type: `array`):

Nomes exatos, comparados sem acentos e sem distinção de maiúsculas; vazio inclui todos.

## `nivel` (type: `string`):

Médias municipais ou observações de preços de postos pessoa jurídica.

## `semanas` (type: `integer`):

Últimas N semanas disponíveis na página oficial. A disponibilidade histórica é limitada pela página.

## `alertaVariacaoPct` (type: `number`):

Opcional. Variação absoluta igual ou superior ao limiar é registrada em RUN_SUMMARY.alertas; não altera o dataset.

## Actor input object example

```json
{
  "produto": "diesel_s10",
  "ufs": [],
  "municipios": [],
  "nivel": "municipio",
  "semanas": 1
}
```

# Actor output Schema

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

Itens do dataset padrão.

# 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("kman-br/diesel-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("kman-br/diesel-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 '{}' |
apify call kman-br/diesel-anp --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kman-br/diesel-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/GoNd5V9KiccUuruQs/builds/WCbwPuF4xeH9WqcU2/openapi.json
