Postal Codes¶
Look up, validate, and search postal codes across 124+ countries. Includes spatial queries for finding nearby codes by GPS coordinates.
apicrate-lookup-postal-code¶
Look up a single postal code in a given country, returning place name, administrative region, and coordinates.
Credit cost: 2 credits per call.
Parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
str |
Yes |
ISO 3166-1 alpha-2 country code (e.g. |
|
str |
Yes |
The postal code to look up (e.g. |
Example¶
Request:
{
"name": "apicrate-lookup-postal-code",
"arguments": {
"country_code": "DE",
"postal_code": "10115"
}
}
Response:
{
"country_code": "DE",
"postal_code": "10115",
"place_name": "Berlin Mitte",
"admin_name1": "Berlin",
"admin_code1": "BE",
"latitude": 52.532,
"longitude": 13.3886
}
Errors¶
Country not found – the
country_codedoes not match any supported country.Postal code not found – no entry exists for the given code in that country.
apicrate-validate-postal-code¶
Check whether a postal code is valid for a given country. Returns format validity (regex match) and whether the code exists in the database.
Credit cost: 1 credit per call.
Parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
str |
Yes |
ISO 3166-1 alpha-2 country code. |
|
str |
Yes |
The postal code to validate. |
Example¶
Valid code – request:
{
"name": "apicrate-validate-postal-code",
"arguments": {
"country_code": "US",
"postal_code": "10001"
}
}
Response:
{
"country_code": "US",
"postal_code": "10001",
"format_valid": true,
"exists": true
}
Invalid code – request:
{
"name": "apicrate-validate-postal-code",
"arguments": {
"country_code": "US",
"postal_code": "ABCDE"
}
}
Response:
{
"country_code": "US",
"postal_code": "ABCDE",
"format_valid": false,
"exists": false
}
Errors¶
Country not found – the
country_codedoes not match any supported country.
apicrate-search-postal-codes¶
Search postal codes within a country by place name or code prefix.
Credit cost: 3 credits per call. Returns up to 50 results.
Parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
str |
Yes |
ISO 3166-1 alpha-2 country code. |
|
str |
No |
Free-text search against place names (e.g. |
|
str |
No |
Postal code prefix to match (e.g. |
Example¶
Request:
{
"name": "apicrate-search-postal-codes",
"arguments": {
"country_code": "DE",
"query": "Berlin"
}
}
Response:
{
"country_code": "DE",
"count": 3,
"results": [
{
"postal_code": "10115",
"place_name": "Berlin Mitte",
"latitude": 52.532,
"longitude": 13.3886
},
{
"postal_code": "10117",
"place_name": "Berlin Mitte",
"latitude": 52.5225,
"longitude": 13.3881
},
{
"postal_code": "10119",
"place_name": "Berlin Prenzlauer Berg",
"latitude": 52.5327,
"longitude": 13.4108
}
]
}
Errors¶
Country not found – the
country_codedoes not match any supported country.
apicrate-list-postal-systems¶
List all supported postal systems (countries) with their code formats. Use the
optional query parameter to filter by country name.
Credit cost: 2 credits per call. Returns up to 250 results.
Parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
str |
No |
Filter countries by name (e.g. |
Example¶
Unfiltered request:
{
"name": "apicrate-list-postal-systems",
"arguments": {}
}
Filtered request:
{
"name": "apicrate-list-postal-systems",
"arguments": {
"query": "Germany"
}
}
Response (filtered):
{
"count": 1,
"results": [
{
"country_code": "DE",
"country_name": "Germany",
"format": "#####",
"regex": "^\\d{5}$"
}
]
}
Errors¶
No tool-specific errors. An empty results list is returned when the query
matches nothing.
apicrate-get-postal-system¶
Get detailed information about a single country’s postal system, including the code format, validation regex, and example codes.
Credit cost: 2 credits per call.
Parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
str |
Yes |
ISO 3166-1 alpha-2 country code. |
Example¶
Request:
{
"name": "apicrate-get-postal-system",
"arguments": {
"country_code": "DE"
}
}
Response:
{
"country_code": "DE",
"country_name": "Germany",
"format": "#####",
"regex": "^\\d{5}$",
"examples": ["10115", "20095", "80331"]
}
Errors¶
Country not found – the
country_codedoes not match any supported country.
apicrate-validate-postal-codes-bulk¶
Validate multiple postal codes in a single call. Each item specifies its own country code, so you can mix countries freely.
Credit cost: 2 credits per code. A request with 10 codes costs 20 credits. Maximum 50 codes per call.
Parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
list[dict] |
Yes |
List of objects, each with |
Example¶
Request:
{
"name": "apicrate-validate-postal-codes-bulk",
"arguments": {
"codes": [
{"country_code": "US", "postal_code": "10001"},
{"country_code": "DE", "postal_code": "10115"}
]
}
}
Response:
{
"count": 2,
"results": [
{
"country_code": "US",
"postal_code": "10001",
"format_valid": true,
"exists": true
},
{
"country_code": "DE",
"postal_code": "10115",
"format_valid": true,
"exists": true
}
]
}
Errors¶
Empty list –
codesmust contain at least one item.Over 50 limit – no more than 50 codes per request.
Missing keys – each item must include both
country_codeandpostal_code.
apicrate-find-nearby-postal-codes¶
Find postal codes near a GPS coordinate within a given radius. Results are sorted by distance (nearest first).
Credit cost: 5 credits per call. Returns up to 100 results.
Parameters¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
str |
Yes |
ISO 3166-1 alpha-2 country code. |
|
float |
Yes |
Latitude of the search center. Range: |
|
float |
Yes |
Longitude of the search center. Range: |
|
float |
Yes |
Search radius in kilometres. Must be greater than |
Example¶
Request:
{
"name": "apicrate-find-nearby-postal-codes",
"arguments": {
"country_code": "DE",
"lat": 52.52,
"lng": 13.405,
"radius_km": 5
}
}
Response:
{
"country_code": "DE",
"center": {"lat": 52.52, "lng": 13.405},
"radius_km": 5,
"count": 3,
"results": [
{
"postal_code": "10117",
"place_name": "Berlin Mitte",
"latitude": 52.5225,
"longitude": 13.3881,
"distance_km": 1.14
},
{
"postal_code": "10115",
"place_name": "Berlin Mitte",
"latitude": 52.532,
"longitude": 13.3886,
"distance_km": 1.52
},
{
"postal_code": "10119",
"place_name": "Berlin Prenzlauer Berg",
"latitude": 52.5327,
"longitude": 13.4108,
"distance_km": 1.47
}
]
}
Errors¶
Country not found – the
country_codedoes not match any supported country.Invalid latitude –
latmust be between-90and90.Invalid longitude –
lngmust be between-180and180.Invalid radius –
radius_kmmust be greater than0and at most500.