juscraper
Scraper for Brazilian courts and other systems of the Brazilian judiciary.
Installation
From PyPI (recommended)
pip install juscraperWith uv
uv add juscraperDevelopment version
To install the latest version from the repository:
pip install git+https://github.com/jtrecenti/juscraper.gitUsage
import juscraper as jus
tjsp = jus.scraper('tjsp')
dados_cjpg = tjsp.cjpg('league of legends', paginas=range(1, 4))
dados_cjpg.head(3)The package covers the basic needs of querying case data in a set of courts.
Most courts implement some of the methods below; the tables in the Implementations section show which ones each court and aggregator has (the STF, for example, has listar_decisoes and contar_decisoes instead):
.cpopg(): first-instance case lookup.cposg(): second-instance case lookup.cjsg(): second-instance case law search.cjpg(): first-instance decision search
.cpopg() and .cposg() take a case number in the CNJ format (NNNNNNN-DD.AAAA.J.TT.OOOO), with or without separators, and return a dict of tables with the case elements (basic data, parties, docket entries and other court-specific tables).
.cjsg() takes case law search parameters (which vary by court) and returns a table with the results. Many courts limit pagination on broad searches (searches that return many results). In those cases the method warns the user with the total number of results and asks for confirmation before downloading all of them.
Implementations
Available courts
| Court | Available methods |
|---|---|
| STF | contar_decisoes, listar_decisoes |
| TSE | baixar_inteiro_teor, baixar_inteiros_teores |
| STM | cjsg |
| TJAC | cjsg, baixar_acordao_por_processo, baixar_acordaos_por_processo |
| TJAL | cjsg |
| TJAM | cjsg |
| TJAP | cjsg ⚠️ |
| TJBA | cjsg |
| TJCE | cjsg, baixar_acordao, baixar_acordaos |
| TJDFT | cjsg |
| TJES | cjsg, cjpg |
| TJGO | cjsg |
| TJMG | cposg, cjsg |
| TJMS | cjsg, cjpg, baixar_acordao, baixar_acordaos, baixar_sentenca, baixar_sentencas |
| TJMT | cjsg |
| TJPA | cjsg |
| TJPB | cjsg |
| TJPE | cpopg, cjsg |
| TJPI | cjsg |
| TJPR | cjsg |
| TJRJ | cjsg |
| TJRN | cjsg |
| TJRO | cjsg |
| TJRR | cjsg |
| TJRS | cjsg |
| TJSC | cjsg |
| TJSP | cpopg, cposg, cjsg, cjpg, baixar_acordao, baixar_acordao_por_processo, baixar_acordaos, baixar_acordaos_por_processo, baixar_sentenca, baixar_sentencas |
| TJTO | cjsg, cjpg, cjsg_ementa |
| TRF1 | cpopg |
| TRF3 | cpopg, cposg, cjsg |
| TRF5 | cpopg |
| TRF6 | cpopg |
Available aggregators
| Name | Available methods |
|---|---|
| ComunicaCNJ | listar_comunicacoes |
| Datajud | contar_processos, listar_processos |
| Falcao | listar_decisoes |
| JusBR | cpopg, download_documents |
| PDPJ | cpopg, contar, documentos, download_documents, existe, movimentos, partes, pesquisa |
⚠️ TJAP —
cjsgunavailable: since ~2026 the TJAP jurisprudence search (Tucujuris platform) requires a Cloudflare Turnstile CAPTCHA, validated server-side. Because the scraper issues plain HTTP requests (no browser), it cannot produce the token and the backend replies"A verificação de segurança falhou". In that casecjsgraisesTJAPSecurityCheckErrorwith an explanation instead of silently returning empty. There is no workaround through the public API. See issue #279.
⚠️ TJGO —
cjsgreturns no results: since 12 November 2026 (Projudi 3.194.1) the TJGO jurisprudence search validates a Cloudflare Turnstile token server-side, which the scraper does not send. Without it the portal returns an empty search, with no error message, andcjsg/cjsg_downloademit aUserWarningexplaining the block. The portal answers a search that genuinely has no results the same way, so the warning is emitted on every empty search.
⚠️ TSE — no jurisprudence search: the search of the TSE jurisprudence portal requires a CAPTCHA token validated server-side, which the scraper, issuing plain HTTP requests (no browser), cannot produce; without it the API replies
"Falha na verificação antirrobô."(probed on 16 November 2026). The scraper covers what the portal serves without a CAPTCHA:baixar_inteiro_teor(codigo_decisao), which downloads the PDF of a decision given its code,baixar_inteiros_teores(codigos_decisao), which does the same for several codes, and the catalogs of the search form (listar_classes,listar_relatores,listar_eleicoesandlistar_normas). The portal of the TREs runs on the same services, with the same CAPTCHA on the search: the full text of a TRE decision downloads by its code, and the catalogs taketribunal="tre-sp"(or"tres", the 27 together).cjsgraisesNotImplementedErrorwith this explanation. See issue #378.
⚠️ STM — IP-based blocking: the STM jurisprudence portal sits behind a WAF that rejected every request from a datacenter IP address outside Brazil, with a “Request Rejected” page served as HTTP 200 (probe on 2026-11-16). In that case
cjsgraisesBotChallengeBlockedError; try another connection, such as a residential one in Brazil.
Falcao covers national labor jurisprudence (TST and TRTs).
JusBR and PDPJ authentication
JusBR and PDPJ share the same JWT from the PJe SSO. With the govbr extra (pip install 'juscraper[govbr]'), auth_govbr() opens the locally installed Google Chrome, Chromium or Microsoft Edge, with a temporary profile, on the PDPJ services portal; the user logs in through gov.br, the token is captured and the window closes on its own. If no browser is found, pass its executable to auth_govbr(navegador=...). The token is cached in ~/.config/juscraper/pdpj_token.json (or under $XDG_CONFIG_HOME/juscraper/), readable only by its owner, and later JusBR and PDPJ instances load it without a new login. When the portal issues a refresh token, the access token is renewed automatically before it expires. The login needs a windowed browser, so it does not run on Google Colab or CI; there, pass the token to auth(token) or set the PDPJ_JWT environment variable (JusBR also accepts JUSBR_JWT).
On JusBR, auth_firefox() reuses the SSO session already open in Firefox and requires the firefox extra (pip install 'juscraper[firefox]').
Example notebooks
These notebooks send live requests to external services and are not guaranteed to work on Google Colab. Courts may block or throttle shared cloud and datacenter IP addresses even when the same request works from a local connection. Some examples also require CAPTCHA handling, access tokens, or optional dependencies. Local Jupyter execution is the project’s reference environment; a connection failure on Colab does not, by itself, indicate a juscraper regression.
- TJAC example
- TJAL example
- TJAM example
- TJAP example
- TJBA example
- TJCE example
- TJDFT example
- TJES example
- TJGO example
- TJMG example
- TJMS example
- TJMT example
- TJPA example
- TJPB example
- TJPE example
- TJPI example
- TJPR example
- TJRJ example
- TJRN example
- TJRO example
- TJRR example
- TJRS example
- TJSC example
- TJSP example
- TJTO example
- TRF3 example
- TRF5 example
- TRF6 example
- TSE example
- STM example
- Datajud example
- Falcao example
- JusBR example
- PDPJ example
Additional information
What sets juscraper apart
- Control over raw files: the package provides an interface to download and store the raw files (HTML and JSON, for example) of each case. By default, raw files are discarded once the data is parsed, except for files that failed to parse.
Limitations
Because the package is complex and niche, its scope is restricted to keep it simple to use.
- The package does not parallelize requests; users who want parallel requests must build that themselves.
- The package does not cover every feature the courts offer. Users who need other courts must write the scrapers.
Contributing
Interested in contributing? See the guidelines in CONTRIBUTING.md. This project is released with a Code of Conduct; by contributing, you agree to abide by its terms.
License
juscraper was created by Julio Trecenti. It is licensed under the terms of the MIT license.