> ## Documentation Index
> Fetch the complete documentation index at: https://storerouter.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Search by color

> Filter product search by one shade or a whole color family, across every store or within one, and draw a store's color palette.

Every store names its colors its own way: one calls a shirt "Sage", another "Eucalyptus", a third "Dusty Green". StoreRouter gives every product the same two color labels, whatever the store calls it:

* a **shade**, a CSS color name such as `darkseagreen`, `navy`, or `goldenrod`
* a **color family**, one of 12 broad colors such as `green`, `blue`, or `brown`

Filter on either one to find products in the color a shopper asks for, in every store or in one store. [`GET /v1/taxonomy/colors`](#list-the-accepted-colors) returns every accepted value. To see it working, open the [Shop by color](https://storerouter.ai/developers/stores/by-color) palette.

## Three ways to ask for a color

| Shopper asks for | Send | Matches |
| - | - | - |
| "sage green linen shirt" | `q` with the color in it | The shade StoreRouter reads from the text (`darkseagreen`) |
| That exact shade | A `color` facet: `["darkseagreen"]` | One shade |
| "Something green" | A `color_family` facet: `["green"]` | Every shade of green: sage, olive, emerald, mint, and so on |

All three are sent to [`POST /v1/products/search`](https://storerouter.ai/docs/api-reference/search-products).

### Put the color in the query

The simplest option is to pass the shopper's words in `q`. StoreRouter reads the color as one shade and filters by it:

```bash theme={null}
curl -sS https://api.storerouter.ai/v1/products/search \
  -H "Authorization: Bearer $OCTOGEN_PLATFORM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"q": "sage green linen shirt", "limit": 10}'
```

The color StoreRouter read from the text appears in `effectiveQuery` as a facet with `source: "generated"`:

```json theme={null}
"effectiveQuery": {
  "text": "sage green linen shirt",
  "facets": [
    {"name": "category_path.depth_3", "values": ["Shirts & Blouses"], "source": "generated"},
    {"name": "color", "values": ["darkseagreen"], "source": "generated"},
    {"name": "fabric", "values": ["fabric__linen"], "source": "generated"}
  ]
}
```

If StoreRouter reads the wrong color, send your own `color` or `color_family` facet. Either one replaces the color read from the text. To drop the color filter altogether, send `"omit_generated_facets": ["color"]`. See [Control query understanding](https://storerouter.ai/docs/guides/catalog-search.md#control-query-understanding).

### Filter by one shade

Use the `color` facet when you already know the exact shade, such as from a color picker or a swatch the shopper tapped:

```bash curl theme={null}
curl -sS https://api.storerouter.ai/v1/products/search \
  -H "Authorization: Bearer $OCTOGEN_PLATFORM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "linen shirt",
    "facets": [{"name": "color", "values": ["darkseagreen"]}],
    "limit": 10
  }'
```

```python python theme={null}
import asyncio
from octogen_ai_sdk import OctogenClient

async def main() -> None:
    async with OctogenClient(base_url="https://api.storerouter.ai/v1") as client:
        page = await client.search_products(
            q="linen shirt",
            facets=[{"name": "color", "values": ["darkseagreen"]}],
            limit=10,
        )
        for product in page.items:
            print(product.title)

asyncio.run(main())
```

```typescript typescript theme={null}
import { OctogenClient } from "@octogen-ai/sdk";

const client = new OctogenClient({ baseUrl: "https://api.storerouter.ai/v1" });
const page = await client.searchProducts({
  q: "linen shirt",
  facets: [{ name: "color", values: ["darkseagreen"] }],
  limit: 10,
});

for (const product of page.items) {
  console.log(product.title);
}
```

The `color` facet takes [CSS color names](https://developer.mozilla.org/en-US/docs/Web/CSS/named-color) in lowercase without spaces, such as `darkseagreen`, `navy`, `maroon`, or `ivory`. There are two more values: `bronze`, and `multi` for products that have several colors. To get all 150, see [List the accepted colors](#list-the-accepted-colors). A value that is not a shade name, such as `"sage"`, returns a `422`:

```json theme={null}
{
  "detail": [{
    "loc": ["body", "facets", 0],
    "msg": "Value error, unsupported color values ['sage']; use an indexed shade name, or attribute_facets.color for taxonomy colors such as clear",
    "type": "value_error"
  }]
}
```

To find the shade for a word a shopper types, send the word in `q` and read the `color` facet from `effectiveQuery`.

> [!NOTE]
>
> `attribute_facets.color` is a separate filter. It holds taxonomy color values, such as `color__navy` and `color__clear`, which are listed at [`GET /v1/taxonomy/attributes/color/values`](https://storerouter.ai/docs/api-reference/list-taxonomy-attribute-values). They are not shades, and sending one as a `color` value returns a `422`. For "find this color" use cases, use `color` or `color_family`.

### Filter by a color family

Use `color_family` when the shopper names a broad color, or when you want more results than one shade gives:

```bash curl theme={null}
curl -sS https://api.storerouter.ai/v1/products/search \
  -H "Authorization: Bearer $OCTOGEN_PLATFORM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "linen shirt",
    "facets": [{"name": "color_family", "values": ["green"]}],
    "limit": 10
  }'
```

```python python theme={null}
page = await client.search_products(
    q="linen shirt",
    facets=[{"name": "color_family", "values": ["green"]}],
    limit=10,
)
```

```typescript typescript theme={null}
const page = await client.searchProducts({
  q: "linen shirt",
  facets: [{ name: "color_family", values: ["green"] }],
  limit: 10,
});
```

This returns `limegreen`, `lightseagreen`, and `darkolivegreen` shirts in the same results. There are 12 color families:

`white` · `gray` · `black` · `red` · `orange` · `brown` · `yellow` · `green` · `blue` · `purple` · `pink` · `multicolor`

Beige, camel, and tan are part of `brown`. Ivory and linen are part of `white`. Each shade belongs to exactly one family. For example, `darkseagreen` belongs to `green`, `maroon` to `red`, and `goldenrod` to `yellow`.

To match more than one color, list several values in one facet, such as `{"name": "color_family", "values": ["black", "gray"]}`. To remove a color instead, send the same facet in `exclude_facets`.

## List the accepted colors

`GET /v1/taxonomy/colors` returns every value the `color_family` and `color` facets accept, with each shade's family. Use it to build a color picker, to check a value before sending it, or to give an agent the full list:

```bash theme={null}
curl -sS https://api.storerouter.ai/v1/taxonomy/colors \
  -H "Authorization: Bearer $OCTOGEN_PLATFORM_API_KEY"
```

```json theme={null}
{
  "facets": [
    {
      "facetName": "color_family",
      "values": ["pink", "red", "orange", "brown", "yellow", "green",
                 "blue", "purple", "white", "gray", "black", "multicolor"]
    },
    {
      "facetName": "color",
      "values": [
        {"value": "aliceblue", "colorFamily": "white"},
        {"value": "darkseagreen", "colorFamily": "green"},
        {"value": "multi", "colorFamily": "multicolor"}
      ]
    }
  ]
}
```

The response above is shortened: `color` lists all 150 shades. Every value can be sent back unchanged in a `facets` entry, and each shade's `colorFamily` is itself a `color_family` value. To build a "green, then its shades" picker, keep the shades whose `colorFamily` is `green`.

The list changes only when StoreRouter adds a value, so you can cache it; the response allows caching for a day. The request is not billed. Agents connected through [MCP](https://storerouter.ai/docs/mcp/overview.md) can call the `taxonomy_colors` tool, which returns the same list.

The list says which values are valid, not which ones a store has products in. To see what's in stock, use [`facet-counts`](#show-the-colors-available).

## Search one store or all of them

Leave out `catalogs` to search every store your key can access. Send `catalogs` to search only certain stores:

```json theme={null}
{
  "catalogs": ["nordstrom"],
  "facets": [{"name": "color_family", "values": ["blue"]}],
  "limit": 24
}
```

You can leave out `q` to list a store's products in a color with no search text. Add a category facet such as `category_path.depth_2` to narrow results to one kind of product.

## Read each result's color

When a search filters by color, each result is the specific color version of the product that matched, not the product in general. For example, a shirt sold in six colors comes back as its sage version, and `productUrl` opens the page for that color. Each result has these color fields:

| Field | Description |
| - | - |
| `colors` | The shade or shades of this color version, main shade first, such as `["darkseagreen"]`. These are `color` facet values. |
| `selectedOptions.color` | The store's own name for the color, such as `"Sage"`. |
| `primaryColor.hexCode` | The main color as `#RRGGBB`, measured from the product photo. Use it for swatches. |
| `primaryColor.isccName` | A standard name for that color, such as `"Grayish Yellow Green"`. |
| `hexCode` | The store's own swatch color, when the store provides one. |

```json theme={null}
{
  "title": "The Palma Shirt // Sage",
  "productUrl": "https://beachwoodthelabel.com/products/the-palma-shirt-sage",
  "colors": ["darkseagreen"],
  "selectedOptions": {"color": "Sage"},
  "primaryColor": {"hexCode": "#8A9A7D", "isccName": "Grayish Yellow Green"}
}
```

`primaryColor` and `hexCode` are left out of results that don't have them, so show a fallback swatch when they are missing. You can use the `color` shade or `color_family` instead.

## Show the colors available

To build color filter chips or a palette with counts, call [`POST /v1/products/facet-counts`](https://storerouter.ai/docs/api-reference/count-product-facets). It counts the products that match each color family or each shade. It takes the same filters as search, so each count matches the results that selecting that color would return.

### Count color families

```bash curl theme={null}
curl -sS https://api.storerouter.ai/v1/products/facet-counts \
  -H "Authorization: Bearer $OCTOGEN_PLATFORM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"q": "linen shirt", "facet_names": ["color_family"]}'
```

```python python theme={null}
counts = await client.count_product_facets(
    q="linen shirt",
    facet_names=["color_family"],
)
```

```typescript typescript theme={null}
const counts = await client.countProductFacets({
  q: "linen shirt",
  facetNames: ["color_family"],
});
```

```json theme={null}
{
  "facets": [{
    "name": "color_family",
    "values": [
      {"value": "white", "count": 6226},
      {"value": "blue", "count": 3737},
      {"value": "brown", "count": 1994},
      {"value": "black", "count": 1658}
    ]
  }]
}
```

Values come back in lowercase, the same form you send, so you can pass one straight back in a `color_family` facet. Add `catalogs` to count one store's colors.

### Count the shades in a family

Send `color` in `facet_names` to count shades. To count the shades of the items in one family, add that family as a facet:

```bash theme={null}
curl -sS https://api.storerouter.ai/v1/products/facet-counts \
  -H "Authorization: Bearer $OCTOGEN_PLATFORM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "linen shirt",
    "facets": [{"name": "color_family", "values": ["green"]}],
    "facet_names": ["color"]
  }'
```

```json theme={null}
{
  "facets": [{
    "name": "color",
    "values": [
      {"value": "olive", "count": 244},
      {"value": "darkolivegreen", "count": 167},
      {"value": "darkseagreen", "count": 165},
      {"value": "green", "count": 113},
      {"value": "white", "count": 94}
    ]
  }]
}
```

The family facet selects the green items, and then every shade those items have is counted. So a green-and-white shirt also counts under `white`, which is not a green shade. To build a "green, then its shades" picker, keep only the values whose `colorFamily` is `green` in [`GET /v1/taxonomy/colors`](#list-the-accepted-colors):

```typescript theme={null}
// colors: the GET /v1/taxonomy/colors response; counts: the facet-counts response above
const greenShades = new Set(
  colors.facets
    .find((facet) => facet.facetName === "color")
    .values.filter((shade) => shade.colorFamily === "green")
    .map((shade) => shade.value),
);
const picker = counts.facets[0].values.filter((v) => greenShades.has(v.value));
```

A few things to know about shade counts:

* **Counts are per color version.** With `color` in `facet_names`, every count in the response counts the color versions of products, the same thing a `color` search returns.
* **Shades can add up to more than the total.** A product with several shades, such as `["red", "white"]`, counts once under each.
* **Your own `color` facet is ignored.** As with every counted facet, a `color` count ignores any `color` facet you send, so each shade shows what selecting it would return. Other facets, such as `color_family` above, still apply.
* **You get every shade by default.** `value_limit` defaults to 150, the number of shades.

> [!NOTE]
>
> The Python and TypeScript SDKs accept `color` in `facet_names` from their next release. Until then, use the REST request above.

## Tips

* **Start broad.** A single shade can be narrow in a small store. If a `color` search returns few results, try that shade's `color_family`.
* **Let `relax` fall back.** With `relax: true`, a query that returns nothing drops filters in stages, and color is one of the filters it can drop. A `color` or `color_family` facet you send is never dropped unless you mark it `"relaxable": true`. See [`relax`](https://storerouter.ai/docs/api-reference/search-products).
* **Report what ran.** Show shoppers the color in `effectiveQuery`, such as "Showing sage green", so they can correct it.
* **Use full product details.** Use the result's `productUrl` with [product lookup](https://storerouter.ai/docs/guides/product-lookup.md) to get every color the product comes in, with `colors[].hexCode` for each.

## Related

* [Catalog Search](https://storerouter.ai/docs/guides/catalog-search.md): every search field and facet
* [List taxonomy colors](https://storerouter.ai/docs/api-reference/list-taxonomy-colors.md): the accepted `color` and `color_family` values
* [Search products API reference](https://storerouter.ai/docs/api-reference/search-products.md#facet-names)
* [Shop by color](https://storerouter.ai/developers/stores/by-color): a live palette of every store, with the request behind it


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.