Why is Poloniex API blocked by CAPTCHA? Expected J

2019-04-14 06:01发布

I am using the following code to look up json from the poloniex API. It is returning HTML instead of JSON. What am I doing wrong? I would like JSON.

import requests
res = requests.get("https://poloniex.com/public?command=returnTradeHistory&currencyPair=BTC_NXT&start=1410158341&end=1410499372")
print(res.text)

2条回答
该账号已被封号
2楼-- · 2019-04-14 06:51

Thanks to a comment of user Mehul, I solved the same problem, but using PHP. I was trying for 2 hours to make a simple curl() to retrieve the public api using this simple call:

https://poloniex.com/public?command=returnTicker

The problem for me was that I was trying to do the call from my local server (at home). So thanks to Mehul, I decided to test to upload the script to my server and voilà: it immediately ran as expected, returning the json array.

My server is in the USA, although I'm in Mexico. Maybe there will be a problem of IPs and geolocalizations. Or a problem "home" vs. "server" connection. I don't know, but I hope that my approach was useful to other people. I really had problems to find some help with this issue. Ep, and I've implemented some API integrations with other exchanges!

查看更多
Bombasti
3楼-- · 2019-04-14 06:53

To summarize the comment chain, you are almost certainly doing something that the server doesn't like which causes it to ask you for a CAPTCHA.

One of the commenters pointed out the documented limit of "6 calls per second to the public API, or repeatedly and needlessly fetching excessive amounts of data". We can only guess at what "repeatedly" or "needlessly" mean to the service, but I think you've made it at least suspicious because it is asking (via CAPTCHA) "are you a person or a program?".

If you want to know what the service's actual limits are, contact the firm. You might have to pay to get the data you are looking for.

查看更多
登录 后发表回答