KF - API

The Kingfisher API allows access to all of the Kingfisher's Liq Maps and GEX+

Apply for API access

To access the Kingfisher's API, you need to fill an application form. Upon reception, we'll get in touch with you.

On http://alpha.thekingfisher.io, click "Subscription" --> API Access --> Apply for API Access

Upon reception of the form, the Kingfisher team will get in touch with you.

Once your access becomes active, refer to the following section to effectively make use of the KF API.

API Usage

See below a crude API connector.

Note: Make sure to create a .env with

HOST='https://thekingfisher.io'
LOGIN="your_kf_login"
KEY="your_kf_password"
import requests
import os
import json
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())

# in .env
# HOST='https://thekingfisher.io'
# LOGIN="your_kf_login"
# KEY="your_kf_password"


class KingfisherController(object):

    def __init__(self):
        self.users = []
        self.token = ""
        self.headers = {}
        self.keys = []
        self.login()

    def login(self):
       login_response = requests.post(HOST + "/api/auth/login", data={"login": LOGIN, "password": KEY})
       if(login_response.status_code):
        self.token = (login_response.json()['token'])
        self.headers = {'Authorization': 'Bearer ' + self.token}
        
    def get_last_map(self, exchange, pair, type):
        data = {'exchange': exchange, 'pair': pair, 'type': type}
        return requests.post(HOST + '/api/private/map/latest',json=data, headers=self.headers).json()
    
    # Being reworked, coming back soon
    def get_ts_map(self, exchange, pair, ts, type):
        data = {'exchange': exchange, 'pair': pair, 'ts' : ts,'type': type}
        return requests.post(HOST + '/api/private/map/timestamp',json=data, headers=self.headers).json()
    
def plot_data (data):
    prices = []
    rel_str = []
    for cluster in data:
        if cluster not in ['Cummulated short liqs','Cummulated long liqs']:
            prices += data[cluster][0]
            rel_str += data[cluster][1]
            
    import plotly.express as px
    plot = px.histogram(x=prices, labels={'x': 'Price'}, y=rel_str, nbins = len(prices))
    plot.show()
    
if __name__ == '__main__':
    kf_control = KingfisherController()
    resp = kf_control.get_ts_map('binance', 'BTC/USDT', time.time(), 'all_leverage')
    data = resp['result']['data']
    plot_data(data)
    # plot histogram with plotly of data
    
    resp = kf_control.get_last_map('binance', 'BTC/USDT', 'high_leverage')

Last updated