Skip to content
Switch branches/tags
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Travis CI Codecov Code Climate

Perfil Político

A platform for profiling candidates in Brazilian 2018 General Election, based entirely on open data.


This project requires Docker and Docker Compose.


To run the API, you must copy the .env.sample to a .env file. You can edit it accordingly if you want run in a production env.

Creating the container

You need to create the docker container:

$ docker-compose up -d

Database initial setup

You should create your database by applying migrations:

$ docker-compose run django ./ migrate


To run the project locally, you can simply use this command:

$ docker-compose up

The website and API will be available at localhost:8000 and the Jupyter at localhost:8888.

Bringing data in your database

Your local data/ directory is mapped, inside the container, to /mnt/data. Each command uses a CSV (compressed as .xz or not) from a public and available source. Use --help for more info. Yet some extra data can be generated with some Django custom commands.

Once you have download the datasets to data/, the roadmap is:

$ docker-compose run django python load_affiliations /mnt/data/filiacao.csv
$ docker-compose run django python load_candidates /mnt/data/candidatura.csv
$ docker-compose run django python link_affiliations_and_candidates
$ docker-compose run django python link_politicians_and_election_results
$ docker-compose run django python load_assets /mnt/data/bemdeclarado.csv
$ docker-compose run django python load_bills /mnt/data/senado.csv
$ docker-compose run django python load_bills /mnt/data/camara.csv


GET /api/candidate/<year>/<state>/<post>/

List all candidates from a certain state to a given post. For example:


Post options for 2018 are:

  • 1o-suplente
  • 2o-suplente
  • deputado-distrital
  • deputado-estadual
  • deputado-federal
  • governador
  • presidente
  • senador
  • vice-governador
  • vice-presidente

State options are the abbreviation of the 27 Brazilian states, plus br for national election posts.

GET /api/candidate/<pk>/

Returns the details of a given candidate.

GET /api/stats/<year>/<post>/<characteristic>/

Get national statistics for a given characteristic in a elected post.

Post options are:

  • deputado-distrital
  • deputado-estadual
  • deputado-federal
  • governador
  • prefeito
  • senador
  • vereador

Characteristic options are:

  • age
  • education
  • ethnicity
  • gender
  • marital_status
  • occupation
  • party

GET /api/stats/<state>/<year>/<post>/<characteristic>/

Same as above but aggregated by state.


$ docker-compose run django py.test
$ docker-compose run django black . --check


A platform for profiling public figures in Brazilian politics





No releases published


No packages published