CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-kucoin-python

A Python SDK for KuCoin cryptocurrency exchange API providing REST endpoints implementation, simple authentication handling, response exception handling, and websocket support for trading, market data, user account management, margin trading, lending, and earning features

Pending
Overview
Eval results
Files

market-data.mddocs/

Market Data

Access to comprehensive KuCoin market information including trading symbols, price tickers, order books, trade history, candlestick data, and currency details. All market data endpoints are public and do not require authentication.

Capabilities

Symbol Information

Retrieve information about available trading pairs and markets.

def get_symbol_list(**kwargs):
    """
    Get list of trading symbols.
    
    Args:
        market (str, optional): Filter by market (e.g., 'BTC', 'USDT')
    
    Returns:
        list: List of symbol objects with trading information
    """

def get_symbol_list_v2(**kwargs):
    """
    Get enhanced list of trading symbols (v2).
    
    Args:
        market (str, optional): Filter by market
    
    Returns:
        list: Enhanced symbol information with additional metadata
    """

def get_symbol_detail(symbol: str):
    """
    Get detailed information for a specific trading symbol.
    
    Args:
        symbol (str): Trading symbol (e.g., 'BTC-USDT')
    
    Returns:
        dict: Detailed symbol configuration and limits
    """

def get_market_list():
    """
    Get list of available markets.
    
    Returns:
        list: Available market names
    """

Price Tickers

Current and 24-hour price information for trading pairs.

def get_ticker(symbol: str):
    """
    Get ticker information for a specific symbol.
    
    Args:
        symbol (str): Trading symbol (e.g., 'BTC-USDT')
    
    Returns:
        dict: Current price, best bid/ask, and timestamp
    """

def get_all_tickers():
    """
    Get ticker information for all symbols.
    
    Returns:
        dict: Timestamp and list of all tickers
    """

def get_24h_stats(symbol: str):
    """
    Get 24-hour trading statistics for a symbol.
    
    Args:
        symbol (str): Trading symbol
    
    Returns:
        dict: 24h high/low, volume, change, and average price
    """

Order Book Data

Market depth and order book information.

def get_part_order(pieces: int, symbol: str):
    """
    Get partial order book with specified depth.
    
    Args:
        pieces (int): Number of order book levels (20, 100)
        symbol (str): Trading symbol
    
    Returns:
        dict: Partial order book with bids and asks
    """

def get_aggregated_orderv3(symbol: str):
    """
    Get full aggregated order book (v3).
    
    Args:
        symbol (str): Trading symbol
    
    Returns:
        dict: Complete aggregated order book
    """

def get_atomic_orderv3(symbol: str):
    """
    Get full atomic order book with order IDs (v3).
    
    Args:
        symbol (str): Trading symbol
    
    Returns:
        dict: Complete atomic order book with individual orders
    """

def get_atomic_order(symbol: str):
    """
    Get full atomic order book with order IDs (v1).
    
    Args:
        symbol (str): Trading symbol
    
    Returns:
        dict: Complete atomic order book with individual orders
    """

Trade History

Historical trade data for symbols.

def get_trade_histories(symbol: str):
    """
    Get recent trade history for a symbol.
    
    Args:
        symbol (str): Trading symbol
    
    Returns:
        list: Recent trades with price, size, side, and timestamp
    """

Candlestick Data

OHLCV candlestick data for technical analysis.

def get_kline(symbol: str, kline_type: str, **kwargs):
    """
    Get candlestick data for a symbol.
    
    Args:
        symbol (str): Trading symbol
        kline_type (str): Candle interval ('1min', '3min', '5min', '15min', '30min', '1hour', '2hour', '4hour', '6hour', '8hour', '12hour', '1day', '1week')
        startAt (int, optional): Start time timestamp
        endAt (int, optional): End time timestamp
        currentPage (int, optional): Page number
        pageSize (int, optional): Page size
    
    Returns:
        list: OHLCV candlestick data
    """

Currency Information

Information about supported cryptocurrencies.

def get_currencies():
    """
    Get list of supported currencies.
    
    Returns:
        list: Currency information with precision and limits
    """

def get_currency_detail_v2(currency: str, chain: str = None):
    """
    Get detailed currency information (v2).
    
    Args:
        currency (str): Currency code (e.g., 'BTC')
        chain (str, optional): Blockchain network
    
    Returns:
        dict: Currency details with chain information
    """

def get_currency_detail_v3(currency: str, chain: str = None):
    """
    Get detailed currency information (v3).
    
    Args:
        currency (str): Currency code
        chain (str, optional): Blockchain network
    
    Returns:
        dict: Enhanced currency details
    """

Fiat Pricing

Fiat currency conversion rates.

def get_fiat_price(**kwargs):
    """
    Get fiat conversion prices for cryptocurrencies.
    
    Args:
        base (str, optional): Base fiat currency
        currencies (str, optional): Comma-separated cryptocurrency codes
    
    Returns:
        dict: Fiat prices for specified cryptocurrencies
    """

Server Information

KuCoin server status and timing information.

def get_server_timestamp():
    """
    Get current server timestamp.
    
    Returns:
        int: Current server timestamp in milliseconds
    """

def get_server_status():
    """
    Get server operational status.
    
    Returns:
        dict: Server status ('open', 'close', 'cancelonly') with message
    """

Usage Examples

Basic Market Data Query

from kucoin.client import Market

# Initialize market client (no auth required)
market = Market()

# Get all available symbols
symbols = market.get_symbol_list()
print(f"Found {len(symbols)} trading pairs")

# Get current ticker for BTC-USDT
ticker = market.get_ticker('BTC-USDT')
print(f"BTC-USDT Price: {ticker['price']}")

# Get 24h statistics
stats = market.get_24h_stats('BTC-USDT')
print(f"24h Volume: {stats['vol']}")
print(f"24h Change: {stats['changeRate']}")

Order Book Analysis

# Get partial order book
orderbook = market.get_part_order(20, 'BTC-USDT')
print(f"Best Bid: {orderbook['bids'][0]}")
print(f"Best Ask: {orderbook['asks'][0]}")

# Get recent trades
trades = market.get_trade_histories('BTC-USDT')
for trade in trades[:5]:
    print(f"Trade: {trade['price']} @ {trade['size']} ({trade['side']})")

Historical Data

# Get 1-hour candlestick data for the last 24 hours
import time
end_time = int(time.time())
start_time = end_time - (24 * 60 * 60)  # 24 hours ago

candles = market.get_kline('BTC-USDT', '1hour', startAt=start_time, endAt=end_time)
for candle in candles:
    timestamp, open_price, close_price, high, low, volume, turnover = candle
    print(f"Time: {timestamp}, Open: {open_price}, Close: {close_price}, Volume: {volume}")

Types

SymbolInfo = dict
# {
#   "symbol": str,           # Trading pair symbol
#   "name": str,             # Display name
#   "baseCurrency": str,     # Base currency
#   "quoteCurrency": str,    # Quote currency
#   "baseMinSize": str,      # Minimum base amount
#   "quoteMinSize": str,     # Minimum quote amount
#   "baseMaxSize": str,      # Maximum base amount
#   "quoteMaxSize": str,     # Maximum quote amount
#   "baseIncrement": str,    # Base precision
#   "quoteIncrement": str,   # Quote precision
#   "priceIncrement": str,   # Price precision
#   "enableTrading": bool,   # Trading enabled
#   "isMarginEnabled": bool, # Margin trading enabled
#   "priceLimitRate": str    # Price limit rate
# }

TickerInfo = dict
# {
#   "sequence": str,     # Sequence number
#   "bestAsk": str,      # Best ask price
#   "size": str,         # Size
#   "price": str,        # Last price
#   "bestBidSize": str,  # Best bid size
#   "bestBid": str,      # Best bid price
#   "bestAskSize": str,  # Best ask size
#   "time": int          # Timestamp
# }

OrderBookLevel = list  # [price: str, size: str]

OrderBook = dict
# {
#   "sequence": str,           # Sequence number
#   "time": int,               # Timestamp
#   "bids": list[OrderBookLevel], # Bid orders
#   "asks": list[OrderBookLevel]  # Ask orders
# }

TradeInfo = dict
# {
#   "sequence": str,  # Sequence number
#   "price": str,     # Trade price
#   "size": str,      # Trade size
#   "side": str,      # Trade side ('buy' or 'sell')
#   "time": int       # Trade timestamp
# }

CandleData = list  # [timestamp: str, open: str, close: str, high: str, low: str, volume: str, turnover: str]

Install with Tessl CLI

npx tessl i tessl/pypi-kucoin-python

docs

account-management.md

earn-products.md

index.md

lending.md

margin-trading.md

market-data.md

spot-trading.md

websocket.md

tile.json