A command-line tool to query Brazilian judicial process data from the CNJ DataJud public API.
- Query a process by its CNJ number (with or without formatting mask)
- Output as table, JSON, or CSV
- Local cache (24h TTL) to avoid repeated API calls
- Supports multiple tribunals (TJBA, TJSP, TRF1, TJMG, STJ)
- Retry with backoff on rate limits
- Bulk query from file
- Installable via
pipx install datajud-cli
git clone https://github.com/cleisabino/datajud-cli.git
cd datajud-cli
python -m venv .venv
source .venv/bin/activate
pip install -e .Copy .env.example to .env and add your DataJud API key:
cp .env.example .env
# edit .env and set DATAJUD_API_KEYGet the public API key at: https://datajud-wiki.cnj.jus.br/api-publica/acesso/
# with formatting mask (auto-normalized)
datajud query 8050490-37.2021.8.05.0001
# raw 20-digit number
datajud query 80504903720218050001
# different tribunal
datajud query 8050490-37.2021.8.05.0001 --tribunal tjsp# default: formatted table
datajud query 8050490-37.2021.8.05.0001
# JSON
datajud query 8050490-37.2021.8.05.0001 --json
# CSV (pipeable)
datajud query 8050490-37.2021.8.05.0001 --csv >> processos.csv# skip cache and hit the API directly
datajud query 8050490-37.2021.8.05.0001 --no-cache
# clear local cache
datajud limpar-cache| Sigla | Tribunal |
|---|---|
| tjba | Tribunal de Justiça da Bahia |
| tjsp | Tribunal de Justiça de São Paulo |
| trf1 | Tribunal Regional Federal da 1ª Região |
| tjmg | Tribunal de Justiça de Minas Gerais |
| stj | Superior Tribunal de Justiça |
- Python 3.12
- Typer — CLI framework
- httpx — HTTP client
- Pydantic — data validation
- Rich — terminal formatting
- diskcache — local cache
pytest tests/ -vMIT — see LICENSE.
Built by Clei Sabino · Senior Backend Engineer · 7+ years building legal systems for Brazilian public sector.