Skip to content

cep-lookupFault-tolerant CEP resolution

Provider racing, circuit breaker, persistent cache and offline fallback - without changing a line of your application code.

Install and resolve in 30 seconds ​

bash
npm install @eusilvio/cep-lookup
ts
import { CepLookup } from "@eusilvio/cep-lookup";
import { viaCepProvider, brasilApiProvider, apicepProvider } from "@eusilvio/cep-lookup/providers";

const cep = new CepLookup({
  providers: [viaCepProvider, brasilApiProvider, apicepProvider],
  circuitBreaker: { enabled: true, failureThreshold: 3, cooldownMs: 30_000 },
  retries: 1,
});

const address = await cep.lookup("01001-000");
// {
//   cep: '01001000',
//   street: 'Praça da Sé',
//   neighborhood: 'Sé',
//   city: 'São Paulo',
//   state: 'SP',
//   service: 'ViaCEP'
// }

If ViaCEP is unavailable, BrasilAPI takes over. If that trips too, APICep responds. Your application keeps working.

Comparison ​

Featurecep-promiseviacep wrapperscep-lookup
Multiple providers✅❌✅
Circuit breaker per provider❌❌✅
Provider health score❌❌✅
Runtime metrics❌❌✅
Event-based observability❌❌✅
Retry with exponential backoff❌❌✅
Rate limiting❌❌✅
Offline fallback (zero-network)❌❌✅
Address verification with CEP correction❌❌✅
Custom providers❌❌✅
React / Vue integration❌❌✅

Already in production

Products that resolve CEPs with the library every day.

Released under the MIT License.