Skip to content

Commit 8c2a250

Browse files
feat(api): update via SDK Studio (#7)
1 parent 4cbe77d commit 8c2a250

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,39 @@ On timeout, an `APIConnectionTimeoutError` is thrown.
135135

136136
Note that requests which time out will be [retried twice by default](#retries).
137137

138+
## Auto-pagination
139+
140+
List methods in the Zeroentropy API are paginated.
141+
You can use the `for await … of` syntax to iterate through items across all pages:
142+
143+
```ts
144+
async function fetchAllDocuments(params) {
145+
const allDocuments = [];
146+
// Automatically fetches more pages as needed.
147+
for await (const documentGetInfoListResponse of client.documents.getInfoList({
148+
collection_name: 'collection_name',
149+
})) {
150+
allDocuments.push(documentGetInfoListResponse);
151+
}
152+
return allDocuments;
153+
}
154+
```
155+
156+
Alternatively, you can request a single page at a time:
157+
158+
```ts
159+
let page = await client.documents.getInfoList({ collection_name: 'collection_name' });
160+
for (const documentGetInfoListResponse of page.documents) {
161+
console.log(documentGetInfoListResponse);
162+
}
163+
164+
// Convenience methods are provided for manually paginating:
165+
while (page.hasNextPage()) {
166+
page = await page.getNextPage();
167+
// ...
168+
}
169+
```
170+
138171
## Advanced Usage
139172

140173
### Accessing raw Response data (e.g., headers)

0 commit comments

Comments
 (0)