---
title: "Document iterator"
method: GET
path: "/api/v1/index/{index_id}/iterator"
tags: ["Iterator"]
---

# Document iterator

`GET /api/v1/index/{index_id}/iterator`

Document iterator via GET and POST are identical, only the way parameters are passed differ.
The document iterator allows to iterate over all document IDs and documents in the entire index, forward or backward.
It enables efficient sequential access to every document, even in very large indexes, without running a search.
Paging through the index works without collecting document IDs to Min-heap in size-limited RAM first.
The iterator guarantees that only valid document IDs are returned, even though document IDs are not strictly continuous.
Document IDs can also be fetched in batches, reducing round trips and significantly improving performance, especially when using the REST API.
Typical use cases include index export, conversion, analytics, audits, and inspection.
Explanation of "eventually continuous" docid:
In SeekStorm, document IDs become continuous over time. In a multi-sharded index, each shard maintains its own document ID space.
Because documents are distributed across shards in a non-deterministic, load-dependent way, shard-local document IDs advance at different rates.
When these are mapped to global document IDs, temporary gaps can appear.
As a result, simply iterating from 0 to the total document count may encounter invalid IDs near the end.
The Document Iterator abstracts this complexity and reliably returns only valid document IDs.
# Parameters
- docid=None, take>0: **skip first s document IDs**, then **take next t document IDs** of an index.
- docid=None, take<0: **skip last s document IDs**, then **take previous t document IDs** of an index.
- docid=Some, take>0: **skip next s document IDs**, then **take next t document IDs** of an index, relative to a given document ID, with end-of-index indicator.
- docid=Some, take<0: **skip previous s document IDs**, then **take previous t document IDs**, relative to a given document ID, with start-of-index indicator.
- take=0: does not make sense, that defies the purpose of get_iterator.
- The sign of take indicates the direction of iteration: positive take for forward iteration, negative take for backward iteration.
- The skip parameter is always positive, indicating the number of document IDs to skip before taking document IDs. The skip direction is determined by the sign of take too.
- include_document: if true, the documents are also retrieved along with their document IDs.
Next page:     take last  docid from previous result set, skip=1, take=+page_size
Previous page: take first docid from previous result set, skip=1, take=-page_size
Returns an IteratorResult, consisting of the number of actually skipped document IDs, and a list of taken document IDs and documents, sorted ascending).
Detect end/begin of index during iteration: if returned vec.len() < requested take || if returned skip <requested skip

## Path parameters

- `index_id` integer, required

## Query parameters

- `document_id` integer, required
- `skip` integer, required
- `take` integer, required
- `include_deleted` boolean, required
- `include_document` boolean, required
- `fields` string[], required

## Headers

- `apikey` string, required

## Response `200`

Document ID found, returning an IteratorResult

- IteratorResult — Iterator
  - `skip` integer, required — number of actually skipped documents
  - `results` IteratorResultItem[], required — document IDs, and optionally the documents themselves
    - `doc_id` integer, required — document ID
    - `doc` object, nullable — document

## Other responses

- `400` — Request object incorrect
- `401` — api_key missing
- `404` — api_key does not exists

## Changes

- **2026-07-13** `e0feb7866512` — 1 info
  - endpoint added
- **2026-06-21** `4cfd9d95648c` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/seekstorm/apis/seekstorm-rest-api-documentation/changes/api/v1/index/:index_id/iterator/get.md)

---

[API](https://skmtc.dev/seekstorm/apis/seekstorm-rest-api-documentation.md) · [All operations](https://skmtc.dev/seekstorm/apis/seekstorm-rest-api-documentation/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/seekstorm/seekstorm-rest-api-documentation/revisions/f464579dd19f/schema)
