CEP library

CEP lookup with automatic fallback.

One API for ViaCEP, BrasilAPI, OpenCEP and AwesomeAPI. When a service goes down, unicep switches to the next one on its own and always returns the same object.

Install

npm install @unicep/core

Example

import { Unicep, defaultProviders } from '@unicep/core';

const unicep = new Unicep({ providers: defaultProviders() });

const address = await unicep.lookup('01310-100');
// { cep: '01310100', street: 'Avenida Paulista', city: 'São Paulo',
//   state: 'SP', provider: 'viacep', ... }

Automatic fallback

Tries the providers in order and always returns the same Address object.

Circuit breaker

Detects unstable services and skips the provider until it recovers.

Ready for your framework

Plain TypeScript core with bindings for React, Vue and Angular.

Built for agents

llms.txt, Markdown pages and ready-made prompts to implement with AI.