# IBGE SIDRA by Municipality - Population, GDP, Crops (`kman-br/ibge-sidra-municipios`) Actor

Official IBGE statistics for any Brazilian city, state or the whole country as tidy JSON: population, Census 2022, municipal GDP, crops (PAM), livestock (PPM) or any SIDRA table. Use city names, IBGE codes or a state. Adds ranking, share and change vs previous period.

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

## Pricing

from $0.50 / 1,000 value returneds

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

## IBGE SIDRA by Municipality - Population, GDP, Crops

**EN** · [PT-BR abaixo](#pt-br)

Get official **IBGE** statistics for any Brazilian city, state or the whole country as **tidy JSON**, without learning the SIDRA URL syntax or parsing its header row:

- **Ready-made datasets**: population estimates, Census 2022 (population, area, density), municipal GDP and value added by sector, crop production (PAM: soy, corn, coffee, sugarcane…), livestock herds (PPM: cattle, pigs…).
- **Any SIDRA table** in custom mode (table number + variable codes + raw classification).
- **Friendly places**: `Campinas/SP`, IBGE code `3304557`, or `SP` to get all 645 municipalities of São Paulo state in one call. Ambiguous names (e.g. *Bom Jesus*) are flagged and not charged.
- **Extra context** on every value: ranking and share within your result, previous period value and % change, UF, IBGE notes (`sigiloso`, `zero_absoluto`, `nao_disponivel`).

Use it for market sizing, site selection, sales territory planning, agribusiness intelligence, public policy dashboards and data journalism.

### Input

```json
{ "preset": "lavouras_pam", "localidades": ["MT"], "categorias": ["soja", "milho"], "periodos": "last 2" }
```

```json
{ "preset": "populacao", "localidades": ["Campinas/SP", "3304557", "Santos/SP"], "periodos": "last 3" }
```

### Output

```json
{ "tabela": 6579, "localidade_codigo": "3548500", "localidade_nome": "Santos (SP)", "uf": "SP", "variavel": "População residente estimada", "periodo": "2025", "valor": 433991, "unidade": "Pessoas", "posicao_no_resultado": 3, "participacao_no_resultado_pct": 5.2, "valor_periodo_anterior": 429567, "variacao_periodo_anterior_pct": 1.03 }
```

### Pricing (pay per event)

- US$ 0.01 per run (charged only after the table, variables and places are validated)
- US$ 0.0005 per value (1,000 values = US$ 0.50)

### Source and licence

IBGE - Sistema IBGE de Recuperação Automática (SIDRA), https://sidra.ibge.gov.br, public data, free use with source citation. Aggregated statistics only, no personal data. Not affiliated with IBGE.

***

### PT-BR

Dados oficiais do **IBGE (SIDRA)** por município, UF ou Brasil em JSON organizado:

- Conjuntos prontos: população estimada, Censo 2022, PIB municipal por setor, lavouras (PAM) e rebanhos (PPM). Ou qualquer tabela do SIDRA.
- Localidades por nome (`Campinas/SP`), código IBGE ou sigla da UF (todos os municípios do estado).
- Ranking e participação no resultado, valor do período anterior e variação %.
- Preço: US$ 0,01 por execução + US$ 0,0005 por valor.
- Fonte: IBGE/SIDRA, dados públicos. Sem dado pessoal.

# Actor input Schema

## `preset` (type: `string`):

Ready-made datasets or any SIDRA table.

## `localidades` (type: `array`):

IBGE code, city name (Name/UF) or a state abbreviation (SP = all municipalities of SP). For level uf use SP, RJ... Empty with uf/regiao/brasil = all.

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

Territorial level of the result: municipality, state, macro-region or Brazil.

## `periodos` (type: `string`):

last N, all, 2022, 2019,2021 or 2015-2022.

## `categorias` (type: `array`):

For PAM and PPM: names like soja, milho, cafe, cana-de-acucar, bovino, suino. Default: soja / bovino.

## `tabela` (type: `integer`):

Table number from sidra.ibge.gov.br, e.g. 6579.

## `variaveis` (type: `array`):

SIDRA variable codes. Empty = preset variables (or all for custom).

## `classificacao` (type: `string`):

Raw SIDRA classification, e.g. c782/40124 or c79/all.

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

Cap on charged values.

## Actor input object example

```json
{
  "preset": "populacao",
  "localidades": [
    "Campinas/SP",
    "3304557",
    "Santos/SP"
  ],
  "nivel": "municipio",
  "periodos": "last 1",
  "maxItems": 5000
}
```

# Actor output Schema

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

No description

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

RUN_SUMMARY: status, table, warnings, charged events.

# 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 = {
    "localidades": [
        "Campinas/SP",
        "3304557",
        "Santos/SP"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kman-br/ibge-sidra-municipios").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 = { "localidades": [
        "Campinas/SP",
        "3304557",
        "Santos/SP",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("kman-br/ibge-sidra-municipios").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 '{
  "localidades": [
    "Campinas/SP",
    "3304557",
    "Santos/SP"
  ]
}' |
apify call kman-br/ibge-sidra-municipios --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kman-br/ibge-sidra-municipios"
        }
    }
}
```

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/gEOb0Cx4cD54g6BFZ/builds/Q9nzMf5oHnAhYZKv8/openapi.json
