adsabs / adsabs-dev-api

Developer API service description and example client code
162 stars 58 forks source link

Can't get ratelimits #71

Closed shortorian closed 3 years ago

shortorian commented 3 years ago

I've been using the unofficial Python interface from Andy Casey for a bit. A few weeks ago I was able to use his code to get ratelimits on my API token but now I can't get them using the same code. I can query the database and get the data I want but the ratelimits are just empty strings. I don't really know what I'm doing, but I've tried to inspect HTTP response headers using the Python requests package and I can't find anything like X-RateLimit in API query responses.

I've done

import requests
r = requests.get("https://api.adsabs.harvard.edu/v1/search/query?q=q", headers={'Authorization': 'Bearer ' + token})

and the resulting r.headers data is

{'Date': 'Wed, 23 Dec 2020 23:23:36 GMT', 
'Content-Type': 'application/json', 
'Transfer-Encoding': 'chunked', 
'Connection': 'keep-alive', 
'Server': 'openresty/1.15.8.1', 
'Vary': 'Accept-Encoding, Origin', 
'Access-Control-Allow-Origin': 'http://0.0.0.0:8000, http://adsabs.harvard.edu, http://adsx.cfa.harvard.edu:8888, http://hourly.adslabs.org, http://localhost:8000, http://ui.adsabs.harvard.edu, http://ui.adslabs.org, https://arxiv.org, https://beta.arxiv.org, https://demo.adsabs.harvard.edu, https://dev.adsabs.harvard.edu, https://devui.adsabs.harvard.edu, https://experimental-bumblebee.us-east-1.elasticbeanstalk.com, https://prod.adsabs.harvard.edu, https://staging-bumblebee.elasticbeanstalk.com, https://staging-bumblebee.us-east-1.elasticbeanstalk.com, https://ui.adsabs.harvard.edu',
'Access-Control-Allow-Methods': 'DELETE, GET, OPTIONS, POST, PUT', 
'Access-Control-Allow-Headers': 'Accept, Authorization, Content-Type, Orcid-Authorization, X-BB-Api-Client-Version, X-CSRFToken', 
'Access-Control-Allow-Credentials': 'true',
'Set-Cookie': 'session=.eJyrVopPK0otzlCyKikqTdVRis9MUbKqVlJIUrJSiqyKyvR198rwdw819g_3rPQNjzT2Mwo0jMpyy_B3CTWJCvfLjsoKNIoK8bRVqgXqLUgtyk3MS80rgZlWWpxaBDZRycjYzMxUqRYAxUsjOQ.X-PReA.3RHeqO_ym_NSaYhW0t0uh1yunDw; Expires=Fri, 24-Dec-2021 05:23:36 GMT; HttpOnly; Path=/',
'Content-Encoding': 'gzip'}

How should I get my ratelimits in Python?

shortorian commented 3 years ago

I figured out how to use curl and opened a new issue that's more specific