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

Adds support for OpenAlex api_key request parameter #7

Merged
merged 5 commits into from
Mar 19, 2023

Conversation

phil-scholarcy
Copy link
Contributor

@phil-scholarcy phil-scholarcy commented Mar 14, 2023

OpenAlex provides an api_key query parameter that provides additional functionality and more frequent updates to commercial customers.

This PR adds api_key support to pyalex. Just set config.api_key to your API key value.

@J535D165
Copy link
Owner

J535D165 commented Mar 18, 2023

Nice, thanks for the PR! I have seen mentions of this feature on the discussion board, however, this is the first time I see how this is implemented. Is there a reference to some documentation already (will merge it anyways).

tests/test_pyalex.py Outdated Show resolved Hide resolved
@phil-scholarcy
Copy link
Contributor Author

phil-scholarcy commented Mar 18, 2023

Nice, thanks for the PR! I have seen mentions of this feature on the discussion board, however, this is the first time I how this is implemented. Is there a reference to some documentation already (will merge it anyways).

Ah great, thanks! I don't think there's any public documentation on it yet. I just received an API key the other day with instructions for using it.

pyalex/api.py Outdated Show resolved Hide resolved
@J535D165
Copy link
Owner

Interestingly, the checks in your PR raise TOO_MANY_REQUESTS errors while the others don't. For example, the number of tests is not bigger than the number of tests in PR #9.

FAILED tests/test_pyalex.py::test_W4238809453_works_abstract - requests.exceptions.HTTPError: 429 Client Error: TOO MANY REQUESTS for url: https://api.openalex.org/works/W4238809453?api_key=my_api_key
FAILED tests/test_pyalex.py::test_random_works - requests.exceptions.HTTPError: 429 Client Error: TOO MANY REQUESTS for url: https://api.openalex.org/works/random?api_key=my_api_key

I wonder whether this is the result of adding the API key.

@J535D165 J535D165 merged commit 78b83bd into J535D165:main Mar 19, 2023
@J535D165
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants