Skip to content

Corpus — Sacred Site Mapping

The Corpus engine is the geographic layer of the Torch. It exposes a PostGIS-backed dataset of Catholic churches and sacred sites sourced from OpenStreetMap, enabling proximity searches, name lookups, and diocese boundary queries.

All Corpus endpoints are mounted at /v1/corpus and require an X-API-Key header. See Authentication.


GET /v1/corpus/nearby

Returns sacred sites within a given radius of a coordinate, ordered by proximity (nearest first).

Query parameters:

ParameterTypeDefaultDescription
latfloat(required)Latitude in decimal degrees
lonfloat(required)Longitude in decimal degrees
radius_milesfloat10.0Search radius (0–100 miles)
event_typeLiturgyType(optional)Filter to sites offering a specific liturgy
limitint50Max results (1–200)

Example:

Terminal window
curl "https://api.torchandlily.com/v1/corpus/nearby?lat=40.7128&lon=-74.0060&radius_miles=5" \
-H "X-API-Key: tl_your_key_here"

Response: List[SacredSiteRead]

[
{
"id": 101,
"name": "Saint Patrick's Cathedral",
"slug": "saint-patricks-cathedral-new-york",
"site_type": "CATHEDRAL",
"location": { "type": "Point", "coordinates": [-73.9762, 40.7580] },
"osm_id": "node/123456789",
"website_url": "https://saintpatrickscathedral.org",
"street": "5th Avenue",
"city": "New York",
"state": "NY",
"postcode": "10022",
"phone": null,
"saint_id": null,
"diocese_id": null,
"denomination": "catholic",
"historic": null,
"distance_miles": 1.4,
"liturgies": []
}
]

GET /v1/corpus/find

Searches for sacred sites by name using trigram similarity. Results are alphabetical by default; provide coordinates to sort nearest-first.

Query parameters:

ParameterTypeDefaultDescription
namestr(required, min 2 chars)Church name or partial name
statestr(optional)State abbreviation (e.g. TX)
citystr(optional)City name
latfloat(optional)Your latitude — enables nearest-first ordering
lonfloat(optional)Your longitude — enables nearest-first ordering
limitint50Max results (1–200)

Example:

Terminal window
curl "https://api.torchandlily.com/v1/corpus/find?name=Holy+Redeemer&state=TX" \
-H "X-API-Key: tl_your_key_here"

Response: List[SacredSiteRead]


GET /v1/corpus/search

Finds sacred sites near a named location. Geocoding is performed via OpenStreetMap Nominatim. Provide either q (free-text) or city.

Query parameters:

ParameterTypeDefaultDescription
qstr(optional)Free-text location (e.g. Weatherford TX)
citystr(optional)City name for structured search
statestr(optional)State or region
radius_milesfloat10.0Search radius (0–100 miles)
event_typeLiturgyType(optional)Filter by liturgy type
limitint50Max results (1–200)

Example:

Terminal window
curl "https://api.torchandlily.com/v1/corpus/search?q=Fort+Worth+TX&radius_miles=15" \
-H "X-API-Key: tl_your_key_here"

GET /v1/corpus/slug/{slug}

Returns full details for a single sacred site.

Path parameters:

  • slug — URL-safe site identifier

Response: SacredSiteRead


FieldTypeNotes
idintInternal ID
namestrSite display name
slugstrURL-safe identifier
site_typestrCHURCH, CATHEDRAL, BASILICA, CHAPEL, SHRINE, or ORATORY
locationGeoJSON Point{ "type": "Point", "coordinates": [lon, lat] }
osm_idstr?OpenStreetMap node/way/relation ID
website_urlstr?Official website
streetstr?Street address
citystr?City
statestr?Two-letter state abbreviation
postcodestr?Postal code
phonestr?Phone number
saint_idint?Linked saint ID (Devotio engine)
diocese_idint?Linked diocese ID (populated after diocese sync)
denominationstr?OSM denomination tag (e.g. catholic, roman_catholic)
historicstr?OSM historic classification
distance_milesfloat?Distance from query point (only on /nearby and /search responses)
liturgiesList[LiturgyRead]Mass and sacrament schedules
FieldTypeNotes
idintInternal ID
site_idintParent site ID
typeLiturgyTypeMASS, CONFESSION, or ADORATION
daystrDay name (e.g. Sunday)
start_timestr24-hour time string (e.g. 09:00)
languagestr?Language of the liturgy
ValueDescription
MASSHoly Mass
CONFESSIONSacrament of Confession
ADORATIONEucharistic Adoration

The diocese layer provides the canonical boundary polygons for Catholic dioceses, sourced from OpenStreetMap relation data. Sites are assigned to a diocese via spatial intersection (ST_Within).

GET /v1/corpus/diocese

Returns all published dioceses with name, slug, and site count. Boundary geometry is omitted — use the detail endpoint for the full polygon.

Response: List[DioceseRead]

[
{
"id": 14,
"name": "Archdiocese of New York",
"slug": "archdiocese-of-new-york",
"osm_id": "relation/123456",
"website_url": "https://archny.org",
"site_count": 412
}
]

GET /v1/corpus/diocese/{slug}

Returns a single diocese with its full boundary as a GeoJSON MultiPolygon. Suitable for rendering on a map.

Response: DioceseDetail

{
"id": 14,
"name": "Archdiocese of New York",
"slug": "archdiocese-of-new-york",
"osm_id": "relation/123456",
"website_url": "https://archny.org",
"boundary": {
"type": "MultiPolygon",
"coordinates": [ ... ]
}
}

GET /v1/corpus/diocese/{slug}/sites

Returns all sacred sites whose coordinates fall within the diocese boundary polygon (ST_Within).

Path parameters:

  • slug — diocese slug

Query parameters:

  • limit — max results (default: 100, max: 500)

Response: List[SacredSiteRead]


Cross-engine enrichment: When a site has a saint_id, retrieve the full saint record via GET /v1/devotio/saints/id/{saint_id}. Sites dedicated to a named saint will carry this link when the hagiographic record is present in the Devotio engine.

Diocese membership: The diocese_id field on each site is populated via a spatial pass after dioceses are synced. This field is currently null for US sites — see the Dioceses section for details on data availability. When populated, query the site’s diocese via GET /v1/corpus/diocese/{slug} to retrieve the boundary and metadata.