> For a complete page index of the Captain API documentation, fetch https://docs.captain.dev/llms.txt?excludeSpec=true

# Algolia Single Query

POST https://acme.captain.dev/1/indexes/{index}/query
Content-Type: application/json

Algolia's single-index query, answered from the Captain index of the same name.

Reference: https://docs.captain.dev/reference/product-search/algolia-compatibility/algolia-single-query

## Authentication

- `x-algolia-api-key` header (required) — A Captain key, as Algolia clients send it: a search key for queries, a write key for writes.
- `x-algolia-application-id` header (required) — Any value; the hostname selects the tenant.

## Request

### Path parameters

- `index` (string, required)

### Body (application/json)

This endpoint expects an object.

- `params` (string, optional)

## Response

### 200

the query's result

- `hits` (list of AlgoliaResultHitsItems, optional)
- `nbHits` (integer, optional) — nbHits is the number of hits you can page through (under 1,000, exact; at 1,000 or more, the keyword-match count, never below 1,000, with exhaustiveNbHits false when that is a floor), and facet counts count exact keyword matches.
- `page` (integer, optional)
- `hitsPerPage` (integer, optional)
- `nbPages` (integer, optional)
- `exhaustiveNbHits` (boolean, optional)
- `exhaustiveFacetsCount` (boolean, optional)
- `exhaustive` (AlgoliaResultExhaustive, optional)
- `facets` (AlgoliaResultFacets, optional)
- `facets_stats` (AlgoliaResultFacetsStats, optional)
- `query` (string, optional)
- `params` (string, optional)
- `index` (string, optional)
- `processingTimeMS` (integer, optional)
- `queryID` (string, optional) — send it back on Insights events for this search
- `renderingContent` (AlgoliaResultRenderingContent, optional)
- `captain` (AlgoliaResultCaptain, optional) — Captain's own details: mode, engine_ms and the like

## Types

### AlgoliaResultHitsItems

- `objectID` (string, optional)
- `_highlightResult` (AlgoliaResultHitsItemsHighlightResult, optional)

### AlgoliaResultExhaustive

- `nbHits` (boolean, optional)
- `facetsCount` (boolean, optional)

### AlgoliaResultFacets

### AlgoliaResultFacetsStats

### AlgoliaResultRenderingContent

### AlgoliaResultCaptain

Captain's own details: mode, engine_ms and the like

### AlgoliaResultHitsItemsHighlightResult

## Examples

**Request**

```json
{
  "params": "query=rain%20jacket&hitsPerPage=1"
}
```

**Response**

```json
{
  "hits": [
    {
      "objectID": "sku-20311",
      "_highlightResult": {
        "title": {
          "value": "Torrentshell 3L <em>Rain</em> <em>Jacket</em>",
          "matchLevel": "full",
          "matchedWords": [
            "rain",
            "jacket"
          ],
          "fullyHighlighted": false
        }
      },
      "title": "Torrentshell 3L Rain Jacket",
      "brand": "Patagonia",
      "category": "Rain Jackets",
      "price": 179
    }
  ],
  "nbHits": 18,
  "page": 0,
  "hitsPerPage": 1,
  "nbPages": 18,
  "exhaustiveNbHits": true,
  "exhaustiveFacetsCount": true,
  "exhaustive": {
    "nbHits": true,
    "facetsCount": true
  },
  "facets": {},
  "query": "rain jacket",
  "params": "query=rain%20jacket&hitsPerPage=1",
  "index": "products",
  "processingTimeMS": 11,
  "queryID": "4b8d2f0e6a1c43b79e5d3a2c8f7b6e10",
  "renderingContent": {}
}
```

**SDK Code**

```python Python REST
import json
import requests

BASE_URL = "https://acme.captain.dev"
API_KEY = "your_search_key"
INDEX = "products"

headers = {
    "x-algolia-api-key": API_KEY,
    "x-algolia-application-id": "acme",
    "Content-Type": "application/json",
}

response = requests.post(
    f"{BASE_URL}/1/indexes/{INDEX}/query",
    headers=headers,
    json={
        "params": "query=rain%20jacket&hitsPerPage=1",
    },
    timeout=30.0,
)

print(json.dumps(response.json(), indent=2))
```

```typescript TypeScript REST
const BASE_URL = "https://acme.captain.dev";
const API_KEY = "your_search_key";
const index = "products";

const response = await fetch(`${BASE_URL}/1/indexes/${index}/query`, {
  method: "POST",
  headers: {
    "x-algolia-api-key": API_KEY,
    "x-algolia-application-id": "acme",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    params: "query=rain%20jacket&hitsPerPage=1",
  }),
});

const result = await response.json();
console.log(JSON.stringify(result, null, 2));
```