DEV Community

Cover image for Is There a Free UK Postcode Lookup API?
Alfiya Tarasenko for Geoapify Maps API

Posted on

Is There a Free UK Postcode Lookup API?

At first glance, the answer seems like yes. There are several APIs that let you search postcodes and return location or address data — for example, the Geoapify Postcode API.

But if you try a few of them, you’ll notice something: results can differ. Some APIs return more complete data, others return partial results — or nothing at all for the same postcode.

Even well-known providers can be inconsistent. The reason isn’t the API. It’s the data.

In the UK, the most complete postcode and address dataset is owned by Royal Mail and distributed under license. Free alternatives exist, but they are never fully complete or fully up to date.

What is a postcode in the UK?

UK postcodes are part of the addressing system used by Royal Mail.

In practice, postcodes are linked to specific geographic points where real addresses are grouped. Each postcode represents a set of properties assigned to that location.

Unlike unique identifiers, a single postcode usually corresponds to multiple addresses — sometimes just a few buildings, sometimes dozens.

UK Postcodes on a map
Example of postcode locations in London. Each point represents a postcode linked to a group of addresses. Source: ONS Postcode Directory (Live)

Postcodes were designed for mail delivery, not precise mapping. That’s why they are often represented as points (centroids) rather than exact building locations.

⚠️ Even when postcode locations are available, it’s not always clear which postcode a specific building belongs to. A postcode represents a group of addresses, not a single precise location.

Who owns UK postcode data?

The most complete postcode and address dataset in the UK is maintained by Royal Mail as part of the Postcode Address File (PAF). It contains the full mapping between postcodes and individual addresses.

However, it is not open data.

Access to Royal Mail data is licensed, which means it cannot be freely used, shared, or redistributed. Most developers don’t access it directly, but through official distributors and resellers such as Ideal Postcodes, Postcoder, or Loqate.

This creates several practical challenges:

  • Higher cost compared to open alternatives
  • Licensing restrictions (storage, caching, redistribution)
  • Limited flexibility for building public or large-scale services

As a result, this data is often unavailable to developers who need free, open, or permissively licensed solutions — forcing them to rely on alternative datasets.

Are there free UK postcode lookup solutions?

Yes — there are several free and open solutions available. However, they differ in coverage, structure, and use cases.

Open data sources

Here are the main open datasets used for UK postcode lookup:

Name Link Description
ONS Postcode Directory (ONSPD) Dataset link The most complete open dataset. Provides postcode coordinates and administrative areas, but no full addresses.
GeoNames Dataset link Global dataset with partial UK postcode coverage. Simpler and less detailed.
OpenStreetMap Website Crowdsourced dataset where postcodes are often assigned directly to buildings or areas. Coverage and accuracy vary.

These datasets are free and open, but they do not provide full postcode → address mapping.

Postcode lookup APIs based on open data

To make these datasets easier to use, you can rely on APIs built on top of open data.

One example is the Geoapify Postcode API.

It allows you to:

  • Search by postcode
  • Get coordinates and address information
  • Use a simple HTTP API

Geoapify combines multiple open data sources (such as OpenStreetMap and GeoNames) to provide practical postcode lookup functionality.

Here’s a request example:

curl "https://api.geoapify.com/v1/postcode/search?postcode=TW2%207LS&countrycode=gb&geometry=original&apiKey=YOUR_API_KEY"
Enter fullscreen mode Exit fullscreen mode

And response example:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "postcode": "TW2 7LS",
        "lon": -0.3583,
        "lat": 51.4513,
        "datasource": {
          "sourcename": "geonames",
          "attribution": "GeoNames",
          "license": "CC BY 4.0",
          "url": "https://www.geonames.org/datasources/"
        },
        "country": "United Kingdom",
        "country_code": "gb",
        "state": "England",
        "city": "Greater London",
        "district": "London Borough of Richmond upon Thames",
        "formatted": "London, TW2 7LS, United Kingdom"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [-0.3583, 51.4513]
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

⚠️ Results are based on open data sources and may differ from official Royal Mail data.

Free vs Official UK Postcode Data: Which One to Use?

The right choice depends on your use case and requirements.

Comparison

Proprietary data (Royal Mail PAF) Open data solutions
Coverage Most complete High but incomplete
Addresses Full address list Limited or none
Accuracy Highest Good, but varies
Cost Paid Free
Licensing Restricted Open / permissive
Best for Validation, delivery, checkout Maps, search, analytics

When to use proprietary data

Use Royal Mail-based solutions (via licensed providers) if you need:

  • Accurate address validation
  • Checkout or form autofill
  • Delivery and logistics systems
  • Guaranteed coverage

When to use open solutions

Use open data and APIs (like Geoapify) if you need:

  • Postcode → location lookup
  • Mapping and visualization
  • General search functionality
  • Free or open-source-friendly solutions

Conclusion

So, is there a free UK postcode lookup API?

Yes — but with limitations.

Free and open solutions can work well for many use cases, especially for mapping, search, and general applications. But they rely on datasets that are not fully complete.

If you need accurate, address-level data, you’ll need access to Royal Mail’s licensed dataset.

In the end, UK postcode accuracy is not a technical problem — it’s a data ownership problem.


If you want to try a free solution yourself, explore the Geoapify Postcode API Playground and test postcode lookup in practice.

Top comments (0)