Skip to main content

POST /api/lookup

Look up city and state/region for a postal code.

Request

POST https://postaldatapi.com/api/lookup
Content-Type: application/json

Body Parameters

ParameterTypeRequiredDescription
zipcodestring or numberYesThe postal code to look up
apiKeystringYesYour API key
countrystringNoISO 3166-1 alpha-2 country code (default: "US")

Response

Success (200)

{
"city": "Beverly Hills",
"state": "California",
"ST": "CA",
"performance": {
"authTime": "0ms",
"rateLimitCheckTime": "0ms",
"balanceTime": "0ms",
"processingTime": "0ms",
"totalTime": "2ms"
},
"rateLimit": {
"enabled": false,
"perMinute": { "limit": null, "current": null, "approachingLimit": false },
"perHour": { "limit": null, "current": null, "approachingLimit": false },
"perDay": { "limit": null, "current": null, "approachingLimit": false }
},
"balance": 4.99
}

Response Fields

FieldTypeDescription
citystringCity or place name
statestringFull state/region name
STstringState/region abbreviation
performanceobjectTiming breakdown for the request
rateLimitobjectCurrent rate limit status
balancenumberAccount balance after this query (USD)

Non-US Example

curl -X POST https://postaldatapi.com/api/lookup \
-H "Content-Type: application/json" \
-d '{"zipcode": "10115", "country": "DE", "apiKey": "YOUR_API_KEY"}'
{
"city": "Berlin",
"state": "Berlin",
"ST": "BE",
"performance": { "totalTime": "1ms" },
"balance": 4.99
}

Errors

StatusErrorCause
400Missing required field: zipcodeNo zipcode in request body
400Missing required field: apiKeyNo apiKey in request body
400Invalid 'country'Country code is not a valid 2-letter ISO code
401Invalid API keyAPI key does not exist or was revoked
402Insufficient balanceAccount balance is zero
404ZIP code not foundPostal code does not exist in the specified country
429Rate limit exceededToo many requests (if rate limits are enabled)

SDK Examples

from postaldatapi import PostalDataPI, NotFoundError

client = PostalDataPI(api_key="YOUR_API_KEY")

# US lookup
result = client.lookup("90210")
print(f"{result.city}, {result.state_abbreviation}") # Beverly Hills, CA

# German lookup
de = client.lookup("10115", country="DE")
print(de.city) # Berlin

# Handle not found
try:
client.lookup("00000")
except NotFoundError:
print("Postal code not found")