Provider racing
ViaCEP, BrasilAPI, APICep and OpenCEP fire in parallel with a staggered start. The first valid response wins, the rest are discarded.
See providers
Provider racing, circuit breaker, persistent cache and offline fallback - without changing a line of your application code.
npm install @eusilvio/cep-lookupimport { 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.
| Feature | cep-promise | viacep wrappers | cep-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 | ❌ | ❌ | ✅ |
Products that resolve CEPs with the library every day.