Get a document
# Get a document
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
<ParamField name="uid" type="string" required>
The name of the index.
</ParamField>
<ParamField name="id" type="string | integer" required>
The primary key of the document.
</ParamField>
## Query parameters
<ParamField name="fields" type="string">
A comma separated list of fields to return, like `name,price`. Returns every field by default.
</ParamField>
## Errors
<ResponseField name="document_not_found" type="404">
No document in the index has this primary key.
</ResponseField>
## Request
```bash
curl https://api.zeroindex.test/v1/indexes/products/documents/1042 \
-H "Authorization: Bearer $ZEROINDEX_KEY"
```
```js
const product = await client.index("products").getDocument(1042);
```
```python
product = client.index("products").get_document(1042)
```
## Response (200)
```json
{
"id": 1042,
"name": "Wireless headphones",
"brand": "Vesterlund",
"category": "Audio",
"price": 99,
"in_stock": true,
"tags": ["bluetooth", "noise cancelling"]
}
```
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"]
}