Documentation

Python Code Snippets

The examples below provide a very basic demonstration of how to integrate against the API using Python.

Examples listed demonstrate who to lookup a postcode and query for an address.

In each instance, you would replace your api key and search terms accordingly.

Please note, these are very simple examples of how to use the API and certainly not production-ready code.

If you think these examples could be improved or made more idiomatic, feel free to let us know.

# Query for an Address

import httplib, urllib, json

address_query = "10 Downing Street London"
params = {"api_key": "iddqd", "query": address_query}

conn = httplib.HTTPSConnection("api.ideal-postcodes.co.uk:443")
conn.request("GET", "/v1/addresses?%s" % urllib.urlencode(params))

addresses = json.load(conn.getresponse())['result']
# Lookup a Postcode

import httplib, urllib, json

postcode = "ID1 1QD"
params = {"api_key": "iddqd"}

conn = httplib.HTTPSConnection("api.ideal-postcodes.co.uk:443")
conn.request("GET", "/v1/postcodes/%s?%s" % (urllib.quote(postcode), urllib.urlencode(params)))

addresses = json.load(conn.getresponse())['result']