Search code examples
pythonapibinanceccxt

Can I get original exchange response from CCXT API call?


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?


Solution

  • 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.