# Brazil DataJud Court Case Metadata (`automatic/brazil-datajud-scraper`) Actor

Search Brazilian public court case metadata across tribunal indices. Filter CNJ case numbers, class, subjects and filing dates; export normalized court metadata and optional latest movements.

- **URL**: https://apify.com/automatic/brazil-datajud-scraper.md
- **Developed by:** [Philip Kirkbride](https://apify.com/automatic) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 83.3% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 court cases

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

## Brazil DataJud Court Case Metadata

Search public Brazilian court metadata across multiple tribunals in one run.
Filter by CNJ case numbers, class and subject codes, or filing dates. Export
consistent English fields with original Portuguese code labels, source links,
and optional latest movements.

Use this Actor only for lawful KYC, credit and legal research under Brazil's
LGPD. You are responsible for establishing and documenting your own legal
basis, purpose, necessity, retention period and access controls. Public
availability alone does not establish a legal basis. Do not use this Actor to
profile individuals or make automated adverse decisions about them. Case
metadata is not evidence of liability, guilt or creditworthiness. Seek qualified
legal advice for your intended processing.

### Quick start

```json
{"tribunals":["TRT1","TRF1","TJSP"],"maxResults":20}
```

The default searches three tribunal indices and returns up to 20 records.
Tribunals are visited in turn, each with its own pagination cursor. Results are
ordered by source update timestamp within each tribunal, oldest first; the
combined output has no global ordering. A cap can leave some tribunals
unvisited. This is a metadata snapshot, not a complete judicial background check.

### Inputs

| Input | Default | Meaning |
|---|---|---|
| `tribunals` | `["TRT1","TRF1","TJSP"]` | Official tribunal codes; `["all"]` expands the selected group. |
| `tribunalGroup` | `TRT` | `TJ` state and state military, `TRF` federal, `TRT` labour, or `TRE` electoral; used only for `all`. |
| `caseNumbers` | `[]` | Up to 100 formatted or bare 20-digit CNJ case numbers. |
| `classCodes` | `[]` | Numeric TPU class codes. |
| `subjectCodes` | `[]` | Numeric TPU subject codes. |
| `filingDateFrom`, `filingDateTo` | omitted | Inclusive `YYYY-MM-DD` filing date range. |
| `maxResults` | `20` | Global cap, 1–10,000 records. |
| `includeMovements` | `false` | Add latest public movement date/code/name triples. |
| `latestMovements` | `5` | Movement limit per row, 1–100. |
| `apiKey` | resolved at runtime | Optional public-key override. Otherwise `DATAJUD_API_KEY`, then the current key on CNJ's official access wiki. |

Values within a code list match any value; different filters are combined.
Case-number searches derive their tribunal indices from the CNJ J.TR segment, overriding the tribunal selection.
Filing-date filters include both ISO dates and compact CNJ timestamps, with inclusive calendar-day bounds.
For a federal search, use `{"tribunals":["all"],"tribunalGroup":"TRF","maxResults":100}`.
Supported tribunal codes come from CNJ's published catalogue (91 endpoints at
capture); a renamed or newly added index requires a catalogue update.

### Output

One row represents a source case record. The same CNJ case can appear in several
degrees or courts; rows are deduplicated by source index and record ID.

Fields: `caseId`, `caseNumber`, `tribunal`, `court`, `class`, `subjects`,
`filingDate`, `filingDateRaw`, `lastUpdate`, `degree`, `system`, `format`,
`movementCount`, `latestMovements`, `sourceIndex`, `sourceUrl`, `scrapedAt`.
Court, class, subjects, system and format carry `code` and `name`. Latest
movements carry `code`, `name` and `date`; the array is empty when disabled.
The source URL is the official search API and requires a POST query to reproduce
the row, rather than opening a case detail page.

Dates use ISO 8601. Compact source filing dates have no published timezone and
remain without an offset; `filingDateRaw` preserves the original value.
`scrapedAt` is UTC retrieval time and does not establish source freshness.
CNJ records can lag court systems; sealed cases and unpublished information
are outside coverage. No party names, movement complements or external
personal-data enrichment are included.

### Reliability and limits

The Actor delivers each page as it arrives. It retries temporary failures,
respects server retry waits, confirms empty pages with a new session and reserves
time to save results. If some tribunals fail after rows were delivered, the run
succeeds with an incomplete-query status naming those tribunals. Zero delivered
rows fails plainly, including a genuinely empty search; inspect the status.
A reached row cap is a partial search, not an assertion of full coverage.
Pagination uses timestamp and record ID, stops on repeated cursors, and rejects
partial-shard pages. Changes to a live index during traversal may still affect
coverage; the API does not provide a snapshot guarantee in this Actor.

Example public metadata row from the local validation run:

```json
{
  "caseId": "TRT1_G2_01016068820245010483",
  "caseNumber": "0101606-88.2024.5.01.0483",
  "tribunal": "TRT1",
  "court": {
    "code": 82967,
    "name": "Gabinete 52"
  },
  "class": {
    "code": 1009,
    "name": "Recurso Ordinário Trabalhista"
  },
  "subjects": [
    {
      "code": 13769,
      "name": "Horas Extras"
    },
    {
      "code": 13771,
      "name": "intervalo Interjonadas"
    },
    {
      "code": 13772,
      "name": "Intervalo Intrajornada"
    },
    {
      "code": 13773,
      "name": "Repouso Semanal Remunerado e Feriado"
    },
    {
      "code": 13787,
      "name": "Adicional de Horas Extras"
    },
    {
      "code": 13790,
      "name": "Comissionista"
    },
    {
      "code": 13799,
      "name": "Adicional de Hora Extra"
    },
    {
      "code": 13839,
      "name": "Comissões e Percentuais"
    },
    {
      "code": 13851,
      "name": "Participação nos Lucros e Resultados - PLR"
    }
  ],
  "filingDate": "2026-03-11T08:40:44",
  "filingDateRaw": "20260311084044",
  "lastUpdate": "2026-07-07T02:04:01.848000Z",
  "degree": "G2",
  "system": {
    "code": 1,
    "name": "PJe"
  },
  "format": {
    "code": 1,
    "name": "Eletrônico"
  },
  "movementCount": 6,
  "latestMovements": [],
  "sourceIndex": "api_publica_trt1",
  "sourceUrl": "https://api-publica.datajud.cnj.jus.br/api_publica_trt1/_search",
  "scrapedAt": "2026-11-01T00:48:14.166153Z"
}
```

# Actor input Schema

## `tribunals` (type: `array`):

Official tribunal codes to query in one run; use \["all"] for every tribunal in tribunalGroup.

## `tribunalGroup` (type: `string`):

Group expanded when tribunals is \["all"]. TJ state, TRF federal, TRT labour, TRE electoral.

## `caseNumbers` (type: `array`):

Optional CNJ identifiers, 20 digits or formatted NNNNNNN-DD.YYYY.J.TR.OOOO; up to 100.

## `classCodes` (type: `array`):

Optional numeric TPU class codes; OR within this filter, AND with other filters.

## `subjectCodes` (type: `array`):

Optional numeric TPU subject codes; OR within this filter, AND with other filters.

## `filingDateFrom` (type: `string`):

Inclusive filing date lower bound, YYYY-MM-DD.

## `filingDateTo` (type: `string`):

Inclusive filing date upper bound, YYYY-MM-DD.

## `maxResults` (type: `integer`):

Maximum delivered case records across all selected tribunals.

## `includeMovements` (type: `boolean`):

Include the latest N public movement date/code/name triples. Count is always included.

## `latestMovements` (type: `integer`):

Maximum movements per row when includeMovements is true.

## `apiKey` (type: `string`):

Optional current published CNJ public key. Otherwise use DATAJUD_API_KEY or retrieve the current public key from the official access wiki.

## Actor input object example

```json
{
  "tribunals": [
    "TRT1",
    "TRF1",
    "TJSP"
  ],
  "tribunalGroup": "TRT",
  "caseNumbers": [],
  "classCodes": [],
  "subjectCodes": [],
  "maxResults": 20,
  "includeMovements": false,
  "latestMovements": 5
}
```

# 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 = {
    "tribunals": [
        "TRT1",
        "TRF1",
        "TJSP"
    ],
    "maxResults": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("automatic/brazil-datajud-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 = {
    "tribunals": [
        "TRT1",
        "TRF1",
        "TJSP",
    ],
    "maxResults": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("automatic/brazil-datajud-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 '{
  "tribunals": [
    "TRT1",
    "TRF1",
    "TJSP"
  ],
  "maxResults": 20
}' |
apify call automatic/brazil-datajud-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,automatic/brazil-datajud-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/kkwutoGio7f9JhZsA/builds/z087vHmnObPN7kNCt/openapi.json
