API Documentation¶
External IP¶
-
GET/api/v1/cryptobook/ip¶ Returns the IP address of the server (for checking/testing purposes).
Example request:
GET /api/v1/cryptobook/ip HTTP/1.1
Example response:
HTTP/1.1 200 OK Connection: keep-alive Content-Length: 21 Content-Type: application/json Keep-Alive: 5 { "ip": "31.23.52.17" }
Exchange Information¶
-
GET/api/v1/cryptobook/exchange/(string: exchange_name)¶ Returns relevant information about the given market to be able to scrape historical data.
Example request:
GET /api/v1/cryptobook/exchange/binance HTTP/1.1
Example response:
HTTP/1.1 200 OK Connection: keep-alive Content-Length: 6400 Content-Type: application/json Keep-Alive: 5 { "exchange": "binance", "historical": true, "symbols": [ "ADA/BNB", "...", "ZRX/USDT" ], "timeframes": { "12h": "12h", "...", "8h": "8h" } }
Status Codes: - 200 OK – No error.
- 404 Not Found – Resource not found.
Historical Data¶
-
POST/api/v1/cryptobook/historical¶ Returns historical exchange data from given params.
Example request:
POST /api/v1/cryptobook/historical HTTP/1.1 Accept: application/json { "exchange": "binance", "symbol": "ETH/BTC", "timeframe": "1m", "start": "2018-01-01 00:00:00", "end": "2018-01-01 00:05:00" }
Example response:
HTTP/1.1 200 OK Connection: keep-alive Content-Length: 543 Content-Type: application/json Keep-Alive: 5 { "Close": { "0": 0.05352, "...", "5": 0.053588 }, "High": { "0": 0.053613, "...", "5": 0.053654 }, "Low": { "0": 0.053496, "...", "5": 0.053567 }, "Open": { "0": 0.053586, "...", "5": 0.053573 }, "Time": { "0": 1514764800000, "...", "5": 1514765100000 }, "Volume": { "0": 162.312, "...", "5": 194.333 } }
JSON Parameters: - exchange (string) – The name of the exchange.
- symbol (string) – The exchange symbol one desires.
- timeframe (string) – Timeframe of the data.
- start (string) – Beginning date and time of the data.
- end (string) – Ending date and time of the data.
- cfbypass (bool) – (optional) Flag to indicate whether or not to bypass CloudFlare checking (read more below).
Status Codes: - 200 OK – No error.
- 404 Not Found – Resource not found.
Note on cfbypass Flag
To bypass CloudFlare this library is using the open source cfscrape library, which unfortunately does not support asynchronous requests with aiohttp. Therefore, if enabled, the scraper will not run with asynchronous capability.
Parsing data:
Once you have received the data, the data is ready to be made back into a Pandas DataFrame.
df = pd.read_json(resp, orient='split')