File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,39 @@ On timeout, an `APIConnectionTimeoutError` is thrown.
135135
136136Note 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)
You can’t perform that action at this time.
0 commit comments