Git Product home page Git Product logo

address-js's Introduction

address-js

EN - Javascript library to search for Brazilian Addresses, Cities and States. PT - Biblioteca javascript para consulta de Endereços, Cidades e Estados

Build Status

Library

This library is a wrapper for the nfe.io API to allow easy access to use it.

Usage

TODO (for now, check the code)

API

The nfe.io API allows to find information about Brazilian addresses.

Authentication

To use the API, your have to create an account in NFe.io and use your API key.

It is a Base64 encoded key that should be passed in the Authorization header as below: Authorization: Basic your_api_key

For testing purposes, you can use the following key: b58801a82418463f961cff952b27baaa

Endpoints

GET /states/

Return all Brazilian states with code, name and abbreviation.

Example

curl http://open.nfe.io/v1/states -H "Authorization: Basic b58801a82418463f961cff952b27baaa"

The response will be like:

[
   {
      "code": "12",
      "abbreviation": "AC",
      "name": "Acre"
   },
   {
      "code": "27",
      "abbreviation": "AL",
      "name": "Alagoas"
   },
   ...
   {
      "code": "33",
      "abbreviation": "RJ",
      "name": "Rio de Janeiro"
   },
   ...
   {
      "code": "35",
      "abbreviation": "SP",
      "name": "São Paulo"
   },
   {
      "code": "17",
      "abbreviation": "TO",
      "name": "Tocantins"
   }
]

GET /states/:state_abbreviation/cities

Return all cities that belong to a state.

Example

Let's say we want to list all cities in the state of São Paulo (abbreviation SP)

curl http://open.nfe.io/v1/states/SP/cities -H "Authorization: Basic b58801a82418463f961cff952b27baaa"

The response will be like:

[
   {
      "code": "3500105",
      "name": "Adamantina"
   },
   ...
   {
      "code": "3550308",
      "name": "São Paulo"
   },
   ...
   {
      "code": "3556701",
      "name": "Vinhedo"
   },
   ...
]

GET /addresses/:postal_code

Example

Let's say that we have a brazilian postal code (01310-200) and we need to find which city, state and street it represents.

curl http://open.nfe.io/v1/addresses/01310200 -H "Authorization: Basic b58801a82418463f961cff952b27baaa"

The response will be:

{
   "postalCode": "01310-200",
   "streetSuffix": "Avenida",
   "street": "Paulista",
   "district": "Bela Vista",
   "city": {
      "code": "3550308",
      "name": "São Paulo"
   },
   "state": {
      "code": "35",
      "abbreviation": "SP",
      "name": "São Paulo"
   }
}

address-js's People

Contributors

gblmarquez avatar tuliomonteazul avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.