All Projects → BrasilAPI → Cep Promise

BrasilAPI / Cep Promise

Licence: mit
Busca por CEP integrado diretamente aos serviços dos Correios, ViaCEP e outros (Node.js e Browser)

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Cep Promise

ViaCEP
The ViaCEP API/webservice .NET client
Stars: ✭ 21 (-99.15%)
Mutual labels:  cep, correios, zipcode, viacep
correios-cep-elixir
Find Brazilian addresses by postal code, directly from Correios API. No HTML parsers.
Stars: ✭ 38 (-98.47%)
Mutual labels:  cep, correios, zipcode
Modfy.video
A video transcoder and converter built using Web Assembly and FFMPEG to transcode and convert videos right in your browser while protecting your privacy
Stars: ✭ 283 (-88.6%)
Mutual labels:  hacktoberfest, browser
Brazilian Values
🇧🇷 Funções de formatação, conversão e validação para valores, documentos e outras unidades usadas no Brasil. Como CEP, CNPJ, CPF, BRL (R$), datas, números etc.
Stars: ✭ 366 (-85.26%)
Mutual labels:  hacktoberfest, cep
Azure Sdk For Js
This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/en-us/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
Stars: ✭ 872 (-64.88%)
Mutual labels:  hacktoberfest, browser
consultacep
🇧🇷 Consulta CEP é uma aplicação básica para consulta de CEP
Stars: ✭ 21 (-99.15%)
Mutual labels:  cep, zipcode
viacep
ViaCEP - Consulte CEPs de todo o Brasil
Stars: ✭ 44 (-98.23%)
Mutual labels:  cep, viacep
Webtorrent
⚡️ Streaming torrent client for the web
Stars: ✭ 25,554 (+929.16%)
Mutual labels:  hacktoberfest, browser
Web Worker Proxy
A better way of working with web workers
Stars: ✭ 218 (-91.22%)
Mutual labels:  hacktoberfest, browser
Cast Sh
📟 An instance of your terminal in your browser
Stars: ✭ 151 (-93.92%)
Mutual labels:  hacktoberfest, browser
Pokeapi Js Wrapper
PokeAPI browser wrapper, fully async with built-in cache
Stars: ✭ 129 (-94.8%)
Mutual labels:  hacktoberfest, browser
Openlinkwith
Open the current webpage you have in another app. Magic! 🔮
Stars: ✭ 158 (-93.64%)
Mutual labels:  hacktoberfest, browser
Offline Qr Code
📱 Browser add-on allowing you to quickly generate a QR code offline with the URL of the open tab or other text!
Stars: ✭ 193 (-92.23%)
Mutual labels:  hacktoberfest, browser
Ac Music Extension
Google Chrome extension that plays hourly Animal Crossing music and more while browsing!
Stars: ✭ 262 (-89.45%)
Mutual labels:  hacktoberfest, browser
Svg2pdf.js
A javascript-only SVG to PDF conversion utility that runs in the browser. Brought to you by yWorks - the diagramming experts
Stars: ✭ 231 (-90.7%)
Mutual labels:  hacktoberfest, browser
Bpmn Js
A BPMN 2.0 rendering toolkit and web modeler.
Stars: ✭ 5,592 (+125.21%)
Mutual labels:  hacktoberfest, browser
Qrcode Renderer
QR Code renderer is a dependency-free library to render QR Codes. The library makes it simple to integrate with any UI framework and comes with a prebuilt SVG renderer for the web.
Stars: ✭ 56 (-97.74%)
Mutual labels:  hacktoberfest, browser
Brain.js
brain.js is a GPU accelerated library for Neural Networks written in JavaScript.
Stars: ✭ 12,358 (+397.7%)
Mutual labels:  hacktoberfest, browser
Python Scripts
Collection of Various Python Script's.💻
Stars: ✭ 195 (-92.15%)
Mutual labels:  hacktoberfest, browser
Cypress Terminal Report
Better terminal and file output for cypress test logs.
Stars: ✭ 200 (-91.95%)
Mutual labels:  hacktoberfest

CEP Promise

Known Vulnerabilities

Busca por CEP integrado diretamente aos serviços dos Correios, ViaCEP e WideNet (Node.js e Browser)

Features

  • Sempre atualizado em tempo-real por se conectar diretamente aos serviços dos Correios, ViaCEP e WideNet.
  • Possui alta disponibilidade por usar vários serviços como fallback.
  • Sempre retorna a resposta mais rápida por fazer as consultas de forma concorrente.
  • Sem limites de uso (rate limits) conhecidos.
  • Interface de Promise extremamente simples.
  • Suporte ao Node.js 10.x, 11.x, 12.x, 13.x, 14.x e @stable.
  • Suporte ao Node.js 4.x, 5.x, 6.x, 7.x, 8.x, 9.x, até cep-promise versão 3.0.9.
  • Suporte ao Node.js 0.10.x e 0.12.x até cep-promise versão 2.0.8.
  • 100% de code coverage com testes unitários e E2E.
  • Desenvolvido utilizando ES6.

Como utilizar

Teste e aprenda aqui.

Realizando uma consulta

Por ser multifornecedor, a biblioteca irá resolver a Promise com o fornecedor que mais rápido lhe responder.

import cep from 'cep-promise'

cep('05010000')
  .then(console.log)

  // {
  //   "cep":  "05010000",
  //   "state":  "SP",
  //   "city":  "São Paulo",
  //   "street":  "Rua Caiubí",
  //   "neighborhood":  "Perdizes",
  // }

Você também poderá passar o CEP como Inteiro

Em muitos sistemas o CEP é utilizado erroneamente como um Inteiro (e com isto cortando todos os zeros à esquerda). Caso este seja o seu caso, não há problema, pois a biblioteca irá preencher os caracteres faltantes na String, por exemplo:

import cep from 'cep-promise'

// enviando sem ter um zero à esquerda do CEP "05010000"
cep(5010000)
  .then(console.log)

  // {
  //   "cep":  "05010000",
  //   "state":  "SP",
  //   "city":  "São Paulo",
  //   "street":  "Rua Caiubí",
  //   "neighborhood":  "Perdizes",
  // }

Quando o CEP não é encontrado

Neste caso será retornado um "service_error" e por ser multifornecedor, a biblioteca irá rejeitar a Promise apenas quando tiver a resposta negativa de todos os fornecedores.

import cep from 'cep-promise'

cep('99999999')
  .catch(console.log)

  // {
  //     name: 'CepPromiseError',
  //     message: 'Todos os serviços de CEP retornaram erro.',
  //     type: 'service_error',
  //     errors: [{
  //       message: 'CEP NAO ENCONTRADO',
  //       service: 'correios'
  //     }, {
  //       message: 'CEP não encontrado na base do ViaCEP.',
  //       service: 'viacep'
  //     }]
  // }

Quando o CEP possui um formato inválido

Neste caso será retornado um "validation_error" e a biblioteca irá rejeitar imediatamente a Promise, sem chegar a consultar nenhum fornecedor.

import cep from 'cep-promise'

cep('123456789123456789')
  .catch(console.log)

  // {
  //     name: 'CepPromiseError',
  //     message: 'CEP deve conter exatamente 8 caracteres.',
  //     type: 'validation_error',
  //     errors: [{
  //       message: 'CEP informado possui mais do que 8 caracteres.',
  //       service: 'cep_validation'
  //     }]
  // }

Options

  • timeout: Timeout em milisegundos das consultas em cada serviço. O tempo total poderá ser maior devido a limites no paralelismo.
  • providers: Lista de providers a serem usados na consulta. Default é usar todos os providers disponíveis.
import cep from 'cep-promise'
cep('5010000', { timeout: 5000, providers: ['brasilapi'] })
  .then(console.log)

Instalação

Browser usando CDN

<script src="https://cdn.jsdelivr.net/npm/cep-promise/dist/cep-promise.min.js"></script>

npm

$ npm install --save cep-promise

Bower

$ bower install --save cep-promise

yarn

$ yarn add cep-promise

Angular 2

import * as cep from 'cep-promise'

cep('05010000')
  .then(console.log)

Como contribuir

Leia nosso guia de contribuição aqui

Contribuidores


@lucianopf

@MarcoWorms

@caio-ribeiro-pereira

@chrisbenseler

@luanmuniz

@AlbertoTrindade

@pedrro

@petronetto

@olegon

@jhonnymoreira

@claytonsilva

@thiamsantos

@flyingluscas

@otaviopace

@vagnercardosoweb

@murilohns

@dominguetigs

@fontebasso

Autor


@filipedeschamps
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].