cryptocurrency-arbitrage icon indicating copy to clipboard operation
cryptocurrency-arbitrage copied to clipboard

Problems with getting data from Poloniex

Open WW-build opened this issue 6 years ago • 3 comments

Hi, after starting parser it can't get data from Poloniex:

Error getting JSON response from https://poloniex.com/public?command=returnTicker SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse () at Request._callback (/opt/arbitrage/main.js:41:33) at Request.self.callback (/opt/arbitrage/node_modules/request/request.js:186:22) at Request.emit (events.js:159:13) at Request. (/opt/arbitrage/node_modules/request/request.js:1163:10) at Request.emit (events.js:159:13) at IncomingMessage. (/opt/arbitrage/node_modules/request/request.js:1085:12) at Object.onceWrapper (events.js:254:19) at IncomingMessage.emit (events.js:164:20) at endReadableNT (_stream_readable.js:1054:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9)

Getting data from other markets working fine.

WW-build avatar Jan 07 '18 19:01 WW-build

I usually get this error when an exchange's API is down or offline. If it is operational then poloniex probably has a new endpoint.

manu354 avatar Jan 08 '18 00:01 manu354

I have the same issue. It seems Poloniex has a security check (One More Step) which returns a HTML instead a string in JSON format.

gabrieldilly avatar Jan 10 '18 15:01 gabrieldilly

{
    marketName: 'poloniex',
    URL: 'https://poloniex.com/public?command=returnTicker',
    toBTCURL: false,
    pairURL : '',
    last: function (data, coin_prices) { //Where to find the last price of coin in JSON data
        return new Promise(function (res, rej) {
            try {
                for (var obj in data) {
                    if(obj.includes('BTC_')&&obj!=="BTC_EMC2") {
                        let coinName = obj.replace("BTC_", '');
                        if (!coin_prices[coinName]) coin_prices[coinName] = {};
                        coin_prices[coinName].poloniex = data[obj].last;
                    }
                }
                res(coin_prices);
            }
            catch (err) {
                console.log(err);
                rej(err);
            }

        })
    },

},

alexmdcampo avatar Jun 13 '22 16:06 alexmdcampo