Skip to content

Commit

Permalink
Add example on paging
Browse files Browse the repository at this point in the history
  • Loading branch information
J535D165 committed Aug 8, 2023
1 parent 9955512 commit a14e347
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ advised to use the built-in pager based on cursor paging.

##### Cursor paging

Use `paginate()` for paging results. By default, `paginate`s argument `n_max`
Use `paginate()` for paging results. Each page is a list of records, with a
maximum of `per_page` (default 25). By default, `paginate`s argument `n_max`
is set to 10000. Use `None` to retrieve all results.

```python
Expand All @@ -283,6 +284,19 @@ for page in pager:
print(len(page))
```

> Looking for an easy method to iterate the records of a pager?
```python
from itertools import chain
from pyalex import Authors

query = Authors().search_filter(display_name="einstein")

for record in chain(*query.paginate(per_page=200)):
print(record["id"])
```


### Get N-grams

OpenAlex reference: [Get N-grams](https://docs.openalex.org/api-entities/works/get-n-grams).
Expand Down

0 comments on commit a14e347

Please sign in to comment.