# Preços de Combustíveis por Município — ANP (`jenko_systems/brazil-fuel-prices-anp`) Actor

Preços semanais de combustíveis (gasolina, diesel, etanol, GLP, GNV) para 567 municípios brasileiros de 2001 até hoje. Fonte: ANP — Agência Nacional do Petróleo.

Weekly fuel prices (gasoline, diesel, ethanol, GLP, GNV) for 567 Brazilian municipalities from 2001 to present. Source: ANP.

- **URL**: https://apify.com/jenko\_systems/brazil-fuel-prices-anp.md
- **Developed by:** [Jenko Systems](https://apify.com/jenko_systems) (community)
- **Categories:** Automation
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.00005 / actor start

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Preços de Combustíveis por Município — ANP

A API mais completa para preços de combustíveis no Brasil — série histórica semanal de 2001 até hoje, com dados diretamente da ANP (Agência Nacional do Petróleo, Gás Natural e Biocombustíveis).

### O que você recebe

- **3,2 milhões de registros** de preços semanais
- **567 municípios** em todos os 27 estados
- **Série histórica** de 2001 até hoje (atualizada toda sexta-feira)
- **7 tipos de combustível**: Diesel, Diesel S10, Gasolina Comum, Gasolina Aditivada, Etanol, GLP, GNV

### Modos de consulta

#### `current_week` — Médias nacionais da semana atual
```json
{ "mode": "current_week" }
````

Retorna as médias nacionais mais recentes para todos os combustíveis, com mínimo e máximo.

#### `municipality` — Preços em um município específico

```json
{
  "mode": "municipality",
  "municipality": "PIRACICABA",
  "fuel": "OLEO DIESEL S10"
}
```

#### `state` — Todos os municípios de um estado

```json
{
  "mode": "state",
  "state": "SP",
  "fuel": "GASOLINA COMUM"
}
```

#### `ranking` — Mais caro / mais barato

```json
{
  "mode": "ranking",
  "fuel": "OLEO DIESEL S10",
  "top_n": 20
}
```

#### `historical` — Evolução histórica de preços

```json
{
  "mode": "historical",
  "fuel": "OLEO DIESEL S10",
  "date_from": "2015-01-01",
  "granularity": "yearly"
}
```

### Combustíveis disponíveis

| Código | Descrição |
|--------|-----------|
| `OLEO DIESEL` | Óleo Diesel comum |
| `OLEO DIESEL S10` | Óleo Diesel S10 (baixo enxofre) |
| `GASOLINA COMUM` | Gasolina Comum |
| `GASOLINA ADITIVADA` | Gasolina Aditivada |
| `ETANOL HIDRATADO` | Etanol Hidratado |
| `GLP` | GLP — gás de cozinha (R$/botijão 13kg) |
| `GNV` | GNV — gás natural veicular (R$/m³) |

### Casos de uso

- **Transportadoras e logística**: monitorar preço do diesel por rota e município
- **Agronegócio**: acompanhar custo de combustível para operações agrícolas
- **Fintechs e seguradoras**: modelos atuariais de custo de transporte
- **Pesquisa e jornalismo**: série histórica de 25 anos para análise econômica
- **Postos e distribuidoras**: inteligência competitiva de preços por região

### Fonte dos dados

Todos os dados são coletados da ANP ([gov.br/anp](https://www.gov.br/anp)) sob licença de dados abertos. Atualizado toda sexta-feira quando a ANP publica o levantamento semanal.

### Unidade de medida

R$/litro — exceto GLP que é R$/botijão 13kg.

# Actor input Schema

## `mode` (type: `string`):

Escolha o que deseja consultar: resumo da semana atual, preços em um município, todos os municípios de um estado, ranking de preços ou evolução histórica.

## `state` (type: `string`):

Sigla do estado brasileiro. Exemplos: SP, RJ, MG, PR, RS. Obrigatório nos modos 'Estado' e 'Ranking'.

## `municipality` (type: `string`):

Nome do município em maiúsculas. Exemplos: PIRACICABA, CAMPINAS, SAO PAULO. Obrigatório no modo 'Município'.

## `fuel` (type: `string`):

Filtrar por tipo de combustível. Deixe em branco para retornar todos os combustíveis.

## `top_n` (type: `integer`):

Quantos municípios exibir no ranking (mais caros e mais baratos). Usado apenas no modo 'Ranking'.

## `date_from` (type: `string`):

Início do período histórico no formato AAAA-MM-DD. Exemplo: 2020-01-01. Usado apenas no modo 'Histórico'.

## `date_to` (type: `string`):

Fim do período histórico no formato AAAA-MM-DD. Padrão: hoje. Usado apenas no modo 'Histórico'.

## `granularity` (type: `string`):

Como agrupar os dados históricos: por semana, mês ou ano. Usado apenas no modo 'Histórico'.

## Actor input object example

```json
{
  "mode": "current_week",
  "fuel": "OLEO DIESEL S10",
  "top_n": 20,
  "granularity": "monthly"
}
```

# 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("jenko_systems/brazil-fuel-prices-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("jenko_systems/brazil-fuel-prices-anp").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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 jenko_systems/brazil-fuel-prices-anp --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=jenko_systems/brazil-fuel-prices-anp",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Preços de Combustíveis por Município — ANP",
        "description": "Preços semanais de combustíveis (gasolina, diesel, etanol, GLP, GNV) para 567 municípios brasileiros de 2001 até hoje. Fonte: ANP — Agência Nacional do Petróleo.\n\nWeekly fuel prices (gasoline, diesel, ethanol, GLP, GNV) for 567 Brazilian municipalities from 2001 to present. Source: ANP.",
        "version": "1.0",
        "x-build-id": "sFEMpEU2dOeeTW0sn"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/jenko_systems~brazil-fuel-prices-anp/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-jenko_systems-brazil-fuel-prices-anp",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/jenko_systems~brazil-fuel-prices-anp/runs": {
            "post": {
                "operationId": "runs-sync-jenko_systems-brazil-fuel-prices-anp",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/jenko_systems~brazil-fuel-prices-anp/run-sync": {
            "post": {
                "operationId": "run-sync-jenko_systems-brazil-fuel-prices-anp",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "mode"
                ],
                "properties": {
                    "mode": {
                        "title": "Modo de consulta",
                        "enum": [
                            "current_week",
                            "municipality",
                            "state",
                            "ranking",
                            "historical"
                        ],
                        "type": "string",
                        "description": "Escolha o que deseja consultar: resumo da semana atual, preços em um município, todos os municípios de um estado, ranking de preços ou evolução histórica.",
                        "default": "current_week"
                    },
                    "state": {
                        "title": "Estado (sigla)",
                        "type": "string",
                        "description": "Sigla do estado brasileiro. Exemplos: SP, RJ, MG, PR, RS. Obrigatório nos modos 'Estado' e 'Ranking'."
                    },
                    "municipality": {
                        "title": "Município",
                        "type": "string",
                        "description": "Nome do município em maiúsculas. Exemplos: PIRACICABA, CAMPINAS, SAO PAULO. Obrigatório no modo 'Município'."
                    },
                    "fuel": {
                        "title": "Combustível",
                        "enum": [
                            "",
                            "OLEO DIESEL",
                            "OLEO DIESEL S10",
                            "GASOLINA COMUM",
                            "GASOLINA ADITIVADA",
                            "ETANOL HIDRATADO",
                            "GLP",
                            "GNV"
                        ],
                        "type": "string",
                        "description": "Filtrar por tipo de combustível. Deixe em branco para retornar todos os combustíveis.",
                        "default": "OLEO DIESEL S10"
                    },
                    "top_n": {
                        "title": "Tamanho do ranking",
                        "minimum": 5,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Quantos municípios exibir no ranking (mais caros e mais baratos). Usado apenas no modo 'Ranking'.",
                        "default": 20
                    },
                    "date_from": {
                        "title": "Data inicial",
                        "type": "string",
                        "description": "Início do período histórico no formato AAAA-MM-DD. Exemplo: 2020-01-01. Usado apenas no modo 'Histórico'."
                    },
                    "date_to": {
                        "title": "Data final",
                        "type": "string",
                        "description": "Fim do período histórico no formato AAAA-MM-DD. Padrão: hoje. Usado apenas no modo 'Histórico'."
                    },
                    "granularity": {
                        "title": "Granularidade temporal",
                        "enum": [
                            "weekly",
                            "monthly",
                            "yearly"
                        ],
                        "type": "string",
                        "description": "Como agrupar os dados históricos: por semana, mês ou ano. Usado apenas no modo 'Histórico'.",
                        "default": "monthly"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
