Skip to content

docs: update pagination usage in README.md #855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ The library automatically handles paging for you. Collections, such as `calls` a

`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.

`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.

#### Use the `list` method

```python
Expand All @@ -206,6 +208,21 @@ for sms in client.messages.list():
print(sms.to)
```

```python
client.messages.list(limit=20, page_size=20)
```
This will make 1 call that will fetch 20 records from backend service.

```python
client.messages.list(limit=20, page_size=10)
```
This will make 2 calls that will fetch 10 records each from backend service.

```python
client.messages.list(limit=20, page_size=100)
```
This will make 1 call which will fetch 100 records but user will get only 20 records.

### Asynchronous API Requests

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.
Expand Down
Loading