Dependency-less Brasil API lookup gem for brazilian data with an easy-to-use API.
Features
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add brasilapi
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install brasilapi
Usage
require 'brasilapi'
BrasilAPI::Bank.all
=>
[{"ispb"=>"00000000", "name"=>"BCO DO BRASIL S.A.", "code"=>1, "fullName"=>"Banco do Brasil S.A."},
{"ispb"=>"00000208", "name"=>"BRB - BCO DE BRASILIA S.A.", "code"=>70, "fullName"=>"BRB - BANCO DE BRASILIA S.A."},
...]
BrasilAPI::Bank.find_by_code(77)
=> {"ispb"=>"00416968", "name"=>"BANCO INTER", "code"=>77, "fullName"=>"Banco Inter S.A."}
BrasilAPI::Company.find_by_cnpj("60316817000103")
=>
{"uf"=>"SP",
"cep"=>"04543907",
"qsa"=>
[{"pais"=>"ESTADOS UNIDOS",
...}
BrasilAPI::Address.find_by_zip_code('64001100')
=> {"cep"=>"64001100", "state"=>"PI", "city"=>"Teresina", "neighborhood"=>"Centro", "street"=>"Praça Pedro II", "service"=>"correios"}
BrasilAPI::Address.find_by_zip_code('80060000', location: true)
=>
{"cep"=>"80060000",
"state"=>"PR",
...
"location"=>{"type"=>"Point", "coordinates"=>{"longitude"=>"-49.2614791", "latitude"=>"-25.427253"}}}
BrasilAPI::Address.state_and_cities_by_area_code('89')
=>
{"state"=>"PI",
"cities"=>
["MASSÂPE DO PIAUÍ",
...,
"ACAUÃ"
]}
BrasilAPI::CVM.all
=>
[{"cnpj"=>"76621457000185",
"type"=>"CORRETORAS",
...]
BrasilAPI::CVM.find_by_cnpj('74014747000135')
=>
{"cnpj"=>"74014747000135",
"type"=>"CORRETORAS",
...}
BrasilAPI::Holiday.by_year(2024)
=>
[{"date"=>"2024-01-01", "name"=>"Confraternização mundial", "type"=>"national"},
...
{"date"=>"2024-12-25", "name"=>"Natal", "type"=>"national"}]
BrasilAPI::IBGE.states
=>
[{"id"=>11,
"sigla"=>"RO"
"nome"=>"Rondônia",
"regiao"=>{"id"=>1, "sigla"=>"N", "nome"=>"Norte"}},
...
{"id"=>53,
"sigla"=>"DF",
"nome"=>"Distrito Federal",
"regiao"=>{"id"=>5, "sigla"=>"CO", "nome"=>"Centro-Oeste"}}]
BrasilAPI::IBGE.find_state_by_code('PI')
=>
{"id"=>22,
"sigla"=>"PI",
"nome"=>"Piauí",
"regiao"=>{"id"=>2, "sigla"=>"NE", "nome"=>"Nordeste"}}
BrasilAPI::IBGE.find_state_by_code(53)
=>
{"id"=>53,
"sigla"=>"DF",
"nome"=>"Distrito Federal",
"regiao"=>{"id"=>5, "sigla"=>"CO", "nome"=>"Centro-Oeste"}}
BrasilAPI::IBGE.cities_by_state('CE')
=>
[{"nome"=>"ABAIARA", "codigo_ibge"=>"2300101"},
...
{"nome"=>"VÁRZEA ALEGRE", "codigo_ibge"=>"2314003"},
{"nome"=>"VIÇOSA DO CEARÁ", "codigo_ibge"=>"2314102"}]
License
MIT
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/dayvidemerson/brasilapi-rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Brasilapi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
Autor