# Consumidor.gov.br Scraper (`national_scrim/consumidor-gov-scraper`) Actor

Lê reclamações e indicadores públicos do Consumidor.gov.br via dados abertos.

- **URL**: https://apify.com/national\_scrim/consumidor-gov-scraper.md
- **Developed by:** [Bruno-Arantir](https://apify.com/national_scrim) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

## Consumidor.gov.br Scraper

**Open data from dados.mj.gov.br → structured Consumidor.gov.br complaints and indicators.**

Enriqueça due diligence e monitoramento de marca com a **base pública** do [Consumidor.gov.br](https://www.consumidor.gov.br) publicada pela Senacon em [dados.mj.gov.br](https://dados.mj.gov.br/dataset/reclamacoes-do-consumidor-gov-br).

- Lê o CKAN `package_show` e os CSVs mensais “Base Completa” (Creative Commons Atribuição).
- Filtra por nome fantasia, CNPJ (se a coluna existir) e intervalo de datas.
- Devolve empresa, segmento, área, assunto, problema, UF/cidade, situação, nota e prazos — **sem sexo, faixa etária, CPF ou contato**.
- HTTP JSON/CSV. Relato/Indicadores que exigem login de empresa **não** são usados (sem OAuth).
- Dedup por hash estável e teto rígido de `maxItems` (5.000).

### Fonte

`GET https://dados.mj.gov.br/api/3/action/package_show?id=reclamacoes-do-consumidor-gov-br`

A API autenticada de empresa (`api.consumidor.gov.br`) fica de fora de propósito.

### Amostra de saída

Estrutura real do dicionário de dados abertos (PII removida):

```json
{
  "id": "c0ffee12ab34cd56",
  "source": "dados-abertos",
  "company": "Nubank",
  "segment": "Bancos, Financeiras e Administradoras de Cartão",
  "area": "Serviços Financeiros",
  "subject": "Cartão de Crédito",
  "uf": "SP",
  "situation": "Finalizada avaliada",
  "score": 4,
  "finalizedAt": "2026-03-12"
}
```

Exemplo ilustrativo de formato — rode o Actor para o CSV do mês vigente.

### Configuração

| Campo | Default | Descrição |
| --- | --- | --- |
| `company` | Nubank | Nome fantasia |
| `cnpj` | — | Só se o CSV trouxer a coluna |
| `dateFrom` / `dateTo` | jan–jun 2026 | Recorte de `Data Finalização` |
| `maxItems` | 50 | Teto 5.000 |
| `resourceUrl` | — | CSV direto do pacote CKAN |
| `proxyConfiguration` | — | Opcional |

### PPE

Evento `dataset-item`: **US$ 1,50–2,50 / 1.000 registros** sugerido (referência US$ 2).

### LGPD

A Senacon já anonimiza a base. Ainda assim o Actor **descarta** sexo, faixa etária e qualquer coluna de contato. Cidade/UF da reclamação são dados do arquivo público. Não é produto oficial do MJ/Senacon.

O portal `dados.mj.gov.br` precisa resolver DNS no ambiente de execução (Apify costuma alcançar). Se o CKAN estiver fora do ar, o run falha de forma explícita — não inventa reclamações.

### Desenvolvimento

```bash
cd actors/consumidor-gov-scraper
npm install && npm test && npm run build
apify run
```

# Actor input Schema

## `company` (type: `string`):

Filtro no campo público Nome Fantasia (ex.: Nubank, Magalu).

## `cnpj` (type: `string`):

Opcional. Só filtra se o CSV do mês trouxer coluna de CNPJ.

## `dateFrom` (type: `string`):

YYYY-MM-DD. Recorta o campo Data Finalização e escolhe CSVs mensais que cruzam o período.

## `dateTo` (type: `string`):

YYYY-MM-DD.

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

Limite rígido (teto 5.000). Os CSVs mensais são grandes — use o teto.

## `resourceUrl` (type: `string`):

Pule o CKAN e leia um CSV público já conhecido do pacote dados.mj.gov.br.

## `proxyConfiguration` (type: `object`):

Opcional. O portal de dados abertos costuma responder sem proxy.

## Actor input object example

```json
{
  "company": "Nubank",
  "dateFrom": "2026-01-01",
  "dateTo": "2026-06-30",
  "maxItems": 20
}
```

# Actor output Schema

## `results` (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 = {
    "company": "Nubank",
    "dateFrom": "2026-01-01",
    "dateTo": "2026-06-30",
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("national_scrim/consumidor-gov-scraper").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 = {
    "company": "Nubank",
    "dateFrom": "2026-01-01",
    "dateTo": "2026-06-30",
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("national_scrim/consumidor-gov-scraper").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 '{
  "company": "Nubank",
  "dateFrom": "2026-01-01",
  "dateTo": "2026-06-30",
  "maxItems": 20
}' |
apify call national_scrim/consumidor-gov-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,national_scrim/consumidor-gov-scraper"
        }
    }
}
```

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/z76SQJnDy3N6T0PYl/builds/wnuRuRuQziVByjUjF/openapi.json
