> For the complete documentation index, see [llms.txt](https://protectedseas.gitbook.io/navigator-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://protectedseas.gitbook.io/navigator-api-docs/api-reference/search.md).

# Search

```http
GET https://map.navigatormap.org/api/search/
```

The Search endpoint returns JSON arrays of **region** and **site** attributes (see [Region keys](/navigator-api-docs/field-reference/region-keys.md) and [Site keys](/navigator-api-docs/field-reference/site-keys.md)).

Common parameters include `type` (control whether regions and/or sites are returned), `lfp` (LFP filters), `category_id` (filter sites by category), `region_id` (select a region), `ogc_fid` or `ps_id` (select a site), `limit` / `page` / `sort`, and `export_bounds`.

{% hint style="info" %}
The catalog includes a small number of sites whose boundary geometries are withheld for redistribution reasons. These sites return their full attributes here, but no geometry is available for them from the Boundary or Site Details endpoints.
{% endhint %}

## Query modes

The endpoint supports three querying modes:

* **Text query** — Returns regions and sites whose attributes match a text query. `q` is required. Text search operates against Site Name, Managing Authority, Region Name, and Species of Concern, matched against the English record only. See [Text & filter queries](/navigator-api-docs/api-reference/search/text-and-filter-queries.md).
* **Spatial query** — Available **only via POST** with a GeoJSON geometry in the request body. See [Spatial queries](/navigator-api-docs/api-reference/search/spatial-queries.md).
* **Updated sites since date** — Use `type=sites_updated` with a `changed_since` date to retrieve all sites updated on or after that date. See [data synchronization](/navigator-api-docs/conventions/data-synchronization.md).

Any of these can be combined with **filters** that narrow the sites returned — by region, category, LFP, tribal exemptions, or individual fishing and marine-activity fields. See [Activity filters](#activity-filters).

## Request parameters

| Parameter           | Required?                                      | Type           | Description                                                                                                                                                                                                                                                                                                                                                                  |
| ------------------- | ---------------------------------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `region_id`         | Optional                                       | integer        | Filter to a specific region. By default, the search considers all regions.                                                                                                                                                                                                                                                                                                   |
| `v`                 | Optional (**required if `region_id` is used**) | integer        | Required when `region_id` is supplied. Pass `1`.                                                                                                                                                                                                                                                                                                                             |
| `lfp`               | Optional                                       | string         | Filters by Level of Fishing Protection. Numeric codes `0`–`5` (single or comma list, e.g. `lfp=5` or `lfp=4,5`), or keyword buckets `high` (LFP 4 & 5), `mid` (LFP 3), `low` (LFP 1 & 2). `lfp=0` selects proposed sites; the keyword buckets cover scores 1–5 only. Default: no LFP filter.                                                                                 |
| `category_id`       | Optional                                       | integer        | Filter sites by category — a single ID or comma-separated list (e.g. `6` or `6,7`). Returns sites whose category matches any listed ID. Supplying it returns **sites only** (the `regions` array is returned empty rather than populated), and it works in both GET and POST/spatial queries. See [Site Categories](/navigator-api-docs/field-reference/site-categories.md). |
| *activity fields*   | Optional                                       | integer        | Any fishing or marine-activity field name (e.g. `anchoring`, `entry`) as a filter, valued by activity code `0`–`3`. Returns sites only. See [Activity filters](#activity-filters).                                                                                                                                                                                           |
| `tribal_exemptions` | Optional                                       | integer        | Filter by tribal exemptions: `0` (Yes) or `1` (No); single value or comma list. Returns sites only.                                                                                                                                                                                                                                                                          |
| `q`                 | Required for **text query**                    | string         | URL-encoded free-text query. Searches Site Name, Managing Authority, Region Name, and Species of Concern. Matching is against English content only.                                                                                                                                                                                                                          |
| `lang`              | Optional                                       | string         | Language ISO ID (e.g. `en_EN`, `es_ES`). **Currently has no effect on this endpoint** — see "Language support" below. Honoured on [Site Details](/navigator-api-docs/api-reference/site-details.md).                                                                                                                                                                         |
| `type`              | Optional                                       | string         | Result type filter. `regions` = only regions; `sites` = only sites; `sites_updated` = all sites updated since a given date (requires `changed_since`); omitting it returns both regions **and** sites.                                                                                                                                                                       |
| `ogc_fid`           | Optional                                       | integer        | Internal numeric identifier for a specific site. If provided (with `type=sites`), narrows results to that single site.                                                                                                                                                                                                                                                       |
| `ps_id`             | Optional                                       | string         | ProtectedSeas-assigned unique identifier for a specific site. Alternative to `ogc_fid`.                                                                                                                                                                                                                                                                                      |
| `export_bounds`     | Optional                                       | boolean        | If `true`, returns region and/or site bounds along with attributes. If `false` or omitted, only attributes are returned.                                                                                                                                                                                                                                                     |
| `limit`             | Optional                                       | integer        | For sites: max number of site results to return. Used without `page`, returns the first *N* site results. Regions ignore `limit`.                                                                                                                                                                                                                                            |
| `page`              | Optional (requires `limit`)                    | integer        | For sites: page number. Returns results from (page−1)×limit to (page×limit−1).                                                                                                                                                                                                                                                                                               |
| `sort`              | Optional                                       | string         | Sort order for site results. Default: **LFP DESC**, then **area DESC**. Values: `AREA_ASC`, `AREA_DESC`, `LFP_ASC`, `LFP_DESC`, `NAME_ASC`, `NAME_DESC`, `TYPE_ASC`, `TYPE_DESC`. Regions are always sorted in hierarchy order.                                                                                                                                              |
| `changed_since`     | Required when `type=sites_updated`             | string (date)  | Date in `YYYY-MM-DD` format. Returns all sites whose `last_update` is on or after this date.                                                                                                                                                                                                                                                                                 |
| `geometry`          | Required for **POST** spatial queries          | GeoJSON object | A GeoJSON Feature (Point, Polygon, MultiPolygon) or FeatureCollection defining the spatial area. Only regions/sites whose geometry intersects this area are returned.                                                                                                                                                                                                        |

### Activity filters

Beyond `lfp` and `category_id`, sites can be filtered by any individual fishing or marine-activity field. Supply the field name as a query parameter with one or more activity codes:

```
GET https://map.navigatormap.org/api/search/?type=sites&anchoring=1
```

* **Values** are activity codes: `0` Allowed, `1` Prohibited, `2` Restricted, `3` N/A or Unknown. Fields not yet coded for a site are `null` and are never returned by a filter on that field.
* **A comma-separated list** matches any of the values — `anchoring=1,2` returns sites where anchoring is prohibited *or* restricted.
* **Multiple fields** combine with **AND** — `anchoring=1&entry=1` returns sites where both are prohibited.
* Supplying any activity filter returns **sites only** (the `regions` array is returned empty rather than populated). Applies to both GET and POST/spatial queries.

See [Text and filter queries](/navigator-api-docs/api-reference/search/text-and-filter-queries.md) for more filter examples.

#### Filterable fields

**Fishing:** `recreational_fishing`, `commercial_fishing`, `artisanal_fishing`, `subsistence_fishing`, `bottom_trawling`, `pelagic_trawling`, `hook_and_line`, `trolling`, `longlining`, `nets`, `purse_seine_rndhaul_surrd_nets`, `gillnetting`, `gillnets_entangling_nets`, `trammel_nets`, `dip_scoop_nets`, `cast_nets`, `drift_nets`, `other_nets`, `dredges`, `traps_and_pots`, `spear_fishing`, `underwater_extraction_diving`, `hand_capture`, `fish_aggregating_devices`, `misc_gear`

**Marine activities:** `discharge`, `speed`, `entry`, `diving`, `removal_of_historic_artifacts`, `stopping`, `anchoring`, `mooring`, `dragging`, `landing`, `dredging`, `dredging_dumping`, `industr_or_mineral_exploration`, `drilling`, `non_fishing_industr_extraction`, `aquaculture`, `construction`, `overflight_or_drones`

Each matches the field of the same name in the site response (see [Site keys](/navigator-api-docs/field-reference/site-keys.md)). `speed` uses only `1`/`2`/`3` — it has no "Allowed" state.

#### LFP and tribal exemptions

`lfp` and `tribal_exemptions` filter the same way as the activity fields but use their own codings (see their rows in [Request parameters](/navigator-api-docs/api-reference/search.md#request-parameters) above). One behavioral difference: a `tribal_exemptions` filter returns **sites only**, like the activity filters, but an `lfp` filter continues to return the `regions` array.

### Sorting and pagination

Site results are returned in a stable total order: ties on the `sort` key are resolved by a unique identifier, so the same `limit` + `page` request returns the same sites in the same order on every call. See [Pagination](/navigator-api-docs/conventions/data-synchronization.md#pagination) for what this means when syncing the full catalog.

## Error handling

The Search endpoint validates parameters before executing any query. Invalid values return `400` with a descriptive message.

| Parameter           | Validation                                                          | Example error trigger       |
| ------------------- | ------------------------------------------------------------------- | --------------------------- |
| `region_id`         | Must be a positive integer; requires `v`                            | `region_id=435` without `v` |
| `category_id`       | Positive integer, or comma-separated list of positive integers      | `category_id=6,abc`         |
| *activity fields*   | Each must be an activity code `0`–`3` (single or comma list)        | `anchoring=9`               |
| `tribal_exemptions` | Must be `0` or `1` (single or comma list)                           | `tribal_exemptions=2`       |
| `lfp`               | Numeric codes must be `0`–`5`; or a keyword `high`/`mid`/`low`      | `lfp=7`                     |
| `type`              | Must be one of: `regions`, `sites`, `sites_updated`                 | `type=foo`                  |
| `limit`             | Must be a positive integer                                          | `limit=abc`                 |
| `page`              | Must be a positive integer; requires `limit`                        | `page=2` without `limit`    |
| `sort`              | Must be one of the accepted sort values                             | `sort=INVALID`              |
| `lang`              | Must be a supported locale code (e.g. `en_EN`, `fr_FR`, `es_ES`)    | `lang=ja_JP`                |
| `changed_since`     | Required for `type=sites_updated`; valid `YYYY-MM-DD` calendar date | `2025-02-30`                |

Server (`500`) errors return a generic JSON error without exposing internal details:

```json
{ "error": "Database query failed" }
```
