# TJMG Scraper (`national_scrim/tjmg-scraper`) Actor

Consulta pública do TJMG (andamento processual) sem login.

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

## Pricing

from $5.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

## TJMG Scraper

**Public TJMG (Minas Gerais court) process consultation — andamentos without lawyer login.**

Consulte andamentos **públicos** do Tribunal de Justiça de Minas Gerais para monitoramento. Sem senha, sem cookie de advogado, sem resolver CAPTCHA.

- **Fonte principal (sem CAPTCHA):** DataJud `api_publica_tjmg` ([wiki CNJ](https://datajud-wiki.cnj.jus.br/api-publica/acesso/)).
- Fallback: andamento clássico `www4.tjmg.jus.br/juridico/sf/`.
- `sessionCookies` (opcional): Cookie da **sua** sessão pública. Sem CAPTCHA solve.
- Fail closed em login wall (`login.seam`), CAPTCHA ou “Serviço Indisponível”.

### URLs públicas descobertas

| Uso | URL |
| --- | --- |
| Portal institucional (links) | `https://www.tjmg.jus.br/portal-tjmg/processos/andamento-processual/` |
| UI nova (Next.js, pouco SSR) | `https://consulta.tjmg.jus.br/home` |
| Andamento 1ª instância — números | `https://www4.tjmg.jus.br/juridico/sf/index.jsp` |
| Andamento 1ª instância — partes | `https://www4.tjmg.jus.br/juridico/sf/index_nome.jsp` |
| Andamento 1ª instância — OAB | `https://www4.tjmg.jus.br/juridico/sf/index_oab.jsp` |
| Resultados | `https://www4.tjmg.jus.br/juridico/sf/proc_resultado.jsp?comrCodigo={comarca}&numero={n}` |
| Complemento | `https://www4.tjmg.jus.br/juridico/sf/proc_complemento.jsp?comrCodigo=&numero=` |
| 2ª instância (números) | `https://www4.tjmg.jus.br/juridico/sf/proc_massiva2.jsp` |
| PJe consulta pública 1º grau | `https://pje-consulta-publica.tjmg.jus.br/` (e `.../pje/ConsultaPublica/listView.seam`) |
| PJe recursal | `https://pjerecursal.tjmg.jus.br/pje/ConsultaPublica/listView.seam` |
| PROJUDI consulta pública | `https://projudi.tjmg.jus.br/projudi/interno.jsp?endereco=/projudi/consultapublica/CentroConsultaPublica` |

O Actor **consulta** o JSP `proc_resultado.jsp` (form GET `comrCodigo` + `numero`). CNJ `*.8.13.OOOO` → comarca `OOOO` (ex. 0024 = Belo Horizonte).

`consulta.tjmg.jus.br` é app client-side (`__NEXT_DATA__` vazio) — não é fonte HTTP estável.

PJe 1º grau às vezes mostra formulário público com recaptcha; `pje-consulta-publica` já redirecionou para `login.seam` neste ambiente. **Login wall = fail closed.** Não há bypass.

O JSP de resultados carrega `ValidacaoCaptchaAction.js` mesmo quando a tabela pública já veio no HTML. Script de captcha ≠ parede. Input/recaptcha ativo = parede.

### Amostra de saída

Exemplo ilustrativo (formato do parser; rode o Actor para um CNJ real).

```json
{
  "processNumber": "5001234-12.2023.8.13.0024",
  "class": "Procedimento Comum Cível",
  "comarca": "Belo Horizonte",
  "parties": ["Autor Exemplo", "Réu Exemplo"],
  "lastMovementDate": "2026-08-15T00:00:00.000Z",
  "sourceUrl": "https://www4.tjmg.jus.br/juridico/sf/proc_resultado.jsp?comrCodigo=24&numero=5001234",
  "sourcePath": "/juridico/sf/proc_resultado.jsp"
}
```

### Configuração

| Campo | Default | Descrição |
| --- | --- | --- |
| `processNumbers` | — | Lista CNJ |
| `partyName` | — | Nome público da parte |
| `comarcaCode` | 24 | BH; sobrescreve origem do CNJ |
| `maxItems` | 20 | Teto 5.000 |
| `delayMs` | 800 | Pausa entre consultas |
| `proxyConfiguration` | — | Opcional |

### PPE

Evento `dataset-item`: **US$ 5,00 / 1.000 processos** sugerido (HTML legado + paredes frequentes no PJe).

### LGPD / ética

Nomes de partes em andamento público são dados pessoais. Segredo de justiça, vítimas, procedimentos investigatórios e processos baixados de natureza criminal **não devem** ser alvo — o próprio TJMG omite esses resultados. Sem login, sem CAPTCHA solve, sem área de advogado.

### Desenvolvimento

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

# Actor input Schema

## `processNumbers` (type: `array`):

Padrão CNJ. Justiça Estadual de MG é 8.13.OOOO — a origem vira comrCodigo.

## `partyName` (type: `string`):

Tenta proc\_nome.jsp após a comarca. O formulário oficial (index\_nome.jsp) é em duas etapas; se só houver parede de login/CAPTCHA, o Actor falha fechado.

## `comarcaCode` (type: `string`):

Sobrescreve a origem do CNJ. Belo Horizonte = 24. Obrigatório na prática para busca só por nome.

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

Limite rígido (teto 5.000).

## `delayMs` (type: `integer`):

Intervalo em milissegundos entre consultas consecutivas ao TJMG, para reduzir carga no servidor público. Padrão: 400.

## `sessionCookies` (type: `string`):

Cole o header Cookie copiado do SEU navegador na consulta pública do TJMG. Só cookies próprios. Sem CAPTCHA solve e sem login de terceiros.

## `datajudApiKey` (type: `string`):

Padrão: chave pública oficial do CNJ. Só preencha se o CNJ rotacionar.

## `skipDatajud` (type: `boolean`):

Força só o JSP www4 / PJe.

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

Para o JSP/PJe: Apify RESIDENTIAL + BR. DataJud costuma funcionar sem proxy.

## Actor input object example

```json
{
  "processNumbers": [
    "5000000-00.2023.8.13.0024"
  ],
  "comarcaCode": "24",
  "maxItems": 5,
  "delayMs": 400,
  "skipDatajud": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# 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 = {
    "processNumbers": [
        "5000000-00.2023.8.13.0024"
    ],
    "comarcaCode": "24",
    "maxItems": 5,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("national_scrim/tjmg-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 = {
    "processNumbers": ["5000000-00.2023.8.13.0024"],
    "comarcaCode": "24",
    "maxItems": 5,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("national_scrim/tjmg-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 '{
  "processNumbers": [
    "5000000-00.2023.8.13.0024"
  ],
  "comarcaCode": "24",
  "maxItems": 5,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call national_scrim/tjmg-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,national_scrim/tjmg-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/wdL1D6OMJq5dDchzC/builds/SQk0g3jXMzuvIJjUf/openapi.json
