# Search API for stores and apps: filters, facets, typo tolerance and analytics

> One REST endpoint for product and site search: typo tolerance, filters with AND, OR and NOT, facets, variant grouping, similar items, autocomplete and click analytics, with your merchandising applied. TypeScript SDK, EU hosting.

Source: https://typemo.com/features/search-api

Search API

# A complete results page from one API call

Hits, filter counts, typo corrections and popular items for an empty search come back from one request, ranked with your merchandising. A typed TypeScript SDK and an OpenAPI spec come with it, and search runs in the EU.

[Get started](https://typemo.com/register) [Read the docs](https://docs.typemo.com/developers/search-api/)

```bash
curl -sL "https://search.typemo.com/v1/collections/products/search" \
  -H "X-API-Key: sq_your_key" \
  -H "Content-Type: application/json" \
  -d '{ "q": "snekers", "perPage": 5 }'
```

```ts
import { Typemo } from '@typemo-org/sdk';

const typemo = new Typemo({ apiKey: process.env.TYPEMO_KEY });

const results = await typemo.search<Product>('products', {
  q: 'snekers',
  perPage: 5
});
```

```json
{
  "found": 3,
  "correctedQuery": "sneakers",
  "hits": [
    { "title": "Court Sneakers", "price": 79.99, "_score": 5.34 },
    { "title": "Trail Sneakers", "price": 64.99, "_score": 4.91 }
  ]
}
```

Works with your stack

* TypeScript
* Node.js
* JavaScript
* React
* Vue
* Svelte
* OpenAPI

How it works

## From key to results in three steps

The same index serves your widget, your code and your AI agents.

1. Create a key A read-only key for browsers and apps, and a write key that stays on your server.
2. Send your documents Push JSON from your server, or connect a store, a feed, a database or a crawl.
3. Search Call the search endpoint from any language, or use the TypeScript SDK.

Capabilities

## Built for the search UI you design

Typo tolerance, synonyms and your ranking apply to every request, exactly as in the widget.

The response

### Everything a results page needs, in one response

Hits, facet counts, slider ranges, the corrected query, popular items for a search that finds nothing and a redirect come back together. One call draws the whole page.

[Response](https://docs.typemo.com/developers/search-api/#response)

Response

```json
{
  "found": 3,
  "hits": [
    { "title": "Court Sneakers", "price": 79.99, "_score": 5.34 },
    { "title": "Trail Sneakers", "price": 64.99, "_score": 4.91 }
  ],
  "facets": { "brand": [["Stride", 2], ["Acme", 1]] },
  "facetStats": { "price": { "min": 49.99, "max": 79.99 } },
  "correctedQuery": "sneakers",
  "fallback": null,
  "redirect": null
}
```

Query features

### Filters, variants, similar items and autocomplete

Combine filters with AND, OR and NOT, show one result per product with its variants counted, build a similar-items row from one id and add completions as visitors type. A filter on a misspelled field answers 400, so a bug never ships as unfiltered results.

[Parameters](https://docs.typemo.com/developers/search-api/#parameters)

```json
"filter": {
  "AND": [
    { "field": "brand", "op": "in", "value": ["Acme"] },
    { "field": "price", "op": "lte", "value": 100 },
    { "NOT": { "field": "color", "op": "eq", "value": "pink" } }
  ]
}
```

```json
{ "q": "dress", "groupBy": "parent_id" }

// each hit is one product
{ "title": "Linen Dress", "_groupFound": 8 }
```

```json
{ "mode": "vector", "documentId": "1001", "perPage": 6 }
```

```json
{ "q": "sne", "autocomplete": true }
```

TypeScript SDK

### Typed from the same spec as the API

One client for search, documents, synonyms, custom results and analytics, on Node 18 and later and in browsers. Your document type types the hits, and a failed call throws an error with the status and the parameter at fault.

[TypeScript SDK](https://docs.typemo.com/developers/sdk/)

TypeScript SDK

```ts
interface Product { title: string; price: number; brand: string }

const results = await typemo.search<Product>('products', {
  q: 'sneakers',
  sort: 'price:asc'
});

results.hits[0]?.title;   // typed: string
results.fallback?.hits;   // popular items on a miss

await typemo.documents.upsert('products', { documents });
```

Merchandising

### Dashboard rules apply to every API search

Pins, boosts and redirects your team sets in the dashboard shape API results exactly as they shape the widget’s, with no deploy.

[Merchandising](https://typemo.com/features/merchandising)

![Custom results: Summer edit with four pins, Gift guide pinning by a rule, Returns page sending its query to a page](https://typemo.com/images/site/close-rules.jpg)

Analytics

### Your own UI, the same analytics

Send searches, clicks, add-to-carts and purchases from your UI, and they fill the dashboard and the popularity that orders your results, as the widget’s events do.

[Analytics events](https://docs.typemo.com/developers/search-api/#analytics-events)

![Top five queries with their searches, clicks, CTR, average position and growth](https://typemo.com/images/site/close-queries.jpg)

## Ready for production

### Sub-50 ms in region

Searches answer in under 50 ms at p95 in your region, and every response reports its own search time.

### Built-in caching

Repeated searches come from a short cache, and search keeps answering from a saved copy during a brief outage.

### Keys for each place

Read-only keys answer only on the domains you allow. Write keys stay on your server, and either can be limited to one collection.

### OpenAPI spec

Generate a client for any language from the same document the SDK and the API reference come from.

### Large documents

Documents of up to 100 KB with up to 256 fields, and up to 1,000 documents per request.

### Plans by volume

A plan is sized by searches a month and documents held. A search past the plan is never billed.

FAQ

## Frequently asked questions

[Contact our team](https://typemo.com/contact)

### What counts as a search?

Every search request answered: each API call, each request the widget sends as a visitor types, and dashboard previews. Popular suggestions do not count. The API is on every plan, Free included; semantic search and Similar items need a paid plan.

### What happens when I go over my plan?

On a paid plan search keeps answering and is never billed as overage. On Free it pauses until the 1st of the month. We email you at 80 % and 100 % of your plan.

### Can I call it from a browser or a mobile app?

Yes, with a Read only key, and your site listed on the allowed domains. A browser calls its region’s address directly: searchUrl in https\://search.typemo.com/init/{key} names it. A server can call search.typemo.com and follow the 307; curl needs -L.

### Does the API search the same way as the widget?

Yes. Typo tolerance, synonyms, ranking and your merchandising apply exactly as in the widget, and every API search counts in your analytics like any other.

### Is there an SDK for my language?

There is a TypeScript SDK for Node 18 and later and for browsers. Any other language calls the HTTP API directly, or generates a client from the OpenAPI document at https\://api.typemo.com/v1/openapi.json.

### Can I build my UI with InstantSearch?

Yes. The InstantSearch adapter runs InstantSearch.js, React, Vue and Svelte InstantSearch on the same API by swapping the search client.

### How do I get my data out?

We index a copy, so your store, feed or database stays the source. The management API lists the documents a collection holds, 100 a page, and custom results export as a JSON file.

## One index for your widget, your API calls and your agents.

[Get started](https://typemo.com/register) [See plans](https://typemo.com/pricing)
