> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Geocodio plugin

> Geocode addresses one at a time or in batches of up to 10,000 with Geocodio - reverse geocode coordinates, append Census and district data, and measure driving or straight-line distances.

Use **Geocodio** through Corsair: one client, typed API calls.

Copy the API key from your Geocodio dashboard. The key travels as the `api_key` **query parameter**, which is where the API expects it.

Things to know before you call:

* **v2.1 is the current version.** A live probe of v1.9 answered with a `_warnings` entry saying a newer version exists, so the plugin targets v2.1 and does not produce that warning.
* **A bad key answers 403, not 401.** A live probe returned `{"error":"Invalid API key","reference":"https://www.geocod.io/geocodio-403-forbidden-error/"}` with HTTP 403. HTTP errors arrive as core's `ApiError`, with that envelope (minus the address sent) on `error.body`.
* **A result always carries its confidence.** `accuracy` is 0 to 1, `accuracy_type` says how the match was made (`rooftop`, `range_interpolation`, `nearest_street`, `place`) and `match_type` says whether it was exact. A caller that ignores those treats a street centroid like a rooftop.
* **The components are parsed for you.** `address_components` splits the result into `street`, `city`, `state_province`, `postal_code`, `country` and `nation`, so nothing has to re-parse `formatted_address`.
* **Batches are one request, not a loop.** `geocode.batch` and `geocode.batchReverse` take up to 10,000 entries in a single POST and answer a `results` array in the order they were sent. Each entry holds the `query` and its own `response.results`. A failed batch is not retried, since its lookups may already be billed.
* **`parse` costs no lookup.** It splits an address without geocoding it, which is the cheap way to clean data before spending lookups on it.
* **Distances come in two flavours.** `driving` follows roads and returns a duration; `straightline` and `haversine` are the as-the-crow-flies distance with no duration. Distances come from `distance.fromOrigin` and `distance.matrix`, which both accept all three modes; the geocode calls take no distance option.
* **An enterprise host exists.** Pass `enterprise: true` on `geocode.forward`, `geocode.reverse`, `geocode.batch`, `geocode.batchReverse` and `distance.fromOrigin` to use `api.enterprise.geocod.io` instead of the self-serve host. `geocode.parse`, `distance.matrix` and the jobs and lists calls always use the self-serve host.
* **Uploading a spreadsheet is not included.** That route needs a multipart file upload; `lists.all`, `lists.get` and `lists.delete` are here so an existing list can be tracked, but a new one has to be uploaded from the dashboard.

**What you get:**

* 13 typed API operations

## Setup

**1. Install**

```bash npm theme={null}
npm install corsair @corsair-dev/geocodio better-sqlite3
npm install --save-dev @types/better-sqlite3
```

```bash yarn theme={null}
yarn add corsair @corsair-dev/geocodio better-sqlite3
yarn add --dev @types/better-sqlite3
```

```bash pnpm theme={null}
pnpm install corsair @corsair-dev/geocodio better-sqlite3
pnpm install --save-dev @types/better-sqlite3
```

```bash bun theme={null}
bun add corsair @corsair-dev/geocodio better-sqlite3
bun add --dev @types/better-sqlite3
```

**2. Add the plugin**

```ts corsair.ts theme={null}
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { geocodio } from '@corsair-dev/geocodio';

export const corsair = createCorsair({
	plugins: [
		geocodio(),
	],
	database: new Database('corsair.db'),
	kek: process.env.CORSAIR_KEK!,
	multiTenancy: true,
	hub: {
		projectApiKey: process.env.CORSAIR_API_KEY!,
		signingSecret: process.env.CORSAIR_SIGNING_SECRET!,
	},
});
```

With `multiTenancy: true`, scope calls with `corsair.withTenant(id)`. See [Quick start](https://docs.corsair.dev/quick-start.md) for KEK + Hub keys, and [Multi-tenancy](https://docs.corsair.dev/concepts/multi-tenancy.md) for account isolation.

**3. Choose authentication**

> [tab] API Key (Recommended)
>
> Store the Geocodio API key before the first call: `pnpm corsair setup --plugin=geocodio --tenant=acme api_key=<your-key>` (leave out `--tenant` without `multiTenancy`), or pass it as `key` in the plugin options. With Hub, each tenant enters their own key on the connect page. See [API key auth](https://docs.corsair.dev/concepts/api-key).
>
> ```ts theme={null}
> geocodio()
> ```
>
> More: [API Key](https://docs.corsair.dev/concepts/api-key)

**4. Connect a tenant**

Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see [Connect / OAuth](https://docs.corsair.dev/management/connect).

```ts theme={null}
const { connectUrl } = await corsair.manage.connect.createLink({
	plugin: 'geocodio',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**Geocode an address**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.geocodio.api.geocode.forward({
	q: '1109 N Highland St, Arlington, VA 22201',
	fields: ['timezone'],
});
```

**Delete a distance job**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.geocodio.api.jobs.delete({ identifier: 'abc123' });
```

See the full list on the [API](https://docs.corsair.dev/plugins/geocodio/api.md) page.

## What's next

> [card] [API reference](https://docs.corsair.dev/plugins/geocodio/api.md)
>
> Every `geocodio.api.*` operation with input and output types.

> [card] [Connect / OAuth](https://docs.corsair.dev/management/connect)
>
> createLink, Hub delivery, and tenant connect flows.

> [card] [Use with agents](https://docs.corsair.dev/mcp-adapters/mcp-adapters)
>
> Expose this plugin's operations as MCP tools.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.