pybliometrics-dev / pybliometrics

Python-based API-Wrapper to access Scopus
https://pybliometrics.readthedocs.io/en/stable/
Other
422 stars 129 forks source link

Possibility to use api key without config file #101

Closed Blake11 closed 5 years ago

Blake11 commented 5 years ago

Would it be possible to change the way api keys are used? It would be beneficial for threaded application where api keys change based on a criteria in different threads. Also this would reduce the number or disk reads/writes in some scenarios

Expected usage:

key = "foo"
author = AuthorRetrieval(author_id, refresh=True, api_key=key)
Michael-E-Rose commented 5 years ago

This can be achieved like so:

from scopus import config, AuthorRetrieval
from scopus.exception import Scopus429Error

try:
    author = AuthorRetrieval(author_id, refresh=True)
exept Scopus429Error:
    config["Authentication"]["APIKey"] = "foo"
    author = AuthorRetrieval(author_id, refresh=True)

This will set the API key to be used w/o changing the configuration file.

Blake11 commented 5 years ago

That is exactly what I was looking for. It should be included in documentation https://scopus.readthedocs.io/en/stable/configuration.html

Michael-E-Rose commented 5 years ago

https://pybliometrics.readthedocs.io/en/stable/tips.html#download-machine