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

# Algolia Multi-Query

POST https://acme.captain.dev/1/indexes/*/queries
Content-Type: application/json

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

Reference: https://docs.captain.dev/reference/product-search/algolia-compatibility/algolia-multi-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

### Body (application/json)

This endpoint expects an AlgoliaMultiQuery.

- `requests` (list of AlgoliaMultiQueryRequestsItems, optional)

## Response

### 200

one result per query

- `results` (list of AlgoliaResult, optional)

## Types

### AlgoliaMultiQueryRequestsItems

- `indexName` (string, optional)
- `params` (string, optional) — URL-encoded Algolia search parameters

### AlgoliaResult

- `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

### 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
{
  "requests": [
    {
      "indexName": "products",
      "params": "query=hiking%20boots&hitsPerPage=2"
    }
  ]
}
```

**Response**

```json
{
  "results": [
    {
      "hits": [
        {
          "objectID": "sku-10482",
          "_highlightResult": {
            "title": {
              "value": "Moab 3 Mid Waterproof <em>Hiking</em> <em>Boot</em>",
              "matchLevel": "full",
              "matchedWords": [
                "hiking",
                "boots"
              ],
              "fullyHighlighted": false
            }
          },
          "title": "Moab 3 Mid Waterproof Hiking Boot",
          "brand": "Merrell",
          "category": "Hiking Boots",
          "price": 139
        },
        {
          "objectID": "sku-10517",
          "_highlightResult": {
            "title": {
              "value": "X Ultra 4 Mid GTX <em>Hiking</em> <em>Boot</em>",
              "matchLevel": "full",
              "matchedWords": [
                "hiking",
                "boots"
              ],
              "fullyHighlighted": false
            }
          },
          "title": "X Ultra 4 Mid GTX Hiking Boot",
          "brand": "Salomon",
          "category": "Hiking Boots",
          "price": 165
        }
      ],
      "nbHits": 42,
      "page": 0,
      "hitsPerPage": 2,
      "nbPages": 21,
      "exhaustiveNbHits": true,
      "exhaustiveFacetsCount": true,
      "exhaustive": {
        "nbHits": true,
        "facetsCount": true
      },
      "facets": {},
      "query": "hiking boots",
      "params": "query=hiking%20boots&hitsPerPage=2",
      "index": "products",
      "processingTimeMS": 14,
      "queryID": "c97e0b2a4f6d41e3a58b1c7d2e9f0a36",
      "renderingContent": {}
    }
  ]
}
```

**SDK Code**

```python Python REST
import json
import requests

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

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

response = requests.post(
    f"{BASE_URL}/1/indexes/*/queries",
    headers=headers,
    json={
        "requests": [
            {"indexName": "products", "params": "query=hiking%20boots&hitsPerPage=2"},
        ],
    },
    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 response = await fetch(`${BASE_URL}/1/indexes/*/queries`, {
  method: "POST",
  headers: {
    "x-algolia-api-key": API_KEY,
    "x-algolia-application-id": "acme",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    requests: [{ indexName: "products", params: "query=hiking%20boots&hitsPerPage=2" }],
  }),
});

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