The Kingfisher
TwitterChatAnnouncements
  • Introduction
  • Getting Started
  • Pricing
  • Premium Tools
    • KF - Liquidations Maps
      • Trade exemple
      • KF- How to trade liquidation map
    • KF - Liquidations Heatmap
    • KF - Liq Ratios
    • KF - GEX+
    • KF - API
    • KF - OEMS Order Execution Management System
      • Disclaimer
      • Setup
      • dYdX Setup
      • Controls
        • Directionality
        • Sizing
        • Risk Management
      • Liquidation DCA order Type
      • Example strategies
      • tl;dr KF-OEMS F.A.Q.
    • KF - Bazar
      • Veiou templates
      • Skew Templates
      • V-Chart
      • BetaPlay
    • KF Index
  • Free Tools
    • Introduction
    • Liquidation calculator
    • Long vs Short
    • Aggregated Orderbook
    • Candle exhaustion indicator & CVD
  • Tips & Tricks
    • Trading with The Kingfisher
    • Insilico terminal
    • KF - ICHI PMS
      • Ichibot PMS
      • Ichibot Setup
  • Help
    • Referral program
    • My invoices
    • FAQ
    • Subscription
    • I need more help
    • Terms & Conditions
    • Links
Powered by GitBook
On this page
  • Apply for API access
  • API Usage

Was this helpful?

  1. Premium Tools

KF - API

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

PreviousKF - GEX+NextKF - OEMS Order Execution Management System

Last updated 2 months ago

Was this helpful?

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')

To improve data readability, we recommend flattening the liqmap. The response contains multiple clusters, including noise, which helps with color representation in UX design. However, for GMM, KDE, or statistical analysis, this can be inconvenient and make data manipulation more difficult.

 import pandas as pd
 
 def process_data(self, data):
            flattened_data = []
            for key in data:
                prices, density = data[key]
                flattened_data.extend([{'price': p, 'density': d} for p, d in zip(prices, density) if d != 0])
            return pd.DataFrame(flattened_data)