Database endpoints
Search by location
Find locations inside a bounding box, within a radius, or nearest to a point.
GET /v1/tenants/{tenant}/geo/{schema}/{field}
- Describe the search areaSupply a box, radius or nearest-point request.
- Search the location fieldMatch points within the selected schema.
- Read matching document IDsInspect distance and any pending index repair.
Before you start
Use your database bearer token.
Register a geospatial index on demo.locations.location and insert coordinates before running the example.
Path parameters
| Field | Type | Required |
|---|---|---|
tenant | string | Required |
schema | string | Required |
field | string | Required |
Query parameters
| Field | Type | Required |
|---|---|---|
mode | string | Optional |
lat | number | Optional |
lon | number | Optional |
radius_m | number | Optional |
k | integer | Optional |
min_lat | number | Optional |
min_lon | number | Optional |
max_lat | number | Optional |
max_lon | number | Optional |
limit | integer | Optional |
Headers
| Field | Type | Required | Description |
|---|---|---|---|
x-oc-db-user | string | Optional | Acting database user (role, grant and row-policy checks). Send with x-oc-db-key. |
x-oc-db-key | string | Optional | API key of the x-oc-db-user user. |
Read the result
hits contains matching document IDs, with distance_m when the search mode provides a distance. count is the returned hit count. Check index_repair_pending before assuming the index is fully repaired.
Response statuses
HTTP status reference
| Status | What to do |
|---|---|
| 200 | OK |
| 400 | Correct the request before retrying. |
| 401 | Check the credential and Authorization header. |
| 402 | Check feature access or available credits. |
| 403 | Check tenant access, roles and permissions. |
| 404 | Check the resource ID and API route. |
| 429 | Honor Retry-After when present; back off. |
| 500 | Check the outcome before retrying a write. |
| 503 | Honor Retry-After when present; check write outcomes. |