address
This endpoint returns one or more full addresses with optional coordinates for a given postcode or part of an address. It supports 249 countries and can be used for UK postcode lookup, Irish Eircode lookup, global address lookup and geocoding.
Request URL
https://ws.postcoder.com/pcw/{apikey}/address/{countrycode}/{searchterm}
Path parameters
Parameter | Description | Example |
---|---|---|
apikey | Your API key | PCW45-12345-12345-1234X |
countrycode | The 2-character country code, see supported countries below; if your address form has a country selector, use the ipaddress endpoint to preset the country based on the user's IP address | uk |
searchterm | The URL-encoded postcode or part of an address that you wish to look up | nr1%201ne |
Querystring parameters
Parameter | Description | Example |
---|---|---|
format | Sets the format of the response, xml or json (default unless "application/xml" header is detected) | format=json |
identifier | Specifies your own meaningful identifier for the request such as "websiteA" or "client123"; you can view usage for each identifier on the Identifier Usage page, which may be helpful when using your API key across multiple websites, apps or clients | identifier=websiteA |
lines | Sets the number of address lines (1-9) to include in the response so you can mirror the layout of your existing address form, see address lines below | lines=3 |
include | Specifies the extra address fields to include within the address lines using a comma-delimited list, supported values: county, posttown, postcode | include=county,posttown,postcode |
exclude | Specifies the address fields to exclude within the address lines using a comma-delimited list, supported values: pobox, organisation, departmentname, buildingname, subbuildingname, number, premise, dependentstreet, street, doubledependentlocality, dependentlocality | exclude=organisation |
addtags | Specifies the extra address fields to include within the response using a comma-delimited list, supported values: latitude, longitude, udprn, deliverypointsuffix, usercategory... see additional response fields below for the full list | addtags=latitude,longitude |
postcodeonly | Limits the request to a postcode-only search rather than matching the search term on other parts of an address, UK only, true or false (default) | postcodeonly=true |
alias | Includes aliases for addresses known to and accepted by Royal Mail, UK only, true or false (default) | alias=true |
nyb | Includes addresses from the Royal Mail Not Yet Built dataset, UK only, true or false (default) | nyb=true |
callback | Specifies the name of your JSONP callback function | callback=jsoncallback |
page | Specifies the index of the page of results to return; the first page is returned by default and has an index of 0, the second page has an index of 1 and so on; see pagination for more info | page=1 |
Supported countries and country codes
The following 249 countries are supported by this endpoint. The address and geocoding levels shown for each country reflect the highest level of data supported. There are three levels:
- Premise: delivery points and buildings
- Street: streets and similar levels of geography
- Locality: villages, towns and cities
Country | Code | Address level | Geocoding level | Updated |
---|---|---|---|---|
Afghanistan | AF | Locality | - | Quarterly |
Aland Islands | AX | Premise | - | Quarterly |
Albania | AL | Street | - | Quarterly |
Algeria | DZ | Street | - | Quarterly |
American Samoa | AS | Premise | - | Monthly |
Andorra | AD | Premise | - | Quarterly |
Angola | AO | Street | - | Quarterly |
Anguilla | AI | Street | - | Quarterly |
Antarctica | AQ | Locality | - | Quarterly |
Antigua and Barbuda | AG | Street | - | Quarterly |
Argentina | AR | Premise | Street | Quarterly |
Armenia | AM | Street | - | Quarterly |
Aruba | AW | Street | - | Quarterly |
Australia | AU | Premise | Street | Quarterly |
Austria | AT | Premise | Street | Quarterly |
Azerbaijan | AZ | Premise | - | Quarterly |
Bahamas | BS | Premise | - | Quarterly |
Bahrain | BH | Premise | - | Quarterly |
Bangladesh | BD | Street | - | Quarterly |
Barbados | BB | Street | - | Quarterly |
Belarus | BY | Street | - | Quarterly |
Belgium | BE | Premise | Street | Quarterly |
Belize | BZ | Street | - | Quarterly |
Benin | BJ | Street | - | Quarterly |
Bermuda | BM | Street | - | Quarterly |
Bhutan | BT | Street | - | Quarterly |
Bolivia | BO | Street | - | Quarterly |
Bonaire, Sint Eustatius And Saba | BQ | Locality | - | Quarterly |
Bosnia and Herzegovina | BA | Premise | - | Quarterly |
Botswana | BW | Premise | - | Quarterly |
Bouvet Island | BV | Street | - | Quarterly |
Br. Indian Ocean Ter. | IO | Locality | - | Quarterly |
Brazil | BR | Premise | Street | Quarterly |
Brunei Darussalam | BN | Premise | - | Quarterly |
Bulgaria | BG | Premise | - | Quarterly |
Burkina Faso | BF | Street | - | Quarterly |
Burundi | BI | Street | - | Quarterly |
Cambodia | KH | Street | - | Quarterly |
Cameroon | CM | Street | - | Quarterly |
Canada | CA | Premise | - | Quarterly |
Cape Verde | CV | Street | - | Quarterly |
Cayman Islands | KY | Premise | - | Quarterly |
Central African Rep. | CF | Street | - | Quarterly |
Chad | TD | Street | - | Quarterly |
Chile | CL | Premise | Street | Quarterly |
China | CN | Street | - | Quarterly |
Christmas Island | CX | Locality | - | Quarterly |
Cocos (Keeling) Islands | CC | Locality | - | Quarterly |
Colombia | CO | Premise | - | Quarterly |
Comoros | KM | Street | - | Quarterly |
Congo (Dem. Rep.) | CD | Street | - | Quarterly |
Congo (Rep.) | CG | Street | - | Quarterly |
Cook Islands | CK | Street | - | Quarterly |
Costa Rica | CR | Premise | - | Quarterly |
Côte d'Ivoire | CI | Locality | - | Quarterly |
Croatia | HR | Premise | - | Quarterly |
Cuba | CU | Street | - | Quarterly |
Curacao | CW | Street | - | Quarterly |
Cyprus | CY | Premise | - | Quarterly |
Czech Republic | CZ | Premise | - | Quarterly |
Denmark | DK | Premise | - | Quarterly |
Djibouti | DJ | Street | - | Quarterly |
Dominica | DM | Street | - | Quarterly |
Dominican Republic | DO | Street | - | Quarterly |
Ecuador | EC | Premise | - | Quarterly |
Egypt | EG | Premise | - | Quarterly |
El Salvador | SV | Street | - | Quarterly |
Equatorial Guinea | GQ | Street | - | Quarterly |
Eritrea | ER | Street | - | Quarterly |
Estonia | EE | Premise | - | Quarterly |
Ethiopia | ET | Street | - | Quarterly |
Falkland Is. (Malvinas) | FK | Street | - | Quarterly |
Faröe Islands | FO | Street | - | Quarterly |
Fiji | FJ | Street | - | Quarterly |
Finland | FI | Premise | - | Quarterly |
France | FR | Premise | Street | Quarterly |
French Guiana | GF | Premise | - | Quarterly |
French Polynesia | PF | Street | - | Quarterly |
French Southern Territories | TF | Locality | - | Quarterly |
Gabon | GA | Street | - | Quarterly |
Gambia | GM | Street | - | Quarterly |
Georgia | GE | Street | - | Quarterly |
Germany | DE | Premise | Street | Quarterly |
Ghana | GH | Street | - | Quarterly |
Gibraltar | GI | Premise | - | Quarterly |
Greece | GR | Premise | - | Quarterly |
Greenland | GL | Street | - | Quarterly |
Grenada | GD | Street | - | Quarterly |
Guadeloupe | GP | Premise | - | Quarterly |
Guam | GU | Premise | - | Monthly |
Guatemala | GT | Street | - | Quarterly |
Guernsey | GG | Premise | Street | Daily |
Guinea | GN | Street | - | Quarterly |
Guinea-Bissau | GW | Street | - | Quarterly |
Guyana | GY | Street | - | Quarterly |
Haiti | HT | Street | - | Quarterly |
Heard Island and McDonald Islands | HM | Street | - | Quarterly |
Honduras | HN | Street | - | Quarterly |
Hong Kong | HK | Premise | - | Quarterly |
Hungary | HU | Premise | - | Quarterly |
Iceland | IS | Premise | - | Quarterly |
India | IN | Premise | Street | Quarterly |
Indonesia | ID | Premise | - | Quarterly |
Iran | IR | Locality | - | Quarterly |
Iraq | IQ | Street | - | Quarterly |
Ireland | IE | Premise | Street | Quarterly |
Isle of Man | IM | Premise | Street | Daily |
Israel | IL | Premise | - | Quarterly |
Italy | IT | Premise | Street | Quarterly |
Jamaica | JM | Street | - | Quarterly |
Japan | JP | Premise | - | Quarterly |
Jersey | JE | Premise | Street | Daily |
Jordan | JO | Premise | - | Quarterly |
Kazakhstan | KZ | Premise | - | Quarterly |
Kenya | KE | Street | - | Quarterly |
Kiribati | KI | Street | - | Quarterly |
Korea (Dem. Rep.) | KP | Locality | - | Quarterly |
Korea (Rep.) | KR | Premise | - | Quarterly |
Kuwait | KW | Premise | - | Quarterly |
Kyrgyzstan | KG | Street | - | Quarterly |
Laos | LA | Locality | - | Quarterly |
Latvia | LV | Premise | - | Quarterly |
Lebanon | LB | Premise | - | Quarterly |
Lesotho | LS | Premise | - | Quarterly |
Liberia | LR | Street | - | Quarterly |
Libya | LY | Street | - | Quarterly |
Liechtenstein | LI | Premise | - | Quarterly |
Lithuania | LT | Premise | - | Quarterly |
Luxembourg | LU | Premise | - | Quarterly |
Macao | MO | Premise | - | Quarterly |
Macedonia, TFYR | MK | Premise | - | Quarterly |
Madagascar | MG | Street | - | Quarterly |
Malawi | MW | Street | - | Quarterly |
Malaysia | MY | Premise | - | Quarterly |
Maldives | MV | Street | - | Quarterly |
Mali | ML | Street | - | Quarterly |
Malta | MT | Premise | - | Quarterly |
Marshall Islands | MH | Premise | - | Monthly |
Martinique | MQ | Premise | - | Quarterly |
Mauritania | MR | Street | - | Quarterly |
Mauritius | MU | Street | - | Quarterly |
Mayotte | YT | Street | - | Quarterly |
Mexico | MX | Premise | - | Quarterly |
Micronesia | FM | Premise | - | Monthly |
Moldova | MD | Street | - | Quarterly |
Monaco | MC | Premise | - | Quarterly |
Mongolia | MN | Street | - | Quarterly |
Montenegro | ME | Premise | - | Quarterly |
Montserrat | MS | Street | - | Quarterly |
Morocco | MA | Premise | - | Quarterly |
Mozambique | MZ | Street | - | Quarterly |
Myanmar | MM | Street | - | Quarterly |
Namibia | NA | Premise | - | Quarterly |
Nauru | NR | Locality | - | Quarterly |
Nepal | NP | Street | - | Quarterly |
Netherlands | NL | Premise | Street | Quarterly |
New Caledonia | NC | Street | - | Quarterly |
New Zealand | NZ | Premise | Street | Quarterly |
Nicaragua | NI | Street | - | Quarterly |
Niger | NE | Street | - | Quarterly |
Nigeria | NG | Street | - | Quarterly |
Niue | NU | Street | - | Quarterly |
Norfolk Island | NF | Street | - | Quarterly |
Northern Mariana Islands | MP | Premise | - | Monthly |
Norway | NO | Premise | Street | Quarterly |
Oman | OM | Premise | - | Quarterly |
Pakistan | PK | Locality | - | Quarterly |
Palau | PW | Premise | - | Monthly |
Palestinian Territory | PS | Locality | - | Quarterly |
Panama | PA | Premise | - | Quarterly |
Papua New Guinea | PG | Street | - | Quarterly |
Paraguay | PY | Premise | - | Quarterly |
Peru | PE | Premise | - | Quarterly |
Philippines | PH | Premise | - | Quarterly |
Pitcairn | PN | Locality | - | Quarterly |
Poland | PL | Premise | Street | Quarterly |
Portugal | PT | Premise | Street | Quarterly |
Puerto Rico | PR | Premise | - | Monthly |
Qatar | QA | Premise | - | Quarterly |
Réunion | RE | Premise | - | Quarterly |
Romania | RO | Premise | - | Quarterly |
Russia | RU | Premise | Street | Quarterly |
Rwanda | RW | Street | - | Quarterly |
S. Georgia and S. Sandwich | GS | Locality | - | Quarterly |
Saint Helena | SH | Street | - | Quarterly |
Saint Lucia | LC | Street | - | Quarterly |
Saint Martin | MF | Street | - | Quarterly |
Saint Pierre and Miquelon | PM | Street | - | Quarterly |
Saint-Barthélemy | BL | Premise | - | Quarterly |
Samoa | WS | Street | - | Quarterly |
San Marino | SM | Premise | - | Quarterly |
Sao Tomé and Principe | ST | Street | - | Quarterly |
Saudi Arabia | SA | Premise | - | Quarterly |
Senegal | SN | Street | - | Quarterly |
Serbia | RS | Premise | - | Quarterly |
Seychelles | SC | Street | - | Quarterly |
Sierra Leone | SL | Street | - | Quarterly |
Singapore | SG | Premise | - | Quarterly |
Sint Maarten | SX | Street | - | Quarterly |
Slovakia | SK | Premise | - | Quarterly |
Slovenia | SI | Premise | - | Quarterly |
Solomon Islands | SB | Street | - | Quarterly |
Somalia | SO | Street | - | Quarterly |
South Africa | ZA | Premise | - | Quarterly |
South Sudan | SS | Street | - | Quarterly |
Spain | ES | Premise | Street | Quarterly |
Sri Lanka | LK | Street | - | Quarterly |
St. Kitts and Nevis | KN | Street | - | Quarterly |
St. Vincent and Grenadines | VC | Street | - | Quarterly |
Sudan | SD | Locality | - | Quarterly |
Suriname | SR | Premise | - | Quarterly |
Svalbard and Jan Mayen | SJ | Street | - | Quarterly |
Swaziland | SZ | Street | - | Quarterly |
Sweden | SE | Premise | - | Quarterly |
Switzerland | CH | Premise | Street | Quarterly |
Syria | SY | Locality | - | Quarterly |
Taiwan | TW | Premise | - | Quarterly |
Tajikistan | TJ | Street | - | Quarterly |
Tanzania | TZ | Street | - | Quarterly |
Thailand | TH | Premise | - | Quarterly |
Timor-Leste | TL | Locality | - | Quarterly |
Togo | TG | Street | - | Quarterly |
Tokelau | TK | Street | - | Quarterly |
Tonga | TO | Street | - | Quarterly |
Trinidad and Tobago | TT | Street | - | Quarterly |
Tunisia | TN | Premise | - | Quarterly |
Turkey | TR | Premise | - | Quarterly |
Turkmenistan | TM | Street | - | Quarterly |
Turks and Caicos Is. | TC | Street | - | Quarterly |
Tuvalu | TV | Street | - | Quarterly |
Uganda | UG | Street | - | Quarterly |
Ukraine | UA | Premise | - | Quarterly |
United Arab Emirates | AE | Premise | - | Quarterly |
United Kingdom | UK | Premise | Street and Premise | Daily |
United States Minor Outlying Islands | UM | Locality | - | Quarterly |
United States of America | US | Premise | - | Every two months |
United States Virgin Islands | VI | Premise | - | Monthly |
Uruguay | UY | Premise | - | Quarterly |
Uzbekistan | UZ | Street | - | Quarterly |
Vanuatu | VU | Street | - | Quarterly |
Vatican City | VA | Street | - | Quarterly |
Venezuela | VE | Street | - | Quarterly |
Viet Nam | VN | Premise | - | Quarterly |
Virgin Islands, British | VG | Street | - | Quarterly |
Wallis and Futuna | WF | Street | - | Quarterly |
Western Sahara | EH | Locality | - | Quarterly |
Yemen | YE | Locality | - | Quarterly |
Zambia | ZM | Street | - | Quarterly |
Zimbabwe | ZW | Premise | - | Quarterly |
Example requests and responses
Return UK addresses with a postcode of NR1 1NE and include up to 3 address lines in the response:
https://ws.postcoder.com/pcw/PCW45-12345-12345-1234X/address/uk/nr1%201ne?format=json&lines=3
[
...
...
{
"addressline1": "Allies Computing Ltd",
"addressline2": "92 St. Faiths Lane",
"summaryline": "Allies Computing Ltd, 92 St. Faiths Lane, Norwich, Norfolk, NR1 1NE",
"organisation": "Allies Computing Ltd",
"number": "92",
"premise": "92",
"street": "St. Faiths Lane",
"posttown": "Norwich",
"county": "Norfolk",
"postcode": "NR1 1NE"
},
...
...
]
Return US addresses that match "1600 Pennsylvania, 20500-0001" and include up to 3 address lines (which exclude the organisation and country fields) in the response:
https://ws.postcoder.com/pcw/PCW45-12345-12345-1234X/address/us/1600%20pennsylvania,%2020500-0001?format=json&lines=3&exclude=organisation,country
[
{
"addressline1": "1600 PENNSYLVANIA AVE NW",
"addressline2": "WASHINGTON DC 20500-0001",
"summaryline": "1600 PENNSYLVANIA AVE NW, WASHINGTON DC 20500-0001",
"organisation": "PRESIDENT",
"number": "1600",
"premise": "1600",
"street": "PENNSYLVANIA AVE NW",
"posttown": "WASHINGTON",
"county": "DISTRICT OF COLUMBIA",
"state": "DISTRICT OF COLUMBIA",
"stateabbreviation": "DC",
"postcode": "20500-0001",
"country": "UNITED STATES"
}
]
Return the Irish address with an Eircode of D02X285 and include up to 3 address lines and coordinates in the response:
https://ws.postcoder.com/pcw/PCW45-12345-12345-1234X/address/ie/d02x285?format=json&lines=3&addtags=latitude,longitude
[
{
"addressline1": "Department of Communications, Climate Action and Environment",
"addressline2": "29-31 Adelaide Road",
"summaryline": "Department of Communications, Climate Action and Environment, 29-31 Adelaide Road, Dublin 2, D02 X285",
"organisation": "Department of Communications, Climate Action and Environment",
"number": "29-31",
"premise": "29-31",
"street": "Adelaide Road",
"posttown": "Dublin 2",
"county": "Co. Dublin",
"postcode": "D02 X285",
"latitude": "53.332067",
"longitude": "-6.255492"
}
]
Response fields
Field | Description | Example |
---|---|---|
summaryline | A summary of the address, ideal for displaying in a drop-down list | Allies Computing Ltd, 92 St. Faiths Lane, Norwich, Norfolk, NR1 1NE |
addressline1 | The first address line, where the total number of address lines is defined by the lines querystring parameter | Allies Computing Ltd |
addressline2 | The second address line | 92 St. Faiths Lane |
addressline3 | The third address line | |
addressline4 | The fourth address line | |
addressline5 | The fifth address line | |
addressline6 | The sixth address line | |
addressline7 | The seventh address line | |
addressline8 | The eighth address line | |
addressline9 | The ninth address line | |
pobox | The PO Box number | |
organisation | The organisation name at that address | Allies Computing Ltd |
departmentname | The department name | |
buildingname | The building name | |
subbuildingname | The sub-building name | |
number | The house or flat number | 92 |
premise | The premise, a combination of buildingname, subbuildingname and number | 92 |
dependentstreet | The dependent street | |
street | The street | St. Faiths Lane |
doubledependentlocality | The double dependent locality | |
dependentlocality | The dependent locality | |
posttown | The post town | Norwich |
county | The county | Norfolk |
postcode | The postcode | NR1 1NE |
notyetbuilt | A true or false indicating whether the address is from the Royal Mail Not Yet Built dataset | false |
alias | A true or false indicating whether the address is a Royal Mail Alias record | false |
recodes | A colon-separated list of the previous postcode, previous delivery point suffix and the date it changed (YYYYMM format) | CM7 8PX:1A:200112 |
state | The state | DISTRICT OF COLUMBIA |
stateabbreviation | The state abbreviation | DC |
morevalues | Set to true when there is another page of results beyond the current page; see pagination for more info | true |
nextpage | The index of the next page of results; see pagination for more info | 1 |
totalresults | The total number of results found; see pagination for more info | 180 |
Additional response fields
Use the addtags
querystring parameter to specify a comma-delimited list of fields that you wish to add to the response. For example, to add latitude, longitude and udprn:
https://ws.postcoder.com/pcw/...?format=json&lines=2&addtags=latitude,longitude,udprn
Field | Description | Example |
---|---|---|
Coordinate data | ||
latitude | ETRS89 latitude (ideal for use with mapping APIs) | 52.6299163702 |
longitude | ETRS89 longitude (ideal for use with mapping APIs) | 1.3018030246 |
latitudeosgb | OSGB36 latitude | 52.6294875459 |
longitudeosgb | OSGB36 longitude | 1.3035999409 |
grideasting | Easting OS Grid Reference (1m precision in units of 1m) | 623545 |
gridnorthing | Northing OS Grid Reference (1m precision in units of 1m) | 308689 |
Address fields | ||
deliverypointsuffix | Delivery Point Suffix | 3JS |
uniquedeliverypointreferencenumber | Unique Delivery Point Reference Number (UDPRN); there is no additional credit cost for including this field; you can also use addtags=udprn | 50959190 |
multipleoccupancycount | Multiple Occupancy Count - count of the number of multiple occupancy addresses for the delivery point | 0 |
administrativecounty | Administrative County (top tier local government) | Norfolk |
postalcounty | Former Postal County | |
traditionalcounty | Traditional County | Norfolk |
usercategory | User Category ('R' for Residential, 'N' for Non-residential, 'L' for Large User) | N |
sortcode | Sortcode for Royal Mail Mailsort | 35529 |
countrycode | Country code within the United Kingdom | 064 |
country | Country name within the United Kingdom | England |
welsh_dependentstreet | Welsh language alternative for dependent street field | |
welsh_street | Welsh language alternative for street field | |
welsh_doubledependentlocality | Welsh language alternative for double dependent locality field | |
welsh_dependentlocality | Welsh language alternative for dependent locality field | |
welsh_posttown | Welsh language alternative for post town field | |
Special PAF keys | ||
The uniquedeliverypointreferencenumber is populated across countries and is the recommended primary key. For Royal Mail PAF addresses only, the following keys can be used as a composite primary key in this order: addresskey ,organisationkey ,postcodetype . | ||
addresskey | The 8-digit PAF Address Key from Royal Mail (UK only) | 00001000 |
organisationkey | The 8-digit PAF Organisation Key from Royal Mail (UK only, '0' for Residential Small Users and Large Users) | 00456120 |
postcodetype | The PAF Postcode Type from Royal Mail (UK only, 'S' for Small Users, 'L' for Large Users) | S |
Census data | ||
oa11 | 2011 Census Output Area | E00136551 |
lsoa11 | 2011 Census Lower Layer Super Output Area | E01033438 |
msoa11 | 2011 Census Middle Layer Super Output Area | E02006907 |
NHS data | ||
commissioningregioncode_gss | NHS Commissioning Region Code (ONS GSS) | E40000007 |
commissioningregionname | NHS Commissioning Region Name | NHS England East of England |
areateamcode_nhs | NHS Area Team Code (NHS) | QMM |
areateamcode_gss | NHS Area Team Code (ONS GSS) | E54000022 |
areateamname | NHS Area Team Name | NHS Norfolk and Waveney Integrated Care Board |
clinicalcommissioninggroupcode_nhs | NHS Clinical Commissioning Group Code (NHS) | 26A |
clinicalcommissioninggroupcode_gss | NHS Clinical Commissioning Group Code (ONS GSS) | E38000239 |
clinicalcommissioninggroupname | NHS Clinical Commissioning Group Name | NHS Norfolk and Waveney ICB - 26A |
Government data | ||
localauthoritycode | Local Authority Code | E07000148 |
localauthorityname | Local Authority Name | Norwich |
electoralwardcode | Electoral Ward Code | E05012910 |
electoralwardname | Electoral Ward Name | Thorpe Hamlet |
electoralcountycode | Electoral County Code | E10000020 |
electoralcountyname | Electoral County Name | Norfolk |
parliamentaryconstituencycode | Westminster Parliamentary Constituency Code | E14000864 |
parliamentaryconstituencyname | Westminster Parliamentary Constituency Name | Norwich South |
europeanelectoralregioncode | European Electoral Region Code | E15000006 |
europeanelectoralregionname | European Electoral Region Name | Eastern |
nationalparkcode | National Park Code | S21000003 |
nationalparkname | National Park Name | The Cairngorms National Park |
Address lines
This endpoint can return up to 9 address lines that contain the required address elements in the correct order for each address. For example:
"addressline1": "123 Rue Brizeux",
"addressline2": "29860 Plouvien",
...
"addressline1": "2101 E COAST HWY STE 100",
"addressline2": "CORONA DEL MAR CA 92625-1963",
...
The address lines returned for addresses in the UK (uk), Guernsey (gg), Jersey (je), Isle of Man (im) and Ireland (ie) are slightly different: they do not contain the posttown, county and postcode by default. For example:
"addressline1": "123 Foxglove Lane",
"addressline2": "Biddenham",
...
Configuring address lines
You can specify the number of address lines by setting the lines
querystring parameter in your request to 1, 2, 3... or 9, although note that empty address lines are not returned. For example:
...&lines=3
"addressline1": "123 Rue Brizeux",
"addressline2": "29860 Plouvien",
...
You can customise what is contained within the address lines by setting the include
and exclude
querystring parameters. For example, to include the posttown and postcode in the address lines:
...&lines=3&include=posttown,postcode
"addressline1": "123 Foxglove Lane",
"addressline2": "Biddenham",
"addressline3": "Ashford, TN27 8BT",
...
Or, to exclude the postcode from the address lines:
...&lines=3&exclude=postcode
"addressline1": "123 Rue Brizeux",
"addressline2": "Plouvien",
...
Working with existing address forms
The address lines returned by this endpoint handle the complexity of international address formats for you, and are ready-made for address forms that use generic address lines.
However, there may be occasions where you need to work with an existing address form that has fields for specific address elements. For example, if you serve customers all around the world, your address form might contain these fields:
Address line 1 |
Address line 2 |
Address line 3 |
City/Town |
State/Region/County |
Postal/Zip code |
For requests where the country is set to UK (uk), Guernsey (gg), Jersey (je), Isle of Man (im) or Ireland (ie), you can return the response fields necessary to populate the form fields above by appending:
...&lines=3
"addressline1": "123 Foxglove Lane", --> Address line 1
"addressline2": "Biddenham", --> Address line 2
...
"posttown": "Ashford", --> City/Town
"county": "Kent", --> State/Region/County (not required in the UK)
"postcode": "TN27 8BT" --> Postal/Zip code
For requests where the country is United States (us), append:
...&lines=3&exclude=posttown,state,stateabbreviation,postcode,country
"addressline1": "2600 E COAST HWY STE 100", --> Address line 1
...
"posttown": "CORONA DEL MAR", --> City/Town
...
"state": "CALIFORNIA",
"stateabbreviation": "CA", --> State/Region/County
"postcode": "92625-2118", --> Postal/Zip code
...
For requests with any other country, append:
...&lines=3&exclude=posttown,county,postcode,country
"addressline1":"123 Rue Brizeux", --> Address line 1
...
"posttown": "Plouvien", --> City/Town
"county": "Finistère", --> State/Region/County
"postcode": "29860", --> Postal/Zip code
...
Pagination
When a request returns many addresses, Postcoder may paginate the response across multiple pages. The first page is returned by default and has an index of 0.
If another page is available, the last address on the current page will include two extra fields: morevalues
(indicates another page is available when "true") and nextpage
(provides the index of the next page).
[
...
...
{
// Last address on current page
...
...
"posttown": "Norwich",
"county": "Norfolk",
"postcode": "NR1 1NE",
"morevalues": "true",
"nextpage": "1",
"totalresults": "180"
}
]
You can retrieve the next page by setting the page
querystring parameter to the index of the next page. In the scenario above, you could do this by adding ?page=1
to your request.
Integration advice
- URL encode all special characters (including /) in your request parameters with %xx encoding
- Verify your request was successful by checking for an HTTP status code of 200; see all HTTP status codes with descriptions
- When using your API key across multiple websites, apps or clients, set the
identifier
querystring parameter to a meaningful value such as "websiteA" or "client123"; you'll then be able to view these identifiers and the number of requests made by each one on the Identifier Usage page - Treat all response fields as optional
- County is no longer required in UK addresses; however, it may include essential postal details for addresses in other countries
- If your address form has a country selector, use the ipaddress endpoint to preset the country based on the user's IP address
Credit cost
Each request costs the following number of credits:
Country | Standard request | Enhanced request using addtags |
---|---|---|
UK | 2 credits | 2.4 credits |
Ireland | 4.5 credits | 4.5 credits |
Rest of world | 2 credits | 2.4 credits |
Buy a credit pack or set up a monthly plan to use with all Postcoder endpoints.