Skip to content

Commit 23f4d07

Browse files
committed
Add option to use email to get polite access
Openalex and crossref APIs provide polite access if email address is used along with API call https://docs.openalex.org/how-to-use-the-api/rate-limits-and-authentication
1 parent 3fdf0a9 commit 23f4d07

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

asreviewcontrib/preprocess/update_data/base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def parse_metadata(retrieved_metadata):
4545

4646
raise NotImplementedError
4747

48+
def _use_email(email):
49+
"""Use email to get polite access to updater API"""
50+
4851

4952
class BaseDOIUpdater(ABC):
5053
"""Abstract class for doi updater finding missing dois"""
@@ -56,3 +59,6 @@ def retrieve_dois(input_data):
5659
"""Retrieve missing dois"""
5760

5861
raise NotImplementedError
62+
63+
def _use_email(email):
64+
"""Use email to get privileged access to updater API"""

asreviewcontrib/preprocess/update_data/crossref_doi_updater.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
class CrossrefDOIUpdater(BaseDOIUpdater):
1414
def __init__(self):
1515
super(CrossrefDOIUpdater, self).__init__()
16+
self.email = None
17+
18+
def _use_email(self, email):
19+
self.email = email
20+
# TODO: Make use of email in crossref API call
1621

1722
def retrieve_dois(self, records_df: pd.DataFrame) -> pd.DataFrame:
1823
"""Requests Crossref with title-year combination and returns DOI if

asreviewcontrib/preprocess/update_data/openalex_updater.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pandas as pd
2+
import pyalex
23
from asreviewcontrib.preprocess.config import OPENALEX_QUERY_LIMIT
34
from asreviewcontrib.preprocess.update_data.base import BaseUpdater
45
from pyalex import Works
@@ -14,6 +15,11 @@ class OpenAlexUpdater(BaseUpdater):
1415
def __init__(self):
1516
super(OpenAlexUpdater, self).__init__()
1617
self.db = None
18+
self.email = None
19+
20+
def _use_email(self, email):
21+
self.email = email
22+
pyalex.config.email = email
1723

1824
def retrieve_metadata(self, db, doi_list):
1925
"""Retrive metadata for the records using doi
@@ -97,6 +103,3 @@ def parse_metadata(self, retrieved_metadata):
97103
parsed_data.append(metadata)
98104
parsed_data_df = pd.DataFrame(parsed_data)
99105
return parsed_data_df
100-
101-
102-
# TODO: Check if Lens.org api or database can be used freely

0 commit comments

Comments
 (0)