# API

> Search churches and read autofill records over plain HTTP. Open CORS, no key, no cookies.

Source: https://lookup.heresmychurch.com/docs/api

Base URL `https://lookup.heresmychurch.com/v1`. Open CORS, no key, no cookies. Send a `client` name, such as your app's, so Here's My Church knows which tool is asking.

## GET /v1/search

Try it against the live API:

| Parameter | What it does |
|---|---|
| `q` | What the person typed. Place words like "in Dallas" or ", TX" are understood. |
| `near`, `lat`, `lng` | Rank near a place or point. |
| `country`, `region` | Only return churches there. |
| `limit` | 1 to 50. Defaults to 8. |
| `settled=1` | The person paused, so semantic search may run. |
| `geo=off` | Don't use the request's approximate location. |

The response has `results`, plus `hasMore` when more churches ranked past `limit`. To show more, ask again with a higher `limit` and add the results you haven't shown yet. A higher limit can search wider, so don't assume the first ones come back in the same order. It also has `place` (the place understood from the query, or `null`), `corrected` (the spelling searched instead, or `null`), `degraded` and `semantic`.

## GET /v1/churches/:id

The autofill record. Every key in `fields` is always present, with `null` or `[]` when empty, plus `missing`, `completeness`, `hints`, `freshness.lastVerified` (when someone last confirmed it, in milliseconds, or `null`), `links.heresMyChurch` (the church's page; add `?suggest=1` to open its fix form) and `claimed` (`true` when the church has claimed its listing on Here's My Church, so others' changes go to the church first). Records are cached for a minute, and a change that goes live through Lookup refreshes it at once.

```bash
curl https://lookup.heresmychurch.com/v1/churches/CA-ON-56994145
```

## GET /v1/meta

Field names, what can be contributed and how it's checked (`contributableFields`, each with `countries`, `review` and `checks`), whether adding churches is on (`addEnabled`), completeness weights, counts and attribution.

## POST /v1/churches/:id/contributions

Send corrections as `{ client, changes: [{ field, value }] }`. Fields are `serviceTimes`, `denomination`, `languages`, `ministries`, `phone`, `website`, `email`, `pastorName`, the address, and the reports `reportClosed`, `reportDuplicate` and `reportRelocated`. Send an address as `{ "field": "address", "value": { "street", "city", "postalCode" } }` (any of the three), or as separate `street`, `city` and `postalCode` changes; either way it goes to Here's My Church as one change, and parts you leave out keep their listed values. Up to 8 changes at once. Each field comes back with its own status:

| Status | Meaning |
|---|---|
| `live` | Applied now, such as a blank field filled in. |
| `in_review` | Held. Here's My Church checks it automatically, and a reviewer decides what the checks can't. With `reviewBy: "church"`, the church reviews it first, since it has claimed its listing. |
| `not_applied` | Not changed: the listed value was already the same, or Here's My Church kept it. |
| `rejected` | Not accepted, with a `message` saying why. |
| `try_again` | A temporary problem, such as maintenance or a rate limit. Nothing was refused. |
| `coming_soon` | A field Lookup will accept soon. Name is coming soon. |

`reviewBy` is only present when Here's My Church says who reviews a held change, and so far it's only ever `"church"`. The statuses themselves don't change, so code that reads only `status` keeps working. [Data and review](/docs/data#sharing-fixes-back) has the rules for each field.

```bash
curl -X POST https://lookup.heresmychurch.com/v1/churches/CA-ON-56994145/contributions \
  -H "content-type: application/json" \
  -d '{"client":"lookup-demo","changes":[{"field":"phone","value":"905-555-0100"}]}'
```

> **Sandbox:** Test with `client: "lookup-demo"`. Changes are checked the same way but never sent, and responses say `sandbox: true`.

When a change goes live, the response has `updated: true` and the record and search already show it.

## POST /v1/churches/:id/confirm

"Still correct." Send `{ client }` to mark a listing as checked today. The response has the new `lastVerified`.

## POST /v1/churches

Add a church that isn't listed. Send `{ client, church }`, where `church` has `name`, `city` and `region` (a code like `TX` or a name like `Texas`), and optionally `street`, `postalCode`, `country` (code or name), `phone`, `email`, `website`, `denomination`, `serviceTimes`, `languages`, `ministries`, `pastorName`, `latitude` and `longitude`.

| Status | Meaning |
|---|---|
| `live` | Added. `id` is its new church ID, already searchable. |
| `similar` | It may already be listed. `similar` holds candidates shaped like search results. Send again with `confirmAdd: true` to add it anyway. |
| `rejected` | Not accepted, with a `message`. |
| `try_again` | A temporary problem. Nothing was added. |

```bash
curl -X POST https://lookup.heresmychurch.com/v1/churches \
  -H "content-type: application/json" \
  -d '{"client":"lookup-demo","church":{"name":"New Hope Fellowship","city":"Dallas","region":"TX"}}'
```

With `lookup-demo`, the duplicate check runs against Lookup's own index and nothing is added: a `live` answer has `id: null` and `sandbox: true`.

## POST /v1/ask

Ask a question about these docs. Send `{ question }` (up to 500 characters) and the answer streams back as server-sent events. It powers the Ask AI button and is limited to 10 questions a minute.

## Errors

Errors are JSON with a readable `error` and a stable `code` to check in your code:

| Status | `code` |
|---|---|
| 400 | `invalid` |
| 404 | `not_found` |
| 405 | `method_not_allowed` |
| 413 | `too_large` |
| 429 | `rate_limited` |
| 500 | `unavailable` |
| 503 | `overloaded` |

## Limits

120 requests and 30 semantic searches a minute per visitor, 5 contributions (adds included) and 10 docs questions a minute. Over the limit returns `429`, a busy database returns `503`, and both send `Retry-After`, which browsers on any origin can read.
