RobertMyles / cepR

Um pacote R para buscar informações sobre CEPs, endereços, bairros e cidades. (An R package for accessing Brazilian postal code data) :email:
https://robertmyles.github.io/cepR/.
Other
28 stars 9 forks source link

Update to v3 #6

Closed RobertMyles closed 4 years ago

RobertMyles commented 4 years ago

Seems there is an API issue. Running the code from the site examples gives me:

GET("http://www.cepaberto.com/api/v3/address?estado=SP&cidade=Ubatuba",
  add_headers(Authorization = auth)) %>% 
  content("parsed")

Result:

named list()

This is not an R issue. Copying directly from the site:

import requests

url = "http://www.cepaberto.com/api/v3/address"
headers = {'Authorization': 'Token token=XXXXXXXXXX'}
params = {'estado': 'SP', 'cidade': 'Ubatuba'}
response = requests.get(url, headers=headers, params=params)
print(response.json())

Result:

{}
RobertMyles commented 4 years ago

@edumucelli do we need lat & lng for estado/cidade requests, Eduardo?

GET("http://www.cepaberto.com/api/v3/nearest?cidade=Ubatuba&estado=SP", add_headers(Authorization = auth)) %>% content("parsed")
$message
[1] "Atributos \"lat\" e \"lng\" necessários"
edumucelli commented 4 years ago

nearest only takes lat and lng. The semantic behind it is that it will find the nearby CEPs from a point centered on this very coordinate formed by the lat and lng.

I could indeed make it accept a cidade and estado but I have not thought about it beforehand.

RobertMyles commented 4 years ago

Ah, understood, my mistake, I was confusing it with the cidade/estado request.

RobertMyles commented 4 years ago

Closing, CRAN submission underway.