Fetchify Documentation
Fetchify
Sign Up
Contact
Fetchify
Sign Up
Contact
  • Getting Started
  • Integrations

    • BigCommerce
    • CS-Cart
    • Ecommerce Templates
    • EKM
    • Formstack
    • Magento 2
    • Microsoft Dynamics 365
    • NetSuite
    • nopCommerce
    • Odoo
    • OpenCart
    • osCommerce
    • PrestaShop
    • Salesforce
    • Shopify Plus
    • Shopware
    • VirtueMart
    • WooCommerce
    • Xero
    • Zen Cart
    • Zapier
    • Zoey
  • Browser Extension

    • Chrome Browser Extension Guide
    • Firefox Browser Extension Guide
  • JavaScript Library

    • Address Auto-Complete
    • UK Postcode Lookup
    • Phone Validation
    • Email Validation
    • Bank Validation
    • Tutorials

      • Address Auto-Complete Website Integration
      • Customising Address Auto-Complete
      • Address Auto-Complete On Two Forms
      • UK Postcode Lookup in 15 Minutes
      • UK Postcode Lookup On Two Forms (Billing & Shipping)
      • Using Address Auto-Complete in React
      • Using Address Auto-Complete in Vue
    • Sample Code

      • Client Side JavaScript Address Auto-Complete
      • JavaScript & HTML – Client Side Postcode Lookup
  • Address & Validation API

    • Address Auto-Complete
    • Phone Validation API
    • Email Validation API
    • Bank Validation API
  • UK Postcode Lookup API

    • UK Postcode Lookup
    • UK Postcode Lookup (XML)
    • UK Postcode Geocodes
    • Errors
    • Sample Code

      • Microsoft C# Wrapper
      • Microsoft C++ Example Application
      • JSON API integration with jQuery UI
      • PHP – Server Side UK Postcode Lookup
      • Python – UK Postcode Lookup Example
      • RealStudio/XOJO Example
      • Microsoft VB.Net Sample Code
  • Embedded Tech API

    • Embedded Tech API
  • End-of-Life Announcements

    • Plugins & Extensions

Python – UK Postcode Lookup Example

Here is an example of a Python function that uses our UK Postcode Lookup JSON API to return address data for a postcode.

Note

This example requires the Requests library.

import requests

def do_lookup(postcode):
	url = "https://pcls1.craftyclicks.co.uk/json/rapidaddress/?"

	payload = {
		'postcode': postcode,
		'key': 'xxxxx-xxxxx-xxxxx-xxxxx',
		'lines': 2,
		'response': 'data_formatted'
	}

	r = requests.get(url, params=payload)
	data = r.json()
	return data

This can be tested using one of our free test postcodes.

print(do_lookup('AA1 1AA'))

This will produce the following result:

{
    "delivery_points": [
        {
            "organisation_name": "THE BAKERY",
            "department_name": "",
            "line_1": "1 HIGH STREET",
            "line_2": "CRAFTY VALLEY",
            "udprn": "12345678",
            "dps": "1A"
        },
        {
            "organisation_name": "FILMS R US",
            "department_name": "",
            "line_1": "3 HIGH STREET",
            "line_2": "CRAFTY VALLEY",
            "udprn": "12345679",
            "dps": "1B"
        },
        {
            "organisation_name": "FAMILY BUTCHER",
            "department_name": "",
            "line_1": "7 HIGH STREET",
            "line_2": "CRAFTY VALLEY",
            "udprn": "12345680",
            "dps": "1C"
        },
        {
            "organisation_name": "",
            "department_name": "",
            "line_1": "BIG HOUSE, HIGH STREET",
            "line_2": "CRAFTY VALLEY",
            "udprn": "12345681",
            "dps": "1D"
        },
        {
            "organisation_name": "",
            "department_name": "",
            "line_1": "LITTLE COTTAGE",
            "line_2": "17 HIGH STREET, CRAFTY VALLEY",
            "udprn": "12345682",
            "dps": "2A"
        }
    ],
    "delivery_point_count": 5,
    "postal_county": "POSTAL COUNTY",
    "traditional_county": "TRADITIONAL COUNTY",
    "town": "BIG CITY",
    "postcode": "AA1 1AA"
}

Let us know if you run into any issues while integrating our address finder into your application – Contact us.

Prev
PHP – Server Side UK Postcode Lookup
Next
RealStudio/XOJO Example