Prompt
address validation and normalization API
Latest observation
Oct 15, 2026
OpenAI APIWeb search: off
Here’s a practical design for an Address Validation and Normalization API.
What it does
The API should accept a raw address and return:
- Validated address: whether it is likely deliverable / structurally valid
- Normalized address: standardized formatting and components
- Confidence / match score
- Parsed components: street, city, state, postal code, country, etc.
- Suggestions: if the address is ambiguous or partially incorrect
Core endpoints
1) Validate and normalize address
POST /v1/addresses/validate
Request
{
"address_line1": "1600 pennsylvania ave nw",
"address_line2": "",
"city": "washington",
"state": "dc",
"postal_code": "20500",
"country": "US"
}
Response
{
"valid": true,
"deliverable": true,
"confidence": 0.98,
"normalized": {
"address_line1": "1600 Pennsylvania Ave NW",
"address_line2": "",
"city": "Washington",
"state": "DC",
"postal_code": "20500-0003",
"country": "US"
},
"components": {
"house_number": "1600",
"street_name": "Pennsylvania",
"street_suffix": "Ave",
"street_directional": "NW",
"city": "Washington",
"state": "DC",
"postal_code": "20500-0003",
"country": "US"
},
"warnings": [],
"suggestions": []
}
2) Batch validate addresses
POST /v1/addresses/batch-validate
Request
{
"addresses": [
{
"id": "1",
"address_line1": "10 downing st",
"city": "london",
"postal_code": "SW1A 2AA",
"country": "GB"
},
{
"id": "2",
"address_line1": "123 fake street",
"city": "new york",
"state": "ny",
"postal_code": "10001",
"country": "US"
}
]
}
Response
{
"results": [
{
"id": "1",
"valid": true,
"deliverable": true,
"normalized": {
"address_line1": "10 Downing St",
"city": "London",
"postal_code": "SW1A 2AA",
"country": "GB"
}
},
{
"id": "2",
"valid": false,
"deliverable": false,
"confidence": 0.12,
"warnings": ["Street not found"]
}
]
}
3) Parse only
POST /v1/addresses/parse
Useful when you want component extraction without external validation.
4) Lookup suggestions / autocomplete
GET /v1/addresses/suggest?q=1600+pen
Returns likely completions and standardized results.
Validation rules
A good API typically checks:
- Required fields based on country
- Postal code format and existence
- City/state consistency
- Street existence and house number plausibility
- Country-specific formatting and abbreviations
- Deliverability against address reference data
- Duplicate or ambiguous addresses
Normalization rules
Normalization often includes:
- Title casing names
- Expanding / standardizing street abbreviations
- Standardizing state/province codes
- Formatting postal codes
- Removing extra punctuation/spaces
- Country-specific address ordering
Examples:
street→Stavenue→Avenew york→New Yorkus→US
Suggested response fields
Return these fields consistently:
valid: structural correctnessdeliverable: known deliverable addressconfidence: 0 to 1 scorenormalized: canonical formcomponents: parsed fieldswarnings: minor issueserrors: blocking issuessuggestions: alternate matches
Error model
Example:
{
"error": {
"code": "INVALID_POSTAL_CODE",
"message": "Postal code does not match country format",
"field": "postal_code"
}
}
Common codes:
MISSING_REQUIRED_FIELDINVALID_COUNTRYINVALID_POSTAL_CODEADDRESS_NOT_FOUNDAMBIGUOUS_ADDRESSRATE_LIMITED
Authentication
Use:
- API key
- OAuth2 client credentials
- JWT for internal services
Example header:
Authorization: Bearer <token>
Best practices
- Support country-specific schemas
- Return confidence score and candidate matches
- Keep raw input and normalized output separate
- Provide batch validation
- Add idempotency keys for retries
- Log validation outcomes for monitoring and improvement
If you want to build it
I can also provide any of these:
- OpenAPI/Swagger spec
- Database schema
- FastAPI/Node.js implementation
- Address normalization rules by country
- Architecture for using Google Maps/Loqate/Melissa/Smarty APIs
If you want, I can generate a full OpenAPI 3.0 spec for this API next.