Skip to main content

Python client for the CoinGlass API v4

Project description

coinglass

Python client for the CoinGlass API v4. Typed access to futures and spot market data — OHLCV, open interest, funding rates, CVD, liquidations, orderbook depth, positioning, whale activity, and technical indicators.

Features

  • 40 API methods across 13 categories (price, OI, funding, volume, liquidations, orderbook, positioning, whale/smart money, indicators, snapshots, options, global/macro)
  • 25 typed models — immutable Pydantic objects with computed properties
  • 39 local indicators — 8 primitives, 13 Tier 1, 14 Tier 2, 5 crypto-specific composites (no external TA libraries)
  • Built-in rate limiting — 80 req/min with 0.75s delay, automatic sleep
  • Type-safe enums for intervals, time ranges, units, and plan validation

Install

pip install coinglass-terminal-tools

Requires Python 3.10+. The import name is coinglass:

from coinglass import CoinGlass

Quick Start

from coinglass import CoinGlass

with CoinGlass() as cg:  # reads COINGLASS_API_KEY env var
    candles = cg.get_ohlcv("BTCUSDT", "4h", limit=100)
    for c in candles[-3:]:
        print(f"Close: ${c.close:,.2f}  Volume: ${c.volume:,.0f}")

Async Usage

import asyncio
from coinglass import AsyncCoinGlass

async def main():
    async with AsyncCoinGlass() as cg:  # reads COINGLASS_API_KEY env var
        candles = await cg.get_ohlcv("BTCUSDT", "4h", limit=100)
        for c in candles[-3:]:
            print(f"Close: ${c.close:,.2f}  Volume: ${c.volume:,.0f}")

asyncio.run(main())

Same 40 methods as the sync client, just await-able. Supports async with or manual await cg.aclose().

What's Available

Category Methods Example
Discovery 5 get_supported_coins()
Price 2 get_ohlcv("BTCUSDT", "4h")
Open Interest 2 get_open_interest_aggregated("BTC", "4h")
Funding Rates 4 get_funding_rate_by_exchange("BTC")
Volume & CVD 5 get_cvd("BTC", "4h")
Liquidations 3 get_liquidations_aggregated("BTC", "1h")
Orderbook 3 get_orderbook_aggregated("BTC", "4h")
Positioning 3 get_global_long_short_ratio("BTCUSDT", "4h")
Whale / Smart Money 2 get_whale_index("BTCUSDT", "4h")
Technical Indicators 5 get_rsi("BTCUSDT", "4h")
Snapshots 1 get_pairs_markets("BTC")
Options 2 get_options_info("BTC")
Global / Macro 3 get_coinbase_premium("4h")

Funding rates are returned as percentages: 0.01 means 0.01%, not 1%.

Indicators

The coinglass.indicators subpackage provides 39 technical indicators built on the library's models — no external TA libraries needed. Tier 1/2 operate on list[OHLCVCandle]. Tier 3 composites combine CoinGlass-unique data (funding, liquidations, whale index, L/S ratios) for crypto-specific analysis.

from coinglass import CoinGlass
from coinglass.indicators import calculate_supertrend

with CoinGlass() as cg:
    candles = cg.get_ohlcv("BTCUSDT", "4h", limit=200)
    st = calculate_supertrend(candles)
    print(f"Supertrend: {st[-1].value:.2f}, direction: {'UP' if st[-1].direction == 1 else 'DOWN'}")

See docs/indicators.md for full details on all 39 indicators.

Examples

Script Description
quickstart.py Basic usage of the client
funding_scanner.py Scan for extreme funding rates across all coins
atr_stops.py Calculate ATR, stop distances, and position sizes
cvd_divergence.py Detect CVD-price divergences
oi_regime.py Classify OI + price regime and detect OI divergences
liquidation_monitor.py Track liquidation spikes and exchange breakdown
orderbook_imbalance.py Orderbook depth analysis at multiple ranges
multi_timeframe.py Compare RSI and OI across 1h/4h/1d timeframes

Each example is fully self-contained — copy any script to your project and it just works.

export COINGLASS_API_KEY="your-key"
python examples/quickstart.py

Documentation

Document Description
Getting Started Installation, authentication, symbols, intervals, common parameters
API Reference All 40 methods with signatures, parameters, and return types
Models All 25 models with field tables and computed properties
Indicators All 39 indicators with formulas, parameters, and outputs
Rate Limits Rate limiting guide with code examples
Error Handling Exception hierarchy, retry patterns, common errors
Changelog Version history

Development

pip install -e ".[dev]"
pytest tests/ -v
ruff check src/

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

coinglass_terminal_tools-0.2.0.tar.gz (167.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coinglass_terminal_tools-0.2.0-py3-none-any.whl (50.4 kB view details)

Uploaded Python 3

File details

Details for the file coinglass_terminal_tools-0.2.0.tar.gz.

File metadata

  • Download URL: coinglass_terminal_tools-0.2.0.tar.gz
  • Upload date:
  • Size: 167.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for coinglass_terminal_tools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 fc7a7b7119a649287b19da8485ae4645d3606a93ea9a154ffacf574797a4c546
MD5 f750710a31bc8a74262f5b4085ed68a5
BLAKE2b-256 b62f567b7848e2db391736a02371e1b4e1d42840ef544590a77867fc0244822a

See more details on using hashes here.

File details

Details for the file coinglass_terminal_tools-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for coinglass_terminal_tools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b7e35a8c7f604aff0ca5a1ab796f8c7579e2a107168ce3185cba98a147db73c
MD5 e8a35c1da38c6f7ae81c55b74287e556
BLAKE2b-256 7c50df8b82fa8c6687a64d7a9a409de9dde287f24370dd2b1b0d15b44b523a1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page