Esc
ZeroIndex
GuidesAPI referenceSDKsChangelogOverviewBuy ZeroIndex

Get a document

View as MarkdownThe page as plain text

Return one document by its primary key, exactly as it is stored in the index.

GET/v1/indexes/{uid}/documents/{id}

Useful to check what the index holds after a sync. Requires an admin key.

Path parameters

uidstringrequired

The name of the index.

idstring | integerrequired

The primary key of the document.

Query parameters

fieldsstring

A comma separated list of fields to return, like name,price. Returns every field by default.

Errors

document_not_found404

No document in the index has this primary key.

Request

curl https://api.zeroindex.test/v1/indexes/products/documents/1042 \
  -H "Authorization: Bearer $ZEROINDEX_KEY"
const product = await client.index("products").getDocument(1042);
product = client.index("products").get_document(1042)

Response

200
{
  "id": 1042,
  "name": "Wireless headphones",
  "brand": "Vesterlund",
  "category": "Audio",
  "price": 99,
  "in_stock": true,
  "tags": ["bluetooth", "noise cancelling"]
}