3

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?

alvas
  • 115,346
  • 109
  • 446
  • 738

4 Answers4

4

You can use alchemy_calls_left(api_key) function from Here

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

Community
  • 1
  • 1
smohamed
  • 3,234
  • 4
  • 32
  • 57
3

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

Naffi
  • 710
  • 1
  • 6
  • 13
2

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.

user1822128
  • 107
  • 2
  • this logic will not work if the above user stops the program & starts it. the local variable will be reinitialised to zero. –  Nov 27 '14 at 03:27
0

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.

KLaz
  • 446
  • 3
  • 11