Skip to content

Commit 11eaeef

Browse files
feat(api): update via SDK Studio (#7)
1 parent 12f3090 commit 11eaeef

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
@@ -137,6 +137,39 @@ On timeout, an `APIConnectionTimeoutError` is thrown.
137137

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

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

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

0 commit comments

Comments
 (0)