[英]How to check how many calls left in AlchemyAPI? python
AlchemyAPI的免費用戶每天可以撥打1000個請求( http://www.alchemyapi.com/products/pricing/ )。
我一直在使用python訪問API:
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
我知道我的呼叫用完了,因為請求是響應返回無。
如何查看我通過python接口留下的調用次數?
支票會算作一個請求嗎?
您可以使用alchemy_calls_left(API_KEY)函數從這里
並且它不會被視為呼叫本身。
此URL將返回每日呼叫使用信息。
用您的密鑰替換API_KEY。
http://access.alchemyapi.com/calls/info/GetAPIKeyInfo?apikey=API_KEY&outputMode=json
您可以保留一個本地變量來跟蹤API調用的數量,並在日期模塊使用datetime.date更改日期時重置。
您也可以使用此Java API ,如下所示:
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);
最后一次調用將導致IOException(如果超過給定日期的允許調用),則消息將為“Error API調用:每日事務限制超出”。
然后你可以抓住它,等待24小時然后重新嘗試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.