# Catalog

> Documentation index: [llms.txt](https://westkite.com/docs/llms.txt). Every page is also at its URL plus `.md`.

Returns every type the API serves, with its kind, topic, which of find and lookup answer it, its fields and its source. `GET /v1/catalog/{type}` returns one type with every field a `where` clause takes. Free.

```endpoint
GET /v1/catalog
GET /v1/catalog/{type}
```

## Parameters

| Name | Type | Description |
|---|---|---|
| `type` | path | One type, such as `properties`, `substations` or `night_lights`. |
| `q` | string | Words to match against type names and descriptions, such as `flood` or `rail`. |
| `topic` | string | One [lookup topic](https://westkite.com/docs/api/lookup.md#topics), such as `power` or `hazards`. |
| `kind` | string | One kind, such as `map`, to list only map types. |

## Request

```curl
curl --get "https://api.westkite.com/v1/catalog" \
  -H "Authorization: Bearer $WESTKITE_API_KEY" \
  --data-urlencode "topic=power"
```

```typescript
const res = await fetch("https://api.westkite.com/v1/catalog/properties", {
  headers: { Authorization: `Bearer ${process.env.WESTKITE_API_KEY}` },
});
const { data } = await res.json();
```

```python
import os, requests

res = requests.get(
    "https://api.westkite.com/v1/catalog/properties",
    headers={"Authorization": f"Bearer {os.environ['WESTKITE_API_KEY']}"},
)
fields = res.json()["data"]["fields"]
```

## Response

`GET /v1/catalog/properties`:

```json 200
{
  "data": {
    "type": "properties",
    "kind": "record",
    "topic": null,
    "answered_by": ["find"],
    "summary": "Properties (parcels and buildings) by location, type, size, sale, value, zoning, owner and site facts.",
    "source": "County assessor rolls and recorder records as each county publishes them; site facts measured by West Kite over the parcel outline.",
    "sort": ["held_years", "market_value", "assessed_value", "last_sale_price", "building_sqft", "lot_sqft", "year_built", "last_sale_date"],
    "fields": [
      {
        "name": "building_sqft",
        "type": "number",
        "unit": "sqft",
        "operators": ["=", ">=", "<=", "between", "is known", "is unknown"],
        "values": null,
        "sortable": true,
        "description": ">=, <=, =, between, is known",
        "source": "County assessor rolls and recorder records as each county publishes them.",
        "coverage": 0.912
      },
      {
        "name": "owner_type",
        "type": "enum",
        "unit": null,
        "operators": ["=", "!="],
        "values": ["government", "nonprofit", "llc", "corporation", "trust", "estate", "individual"],
        "sortable": false,
        "description": "= or != (leaves one class out; repeat for several)",
        "source": "County assessor rolls and recorder records as each county publishes them.",
        "coverage": null
      }
    ]
  },
  "missing": [],
  "billing": { "operation_id": "op_4b1d…", "operation": "catalog", "charged_usd": 0, "balance_usd": 9.98 },
  "request_id": "req_4b1d…"
}
```

The example is illustrative and trimmed to two fields. `GET /v1/catalog` returns a list of the same type entries, without `fields` unless you name one type.

| Field | Meaning |
|---|---|
| `type` | The name find, lookup and exports take |
| `kind` | What the type is: a record, an infrastructure type, a map type or a screening type. See [lookup types](https://westkite.com/docs/api/lookup.md#types). |
| `topic` | The [lookup topic](https://westkite.com/docs/api/lookup.md#topics) it belongs to, or `null` |
| `answered_by` | Which endpoints answer it: `find`, `lookup` or both |
| `fields[].name` | The field as a `where` clause names it |
| `fields[].type` | `string`, `number`, `integer`, `boolean`, `date` (`YYYY-MM-DD`) or `enum` |
| `fields[].unit` | `usd`, `sqft`, `acres`, `ft`, `percent`, `ratio`, `year`, `years`, `units`, `stories` and so on; `null` for text and codes |
| `fields[].operators` | The operators find applies to this field. See [the where grammar](https://westkite.com/docs/api/find.md#the-where-grammar). |
| `fields[].values` | The values it takes, when it takes a fixed list |
| `fields[].sortable` | Whether `sort` takes it |
| `fields[].coverage` | Properties only: the share of served records that carry the field, 0 to 1. `null` for other types and for fields West Kite doesn't measure. |
| `source` | Where the type's records come from |

The catalog is read from the same definitions find checks a clause against, so a field it doesn't list is refused, and every operator it lists is one find applies to that field. A low `coverage` means a filter on that field only reaches the records that carry it: a missing value is never zero.

## Errors

| Code | When |
|---|---|
| [`invalid_request`](https://westkite.com/docs/api/errors.md#invalid_request) | An unknown topic or kind. |
| [`not_found`](https://westkite.com/docs/api/errors.md#not_found) | No type has that name. |
