Skip to content

Commit eb8917a

Browse files
committed
Added note about pagination flag
1 parent ee015a0 commit eb8917a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,41 @@ for quote in quotes:
6262
print(quote)
6363
```
6464

65+
### Pagination Behavior
66+
67+
By default, the client paginates results for endpoints like `list_trades` and `list_quotes` behind the scenes for you. Understanding how pagination interacts with the `limit` parameter is key.
68+
69+
#### Default (Pagination Enabled)
70+
71+
Pagination is enabled by default (`pagination=True`):
72+
73+
* `limit` controls the page size, not the total number of results.
74+
* The client automatically fetches all pages, yielding results until none remain.
75+
76+
Here's an example:
77+
78+
```python
79+
client = RESTClient(api_key="<API_KEY>")
80+
trades = [t for t in client.list_trades(ticker="TSLA", limit=100)]
81+
```
82+
83+
This fetches all TSLA trades, 100 per page.
84+
85+
#### Disabling Pagination
86+
87+
To return a fixed number of results and stop, disable pagination:
88+
89+
```python
90+
client = RESTClient(api_key="<API_KEY>", pagination=False)
91+
trades = [t for t in client.list_trades(ticker="TSLA", limit=100)]
92+
```
93+
94+
This returns at most 100 total trades, no additional pages.
95+
96+
### Performance Tip
97+
98+
If you're fetching large datasets, always use the maximum supported limit for the API endpoint. This reduces the number of API calls and improves overall performance.
99+
65100
### Additional Filter Parameters
66101

67102
Many of the APIs in this client library support the use of additional filter parameters to refine your queries. Please refer to the specific API documentation for details on which filter parameters are supported for each endpoint. These filters can be applied using the following operators:

0 commit comments

Comments
 (0)