How to check how many calls left in AlchemyAPI? python

1.4k views Asked by At

The free user for AlchemyAPI can call 1000 requests a day (http://www.alchemyapi.com/products/pricing/).

I have been accessing the API with python as such:

from alchemyapi import AlchemyAPI
demo_text = 'Yesterday dumb Bob destroyed my fancy iPhone in beautiful Denver, Colorado. I guess I will have to head over to the Apple Store and buy a new one.'
response = alchemyapi.keywords('text', demo_text)
json_output = json.dumps(response, indent=4)
print json_output

I know I ran out of calls since the requests were response returning None.

How do I check how many calls I have left through the python interface?

Will the check count as one request?

4

There are 4 answers

0
smohamed On BEST ANSWER

You can use alchemy_calls_left(api_key) function from Here

and no it won't count as a call itself.

1
user1822128 On

You could keep a local variable that would keep track of the number of API calls and would reset when the date changes using datetime.date from date module.

0
KLaz On

You can also use this Java API as follows:

AlchemyAPI alchemyObj = AlchemyAPI.GetInstanceFromFile("/../AlchemyAPI/testdir/api_key.txt");
AlchemyAPI_NamedEntityParams params= new AlchemyAPI_NamedEntityParams();
params.setQuotations(true); // for instance, enable quotations
Document doc =  alchemyObj.HTMLGetRankedNamedEntities(htmlString, "http://news-site.com", params);

The last call will cause an IOException (if you exceed the allowed calls for a given day) and the message will be "Error making API call: daily-transaction-limit-exceeded."

You can then catch it, wait for 24 hours and re-try.

0
Naffi On

This URL will return you the daily call used info.

Replace the API_KEY with your key.

http://access.alchemyapi.com/calls/info/GetAPIKeyInfo?apikey=API_KEY&outputMode=json