# Address Geocode: US Census Address & UK Postcode Lookup (`calcio_you/address-geocode-us-uk`) Actor

Geocode US street addresses with the official U.S. Census Bureau geocoder (lat/lon, county, census tract, block group, congressional district, GEOIDs) and look up UK postcodes (ONS via postcodes.io: region, council, ward, constituency, NHS ICB). No match = not charged. Pay per lookup.

- **URL**: https://apify.com/calcio_you/address-geocode-us-uk.md
- **Developed by:** [Novarithm](https://apify.com/calcio_you) (community)
- **Categories:** AI, Developer tools, Business
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Address Geocode: US Census Address & UK Postcode Lookup

Turn a US street address or a UK postcode into coordinates and official areas, straight from government sources. Built for AI agents (delivery, logistics, real estate, tax, CRM) and usable from the Apify MCP server.

### What it does

- **US addresses** (`usAddresses`): matched by the official **U.S. Census Bureau Geocoder** (benchmark *Public_AR_Current*). Returns the standardised address, latitude/longitude, state, county, place, census tract, block group, block, ZIP code tabulation area, metro area, school district and congressional district, each with its official GEOID.
- **UK postcodes** (`ukPostcodes`): looked up in the **ONS Postcode Directory** via postcodes.io. Returns latitude/longitude, country, region, local authority, ward, parish, parliamentary constituency (2024 boundaries), NHS ICB, police force and LSOA.

### Pricing (pay per event)

| Event | Price | Charged when |
|---|---|---|
| `us-geocode` | $0.003 | one US address matched |
| `uk-postcode` | $0.002 | one UK postcode found |

No match, invalid input or a source outage is **never charged**. No start fee.

### Example

Input:

```json
{"usAddresses": ["1600 Pennsylvania Ave NW, Washington, DC 20500"], "ukPostcodes": ["M1 1AE"]}
```

Output (shortened, real values):

```json
{"endpoint": "us_geocode", "ok": true, "result": {"matched_address": "1600 PENNSYLVANIA AVE NW, WASHINGTON, DC, 20500", "lat": 38.898703, "lon": -77.035189, "geographies": {"state": {"name": "District of Columbia", "geoid": "11"}, "county": {"name": "District of Columbia", "geoid": "11001"}}}, "charged_event": "us-geocode"}
{"endpoint": "uk_postcode", "ok": true, "result": {"postcode": "M1 1AE", "lat": 53.483487, "lon": -2.231182, "admin_district": "Manchester", "parliamentary_constituency": "Manchester Central"}, "charged_event": "uk-postcode"}
```

### Limits (honest)

- US coordinates are **interpolated along Census address ranges** (street-level precision, not rooftop).
- US: street addresses with a house number only (no PO boxes). Some very new or private addresses (campuses, new developments) are not yet in the Census ranges and return `no_match` (not charged).
- UK: postcode lookup only, not full address matching.
- No coverage outside the US and the UK yet.

### Sources

- U.S. Census Bureau Geocoder — public domain.
- postcodes.io / ONS Postcode Directory, Ordnance Survey — Open Government Licence v3.

# Actor input Schema

## `usAddresses` (type: `array`):

One-line US addresses with a house number. One charged lookup per matched address; no match is not charged.

## `ukPostcodes` (type: `array`):

UK postcodes (e.g. SW1A 2AA). Unknown or invalid postcodes are not charged.

## `queries` (type: `array`):

e.g. \[{"endpoint": "us_geocode", "params": {"address": "..."}}]; endpoints: us_geocode, uk_postcode.

## `maxQueries` (type: `integer`):

Safety cap: only the first N lookups are processed.

## Actor input object example

```json
{
  "usAddresses": [
    "350 5th Ave, New York, NY 10118"
  ],
  "ukPostcodes": [
    "SW1A 2AA"
  ],
  "maxQueries": 1000
}
```

# Actor output Schema

## `results` (type: `string`):

All result items in the default dataset (JSON).

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "usAddresses": [
        "350 5th Ave, New York, NY 10118"
    ],
    "ukPostcodes": [
        "SW1A 2AA"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("calcio_you/address-geocode-us-uk").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "usAddresses": ["350 5th Ave, New York, NY 10118"],
    "ukPostcodes": ["SW1A 2AA"],
}

# Run the Actor and wait for it to finish
run = client.actor("calcio_you/address-geocode-us-uk").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "usAddresses": [
    "350 5th Ave, New York, NY 10118"
  ],
  "ukPostcodes": [
    "SW1A 2AA"
  ]
}' |
apify call calcio_you/address-geocode-us-uk --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,calcio_you/address-geocode-us-uk"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/6oS3QjJDWeIpWxyrV/builds/fTyssl0K16VIrB7yb/openapi.json
