1

Is there a possibility to get the original response from the exchange (e.g. Binance)?

Since CCXT offers the possibility to overrride API params, I thought it might be possible to get the original response as well.

Right now I'm overriding the CCXT module itself - maybe there is a better solution than that?

Joël Brigate
  • 237
  • 2
  • 13

1 Answers1

2

CCXT will store the most recent response in exchange.last_http_response (as a text string) and exchange.last_json_response (as a JSON-decoded object, if applicable). So, after executing a RESTful call, you can see the response in one or both of those properties:

import ccxt
from pprint import pprint
exchange = ccxt.binance()
ticker = exchange.fetch_ticker('BTC/USDT')
pprint(exchange.last_http_response)
pprint(exchange.last_json_response)

Apart from the above CCXT also serves the original structures returned from the exchange in the info field in all JSON objects returned from the Unified CCXT API.

Igor Kroitor
  • 1,548
  • 13
  • 16
  • I see now that `exchange.fetch_ticker` returns the original structure in the `info` field. However, `exchange.fetchOHLCV` doesn't have the info field. Can you give me a hint on how to get original data for streams, e.g. `watchOHLCV` as it returns a list? – Joël Brigate May 25 '21 at 15:43
  • @Josip you can do that with CCXT Pro like it is shown in this example: https://github.com/ccxt/ccxt/blob/master/examples/ccxt.pro/py/intercept-original-ohlcv-updates.py – Igor Kroitor May 26 '21 at 21:41