# Geocoding API with Congressional Districts and Census: Geocodio (`nabeelbaghoor/geocoding-congressional-district-census-api`) Actor

Batch and single address geocoding and reverse geocoding for the US, Canada, Mexico, UK, Australia and New Zealand through the Geocodio API, with appends for congressional districts, state legislative districts, census tracts and FIPS, school districts, time zones, ZIP+4 and ACS. Bring your own key.

- **URL**: https://apify.com/nabeelbaghoor/geocoding-congressional-district-census-api.md
- **Developed by:** [Nabeel Hassan](https://apify.com/nabeelbaghoor) (community)
- **Categories:** Developer tools, Business, Integrations
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 geocoded address or coordinates

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

## Geocoding API with Congressional Districts and Census: Geocodio

Turn addresses into coordinates, or coordinates into addresses, through the Geocodio API with your own API key, and add congressional districts, state legislative districts, census tracts, school districts and time zones to every match in the same call.

Geocodio is a geocoding and data enrichment API for the United States, Canada, Mexico, the United Kingdom, Australia and New Zealand. Its results may be stored permanently and reused, and it is built for batch work: up to 10,000 lookups per request. This actor wraps its four geocoding operations on api.geocod.io (and the Enterprise server api.enterprise.geocod.io): single and batch forward geocoding, and single and batch reverse geocoding, each with Geocodio's data appends. Use it to clean and geocode a CRM or donor list, map customers and stores, match constituents to their congressional district and representative, attach census tract and FIPS codes for analysis, or feed Google Sheets, BI dashboards, a data warehouse or AI agents. Bring your own API key.

BYOK, not live tested: every route, parameter and append field comes from the OpenAPI definition Geocodio publishes at api.geocod.io/openapi-spec.json and its documentation at geocod.io/docs, and every route was probed on 2026-10-25 with an invalid key. The actor has not been run against a live Geocodio key.

### What it does

- **Forward geocoding**: one address per request to GET /geocode, returning latitude and longitude, accuracy score and type (rooftop, range interpolation, street center, place), parsed address components, the formatted address, the data source and Geocodio's stable address key.
- **Batch forward geocoding**: POST /geocode with as many addresses as fit in Geocodio's limit of 10,000 lookups per request. The actor sizes each batch for you, counting one lookup per address plus one per append field.
- **Reverse geocoding**: one latitude,longitude pair per request to GET /reverse, returning the nearest street address and its components.
- **Batch reverse geocoding**: POST /reverse for whole lists of coordinates, with the same automatic batch sizing.
- **Appends only**: in the reverse modes, Geocodio's skipGeocoding option returns only the appends for each coordinate (for example the census block or congressional district of a GPS point), and Geocodio then bills only the appends.
- **Data appends**: every documented Geocodio field as a multi-select: congressional districts with current legislators (cd, plus cd113 to cd120 for past Congresses), state legislative districts (stateleg, stateleg-next), census geographies for the latest vintage or any year from 2010 to 2025 and 2000, ACS demographics, economics, families, housing and social data at any geography level, school districts, USPS ZIP+4, FFIEC CRA and HMDA data, time zone, Canadian federal and provincial ridings and Statistics Canada boundaries, UK Westminster, devolved and local ward constituencies and UK census, and Australian census and electorates.
- **Flat columns for the common appends**: congressional district, representative, senators, state house and senate districts, census tract, block, county and state FIPS, metro area, school district, time zone, UTC offset and ZIP+4, next to the full Geocodio `fields` object.
- **Pay only for matches**: addresses and coordinates with no match, and lookups Geocodio refuses, are recorded as a free row that says why, never charged.

### How to use it

1. Get a Geocodio API key at dash.geocod.io. The first 2,500 lookups each day are free on pay as you go and Flex; after that Geocodio bills your account per lookup. Keys can use single and batch geocoding by default.
2. Paste the key into the API key field, or set the DATA_API_KEY environment secret. The key is sent only to Geocodio in the Authorization header and is removed from everything the actor logs.
3. Pick a mode, paste your addresses or coordinates, choose any data appends and a country, and run.
4. Download the dataset as JSON, CSV or Excel, or connect it to your workflow through the Apify API, webhooks or integrations.

A missing or rejected key, a key without permission, or a Geocodio account over its daily maximum ends the run cleanly with a status message that explains what to change, and nothing is charged.

### Input

| Field | Modes | Description |
| --- | --- | --- |
| `mode` | all | `geocode` (default), `batchGeocode`, `reverse` or `batchReverse` |
| `addresses` | forward | One full address per line, such as `1109 N Highland St, Arlington, VA 22201` |
| `coordinates` | reverse | One `latitude,longitude` pair per line, latitude first, such as `38.9002898,-76.9990361` |
| `fields` | all | Data appends to add, such as `cd`, `stateleg`, `census`, `school`, `timezone`, `zip4`, `acs-demographics` |
| `country` | forward | `USA` (default), `Canada`, `Mexico`, `GB`, `AU`, `NZ`, or empty to let Geocodio infer it |
| `limit` | all | Matches per lookup, default 1; 0 means no limit. Extra matches go in `otherResults` |
| `appendsOnly` | reverse | Skip reverse geocoding and return only the appends (needs at least one append) |
| `endpoint` | all | `standard` (api.geocod.io) or `enterprise` (api.enterprise.geocod.io) |
| `maxResults` | all | The most rows this run returns and charges for (default 100) |
| `requestsPerMinute` | all | Pacing for calls to Geocodio (default 600) |
| `apiKey` | all | Your Geocodio API key |

A single run takes up to 1,000 addresses or coordinates in the single modes and up to 50,000 in the batch modes. For large lists the batch modes are faster and are not counted against Geocodio's per minute rate limit.

### Output

One row per address or coordinate. Example forward geocoding row with the `cd`, `stateleg`, `census`, `school` and `timezone` appends (the `fields` and `addressComponents` objects shortened):

```json
{
    "mode": "geocode",
    "modeLabel": "Forward geocoding",
    "query": "1109 N Highland St, Arlington, VA 22201",
    "found": true,
    "formattedAddress": "1109 N Highland St, Arlington, VA 22201",
    "latitude": 38.886672,
    "longitude": -77.094735,
    "accuracy": 1,
    "accuracyType": "rooftop",
    "isApproximate": false,
    "matchType": "building_centroid",
    "source": "Arlington",
    "stableAddressKey": "gcod_usndjrg9xn28uz888u3fkm6yusrdg",
    "number": "1109",
    "street": "N Highland St",
    "city": "Arlington",
    "county": "Arlington County",
    "stateProvince": "VA",
    "postalCode": "22201",
    "country": "US",
    "congressionalDistrict": 8,
    "congressionalDistrictOcdId": "ocd-division/country:us/state:va/cd:8",
    "congressNumber": "119th",
    "representative": "Donald Beyer (Democrat)",
    "stateHouseDistrict": "2",
    "stateSenateDistrict": "40",
    "censusYear": 2025,
    "censusTract": "101801",
    "censusBlock": "2004",
    "countyFips": "51013",
    "stateFips": "51",
    "fullFips": "510131018012004",
    "metroArea": "Washington-Arlington-Alexandria, DC-VA-MD-WV",
    "schoolDistrict": "Arlington County Public Schools",
    "timezone": "America/New_York",
    "utcOffset": -5,
    "requestedFields": ["cd", "stateleg", "census", "school", "timezone"],
    "resultCount": 1,
    "warnings": null,
    "fields": { "congressional_districts": [], "state_legislative_districts": {}, "census": {}, "school_districts": {}, "timezone": {} },
    "otherResults": null,
    "note": null
}
```

`isApproximate` is true when Geocodio could only place the lookup at a city, county or state centroid (accuracy type `place`, `county` or `state`), which means the street address itself was not found. `warnings` carries Geocodio's `_warnings`, for example an append that was skipped because the match was not street level. Appends-only reverse rows carry the location and the appends, with no address.

### Pricing

| Event | Price | Charged for |
| --- | --- | --- |
| `geocode-result` | 0.005 USD | Each matched address or coordinate without appends |
| `geocode-result-with-appends` | 0.01 USD | Each matched address or coordinate that comes back with data appends |

Lookups with no match and refused or invalid lookups are never charged.

**Geocodio bills your own account separately, per lookup, and appends cost extra lookups on Geocodio's side**: each append field counts as one more lookup per record, so 1,000 addresses with `cd` and `census` use 3,000 Geocodio lookups. The basic `census` field is free with any `acs-*` field, so do not request both. Appends only reverse lookups bill only the appends. Zero-result lookups are not billed by Geocodio. See geocod.io/pricing for current rates.

### FAQ

#### What is the Geocodio API?

Geocodio is a geocoding and data append API run by Dotsquare LLC. It converts addresses to latitude and longitude (forward geocoding) and coordinates to addresses (reverse geocoding) for the US, Canada, Mexico, the UK, Australia and New Zealand, and can append congressional districts, state legislative districts, census data, school districts, time zones and ZIP+4 to each result.

#### Do I need my own Geocodio API key?

Yes. This actor is bring your own key: it calls Geocodio with your key and your Geocodio plan and usage apply. Create a key at dash.geocod.io; the first 2,500 lookups a day are free on pay as you go and Flex.

#### How do I find the congressional district for an address?

Choose Forward geocoding or Batch forward geocoding, paste the addresses and select the `cd` append. Each row gets `congressionalDistrict`, `congressionalDistrictOcdId`, `congressNumber`, `representative` and `senators`, and the full legislator records (contact details, social accounts and IDs such as bioguide) stay in `fields.congressional_districts`. Use `cd113` to `cd120` for past or upcoming Congresses.

#### How do I get the census tract and FIPS code of an address or GPS point?

Select the `census` append (latest vintage) or a year such as `census2020`. Rows carry `censusTract`, `censusBlock`, `countyFips`, `stateFips`, `fullFips` and `metroArea`. For coordinates you already have, use Reverse geocoding with Appends only so Geocodio bills only the census append.

#### How many addresses can I geocode at once?

Geocodio takes up to 10,000 lookups per batch request, where every append counts as a lookup. The batch modes split your list for you, and one run takes up to 50,000 records.

#### Does it work for Canada and the UK?

Yes. Set the country to Canada or GB. Canadian addresses must include the word Canada and return the three character FSA rather than the full postal code. UK lookups need a Geocodio Flex or Unlimited plus UK plan. Canadian appends include `riding`, `provriding` and `statcan`; UK appends include `uk-westminster`, `uk-devolved` and `uk-local`.

#### Can I store the results?

Geocodio's terms allow storing and reusing geocoding results permanently. The exception is UK reverse geocoding addresses, which under Royal Mail PAF licensing may not be supplied to third parties. Keep the `stableAddressKey`: it identifies the address permanently and deduplicates differently written copies of it.

#### What do I pay?

0.005 USD per matched lookup without appends and 0.01 USD per matched lookup with appends, plus your own Geocodio usage, billed by Geocodio. Lookups with no match are free on both sides.

### Keyword map

geocoding API, batch geocoding, bulk address geocoding, reverse geocoding API, address to latitude longitude, coordinates to address, congressional district lookup API, address to congressional district, find my representative by address, state legislative district lookup, census tract lookup, FIPS code lookup, census block by address, school district lookup, time zone by address, ZIP+4 lookup, ACS demographics by address, Canadian riding lookup, UK constituency lookup, Geocodio API, Geocodio batch geocoding.

### Routes and verification

| Mode | Route | Source | Probe with an invalid key |
| --- | --- | --- | --- |
| Forward geocoding | GET /v2/geocode | OpenAPI spec and docs | 403 `Invalid API key` |
| Batch forward geocoding | POST /v2/geocode | OpenAPI spec and docs | 403 `Invalid API key` |
| Reverse geocoding | GET /v2/reverse | OpenAPI spec and docs | 403 `Invalid API key` |
| Batch reverse geocoding | POST /v2/reverse | OpenAPI spec and docs | 403 `Invalid API key` |

Invented paths on the same host answered 404 `Resource not found`, so every route above is confirmed to exist. Response shapes come from the examples in Geocodio's OpenAPI spec. The lists (spreadsheet upload) and distance endpoints are not wrapped.

### Licensing and data use

This actor works only with your own Geocodio account and API key, and Geocodio's Terms of Use apply. Geocodio permits storing, transforming and redistributing results, except UK reverse geocoding address records, and makes the customer responsible for the licences of the underlying data sources. This actor is not affiliated with or endorsed by Geocodio or Dotsquare LLC.

# Actor input Schema

## `mode` (type: `string`):

Forward geocoding turns addresses into coordinates, one request per address. Batch forward geocoding sends up to 10,000 lookups per request, the fastest way to geocode a list. Reverse geocoding turns latitude,longitude pairs into the nearest addresses; batch reverse does the same in bulk. Every mode can add data appends such as congressional districts or census tracts.

## `addresses` (type: `array`):

Forward modes. One full address per line: a street plus city and state, or a postal code. Canadian addresses must include the word Canada. Duplicates are sent once.

## `coordinates` (type: `array`):

Reverse modes. One latitude,longitude pair per line, latitude first, in WGS 84 decimal degrees.

## `fields` (type: `array`):

Optional. Extra data added to every match, such as congressional districts (cd), state legislative districts (stateleg), census tract and FIPS codes (census), school districts, time zone and ZIP+4. Each append costs one extra Geocodio lookup per record on your account. US appends do nothing for other countries.

## `country` (type: `string`):

Forward modes. The country of the addresses. Geocodio recommends setting it: when empty it infers the country and falls back to the US. UK needs a Flex or Unlimited plus UK plan.

## `limit` (type: `integer`):

The most matches Geocodio returns per address or coordinate. The best match fills the row; the rest go in otherResults. 0 means no limit. It does not change what Geocodio bills.

## `appendsOnly` (type: `boolean`):

Reverse modes. Returns only the data appends for each coordinate, with no address, using Geocodio skipGeocoding. Needs at least one data append; Geocodio then bills only the appends.

## `endpoint` (type: `string`):

The self-serve API at api.geocod.io, or the Enterprise API at api.enterprise.geocod.io, which needs an Enterprise key.

## `maxResults` (type: `integer`):

The most rows this run returns and charges for.

## `requestsPerMinute` (type: `integer`):

Pacing for calls to Geocodio. Single lookups are limited to 1,000 per minute on pay as you go and Flex plans; a batch request counts as one call here. Throttled calls are retried after a pause.

## `apiKey` (type: `string`):

Your own Geocodio API key, from dash.geocod.io/apikey. Stored as a secret and sent only to Geocodio in the Authorization header; it is never logged. You can instead set the DATA_API_KEY environment secret.

## Actor input object example

```json
{
  "mode": "geocode",
  "addresses": [
    "1109 N Highland St, Arlington, VA 22201"
  ],
  "country": "USA",
  "limit": 1,
  "appendsOnly": false,
  "endpoint": "standard",
  "maxResults": 100,
  "requestsPerMinute": 600
}
```

# Actor output Schema

## `records` (type: `string`):

One row per address or coordinate the chosen mode looked up.

# 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 = {
    "addresses": [
        "1109 N Highland St, Arlington, VA 22201"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("nabeelbaghoor/geocoding-congressional-district-census-api").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 = { "addresses": ["1109 N Highland St, Arlington, VA 22201"] }

# Run the Actor and wait for it to finish
run = client.actor("nabeelbaghoor/geocoding-congressional-district-census-api").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 '{
  "addresses": [
    "1109 N Highland St, Arlington, VA 22201"
  ]
}' |
apify call nabeelbaghoor/geocoding-congressional-district-census-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nabeelbaghoor/geocoding-congressional-district-census-api"
        }
    }
}
```

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/MLdhCPkMuFMW8VsM3/builds/gi8u2uyWZ1yUs622w/openapi.json
