Skip to content

Commit e44db6b

Browse files
docs: update pagination usage in README.md (#855)
* chore: update README.md * chore: fix page_size snakecase --------- Co-authored-by: Shubham <[email protected]>
1 parent a2b5324 commit e44db6b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ The library automatically handles paging for you. Collections, such as `calls` a
193193

194194
`list` eagerly fetches all records and returns them as a list, whereas `stream` returns an iterator and lazily retrieves pages of records as you iterate over the collection. You can also page manually using the `page` method.
195195

196+
`page_size` as a parameter is used to tell how many records should we get in every page and `limit` parameter is used to limit the max number of records we want to fetch.
197+
196198
#### Use the `list` method
197199

198200
```python
@@ -206,6 +208,21 @@ for sms in client.messages.list():
206208
print(sms.to)
207209
```
208210

211+
```python
212+
client.messages.list(limit=20, page_size=20)
213+
```
214+
This will make 1 call that will fetch 20 records from backend service.
215+
216+
```python
217+
client.messages.list(limit=20, page_size=10)
218+
```
219+
This will make 2 calls that will fetch 10 records each from backend service.
220+
221+
```python
222+
client.messages.list(limit=20, page_size=100)
223+
```
224+
This will make 1 call which will fetch 100 records but user will get only 20 records.
225+
209226
### Asynchronous API Requests
210227

211228
By default, the Twilio Client will make synchronous requests to the Twilio API. To allow for asynchronous, non-blocking requests, we've included an optional asynchronous HTTP client. When used with the Client and the accompanying `*_async` methods, requests made to the Twilio API will be performed asynchronously.

0 commit comments

Comments
 (0)