Scopus API - Number of requests remaining for the week
Asked Answered
C

1

9

I am using the Elsevier API to access citation count data from Scopus, through the scopus-api module (but would be happy to use Elsevier's elsapy module). I can access the data I need, but there is a limit for the number of requests that can be made per week.

How would one obtain the number of remaining requests for the week?

All help is appreciated.

Cru answered 30/4, 2018 at 11:46 Comment(0)
M
8

Although an old question, the answer might help someone else who stumbles across it. The quota related information is contained in the headers of the response to your request. Each API endpoint seems to have its own limit.

Here's an example of a response that still has something left of the quota:

{'allow': 'GET', 'Content-Encoding': 'gzip', 'Content-Type': 'application/xml;charset=UTF-8', 'Date': 'Fri, 26 Aug 2019 17:46:46 GMT', 'Server': 'Apache-Coyote/1.1', 'vary': 'Origin', 'X-ELS-APIKey': 'your-api-key-would-be-here', 'X-ELS-ReqId': '16385g19-b193-1308-5817-c5694db5619g', 'X-ELS-ResourceVersion': 'default', 'X-ELS-Status': 'OK', 'X-ELS-TransId': '16385g19-b193-1308-5817-c5694db5619g', 'X-RateLimit-Limit': '20000', 'X-RateLimit-Remaining': '19636', 'X-RateLimit-Reset': '2019-10-03 07:18:17', 'transfer-encoding': 'chunked', 'Connection': 'keep-alive'}

Here's an example for which the quota has been exceeded:

{'Content-Encoding': 'gzip', 'Content-Type': 'text/xml;charset=UTF-8', 'Date': 'Fri, 19 Aug 2019 17:46:46 GMT', 'Server': 'Apache-Coyote/1.1', 'X-ELS-Status': 'QUOTA_EXCEEDED - Quota Exceeded', 'X-RateLimit-Reset': '2019-08-26 05:51:01', 'Content-Length': '191', 'Connection': 'keep-alive'}

An example to get the headers in python using requests:

url = https://api.elsevier.com/content/abstract/scopus_id/85040730407?apiKey=yourapikey
response = requests.get(url)
print(response.headers)
Marcelinomarcell answered 27/9, 2019 at 18:9 Comment(1)
Just FYI, the "X-RateLimit-Reset" is now Unix Timestamp format in ms so you'll have to divide by 1000 to get seconds and then convert.Bihar

© 2022 - 2024 — McMap. All rights reserved.