- authentication
- Secret API key as a bearer token
- billing
- 2 credits per answered list, which is what the licensed partner charges through. A country with no partner configured answers 501 and costs nothing, and so does a partner that could not answer.
Answers the addresses at one postcode, in the partner's own order, for callers that want a "find my address" picker under a postcode field.
This is the one address answer no open dataset carries: every full address list is derived from a postal operator's own address file, and serving it needs a licence. Until a partner is configured for the country, the endpoint answers 501 ADDRESS_LIST_UNAVAILABLE and charges nothing, rather than returning an empty list that would read as "there are no addresses here". Nothing else in the address API depends on it.
country is an ISO 3166-1 alpha-2 code and defaults to GB. The postcode is passed in the path, with or without its space (NW1 6XE and NW16XE are the same postcode). At most 100 addresses are returned for one postcode; count is how many the answer carries.
Parameters
| name | in | type | description |
|---|---|---|---|
| postcoderequired | path | string | The postcode to list, in the country's own notation. |
| country | query | string | An ISO 3166-1 alpha-2 code the postal format table covers. Default: GB. |
Example request
curl https://spaw.co/api/v1/address/postcode/NW1 6XE \ -H "Authorization: Bearer sk_live_…"
Responses
200The addresses the partner lists at that postcode.
{
"success": true,
"data": {
"postcode": "NW1 6XE",
"country": "GB",
"available": true,
"addresses": [
{
"address_line1": "221B Baker Street",
"address_line2": null,
"organization": null,
"street": "Baker Street",
"house_number": "221B",
"unit": null,
"locality": "London",
"administrative_area": null,
"postal_code": "NW1 6XE",
"country": "GB",
"identifier": "10023456789"
}
],
"count": 1
},
"meta": {
"credits_used": 2,
"credits_remaining": 8,
"request_id": "req_01m1kgdm4xngzmbmff68g94w0c"
}
}401The key is missing, malformed, or revoked.
{
"success": false,
"error": {
"code": "UNAUTHENTICATED",
"message": "Provide a valid API key as a bearer token.",
"request_id": "req_01m1kgdm4xngzmbmff68g94w0c"
}
}402The balance is empty. The lookup did not run.
{
"success": false,
"error": {
"code": "INSUFFICIENT_CREDITS",
"message": "Your credit balance is empty.",
"request_id": "req_01m1kgdm4xngzmbmff68g94w0c"
}
}422The request body could not be validated; `error.errors` lists the fields.
{
"success": false,
"error": {
"code": "VALIDATION_FAILED",
"message": "The email field is required.",
"errors": {
"email": [
"The email field is required."
]
},
"request_id": "req_01m1kgdm4xngzmbmff68g94w0c"
}
}429Over 5 requests per second for the key. Retry after the limit resets.
{
"success": false,
"error": {
"code": "RATE_LIMITED",
"message": "Too many requests. Retry after the limit resets.",
"request_id": "req_01m1kgdm4xngzmbmff68g94w0c"
}
}501No licensed address-list partner is configured for the country. Nothing was charged.
{
"success": false,
"error": {
"code": "ADDRESS_LIST_UNAVAILABLE",
"message": "Listing the addresses at a postcode needs a licensed address-list partner, and none is configured for GB.",
"request_id": "req_01m1kgdm4xngzmbmff68g94w0c"
}
}Error codes
Failures answer { success: false, error: { code, message, request_id } }. Each code has its own page.