Overview
ViaCep is a free Brazilian zip code (CEP) API that returns address data including street, neighborhood, city, and state for any valid Brazilian postal code. No authentication is required, making it ideal for beginners building forms or address validation for Brazil. Responses are available in JSON or XML format.
Beginner Tip
Just replace the CEP in the URL with any valid 8-digit Brazilian zip code. Use the JSON format endpoint (/json/) for easiest parsing in modern apps.
Measurement Record
What actually happened when we called this API from our own infrastructure. Every value below was recorded by the request, not copied from the provider's documentation.
- Request
- GET https://viacep.com.br/ws/01310-100/json/
- Result
- HTTP 200 · application/json · 313 bytes
- Response time
- 410 ms (median of 3) · fastest 398 ms
- Transport
- TLSv1.3 · TLS_AES_256_GCM_SHA384 · certificate issued by Sectigo Limited
- Browser CORS
- Allowed — Access-Control-Allow-Origin: *
- Served by
- nginx/1.22.0
- Answered
- 6 of 8 weekly checks (75%, since 2026-07-31)
- Recorded
- 2026-09-21
Fields Returned
Top-level fields present in the response we captured, with the type and value we actually received.
| Field | Type | Value received |
|---|---|---|
| cep | string | 01310-100 |
| logradouro | string | Avenida Paulista |
| complemento | string | de 612 a 1510 - lado par |
| unidade | string | |
| bairro | string | Bela Vista |
| localidade | string | São Paulo |
| uf | string | SP |
| estado | string | São Paulo |
| regiao | string | Sudeste |
| ibge | string | 3550308 |
| gia | string | 1004 |
| ddd | string | 11 |
| siafi | string | 7107 |
Captured Response
Captured from a real request to https://viacep.com.br/ws/01310-100/json/ on 2026-09-21. Long arrays and nested objects are truncated to keep the shape readable.
{
"cep": "01310-100",
"logradouro": "Avenida Paulista",
"complemento": "de 612 a 1510 - lado par",
"unidade": "",
"bairro": "Bela Vista",
"localidade": "São Paulo",
"uf": "SP",
"estado": "São Paulo",
"regiao": "Sudeste",
"ibge": "3550308",
"gia": "1004",
"ddd": "11",
"siafi": "7107"
} Field Reference
cep The Brazilian postal code in XXXXX-XXX format. logradouro Street name associated with the postal code. bairro Neighborhood or district name. localidade City name for the postal code. uf Two-letter Brazilian state abbreviation, e.g. SP for São Paulo. ibge IBGE code, a numeric identifier for the municipality. Implementation Example
Calls a real endpoint of this API. Replace any placeholder credentials with your own key.
const url = "https://viacep.com.br/ws/01310-100/json/";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data); What Can You Build?
Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.
How This API Fails
We deliberately sent this API a broken request and recorded exactly what came back on 2026-09-21. Knowing the shape of an error before you hit it makes error handling much easier to write.
Returned an HTML error page rather than JSON — worth knowing if your client assumes every response can be parsed as JSON.
Common Errors & Troubleshooting
Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.
Measured Score Breakdown
Live HTTP request to the API endpoint
Fully tested on Sep 21, 2026
Technical Specifications
Related Tags
Similar APIs
View All →administrative-divisons-db
⭐ Beginner's PickThe Administrative Divisions DB API provides a structured list of all administrative divisions (states, provinces, regions, cities) for countries around the world.
adresse.data.gouv.fr
adresse.data.gouv.fr provides programmatic access to address database of france, geocoding and reverse via REST API.
Airtel IP
⭐ Beginner's PickAirtel IP is a free, no-auth IP geolocation API that aggregates data from multiple sources to return the country associated with any given IP address.
bng2latlong
⭐ Beginner's Pickbng2latlong is a simple, free API that converts British National Grid (OSGB36) easting and northing coordinates into standard WGS84 latitude and longitude.
Cartes.io
⭐ Beginner's PickCartes.io is a free API that lets you create maps and add custom markers without signing up.