Skip to content
Scrapers for many e-SAJ systems
Branch: master
Clone or download
C. T. Lente
C. T. Lente User
Latest commit fdd12dd Mar 8, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
R download_cjsg() back to working Aug 2, 2018
docs User Mar 9, 2019
man Brought rm_accent() to esaj May 29, 2018
tests Added leading zeroes to page number in CJXG Apr 6, 2018
vignettes Updated README Sep 25, 2017
.Rbuildignore Updated README Sep 25, 2017
.gitignore Remoção temporária de vignettes, testes e exemplos para poder rodar c… Jul 25, 2017
LICENSE documentacao Feb 25, 2016
README.Rmd User Mar 9, 2019
_pkgdown.yml Added vignette to download_decision() Sep 25, 2017
appveyor.yml Added travis and appveyor Aug 8, 2017


Made In Brazil Travis-CI Build Status AppVeyor Build Status


The esaj R package is a simple interface that allows you to download multiple kinds of files from Brazil's e-SAJ (Electronic Justice Automation System) portals. With this package you can save and parse lawsuits, queries, and decisions with very simple, tidyverse compliant functions.

To install esaj, run the code below:

# install.packages("devtools")



Before esaj if you wanted to gather information about lawsuits being processed by Brazil's state-level Judiciary, you would have to go to each state's e-SAJ portal, manually input each lawsuit's ID, break a capthca, and only then download an HTML with the information you wanted; now you can simply run download_cpopg() or download_cposg(), and spend your valuable time analysing the data.

# Download first degree lawsuits from multiple states
ids <- c(
esaj::download_cpopg(ids, "~/Desktop/")
#> [1] "/Users/user/Desktop/01234790720128260100.html"
#> [2] "/Users/user/Desktop/05524866220158050001.html"
#> [3] "/Users/user/Desktop/03033494420148240020.html"

# Download second degree lawsuits from São Paulo
ids <- c(
esaj::download_cposg(ids, "~/Desktop/")
#> [1] "/Users/user/Desktop/10018695120178260562.html"
#> [2] "/Users/user/Desktop/10012140720168260565.html"

For more information on how to use these functions and which TJs are implemented, please see Downloading Lawsuits.


Besides downloading lawsuits (see the Downloading Lawsuits article), esaj also allows the user to download the results of a query on lawsuits. This kind of query is very useful for finding out what lawsuits contain certain words, were filed in a given period, were filed in a given court, etc.

# Download results of a simple first degree query
esaj::download_cjpg("recurso", "~/Desktop/")
#> [1] "/Users/user/Desktop/search.html"
#> [2] "/Users/user/Desktop/page1.html"

# Download results of a slightly more complex second degree query
esaj::download_cjsg("recurso", "~/Desktop/", classes = c("1231", "1232"))
#> [1] "/Users/user/Desktop/search.html"
#> [2] "/Users/user/Desktop/page1.html"

For more information on how to use these functions and all their auxiliary methods (like peek_cj*g() and cj*g_table()), please see Downloading Queries.


Of all functions in the esaj package, download_decision() is probably the simplest: it downloads the PDF belonging to a decision and that's it.

# Download one decision
esaj::download_decision("10000034", "~/Desktop/")
#> [1] "/Users/user/Desktop/10000034.pdf"

# Download more than one decision
esaj::download_decision(c("10800758", "10000034"), "~/Desktop/")
#> [1] "/Users/user/Desktop/10800758.pdf"
#> [2] "/Users/user/Desktop/10000034.pdf"

For more information on how to use this function, please see Downloading Decisions.

You can’t perform that action at this time.