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 @@ -137,6 +137,39 @@ On timeout, an `APIConnectionTimeoutError` is thrown.
137137
138138Note 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 =  [];
148+   //  Automatically fetches more pages as needed.
149+   for  await  (const 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 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)  
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments