Skip to content
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

Add example on paging #27

Merged
merged 1 commit into from
Aug 29, 2023
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
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