Skip to main content

Glassnode API client that mimics the yfinance download experience.

Project description

glassnode-python

Glassnode API toolkit with a yfinance-style interface.

Chinese version


✨ Feature Highlights

Capability Details
yfinance-style download() Mirrors yfinance.download semantics including period, interval, metrics, threads, group_by, and progress hooks.
Multi-metric alias registry Built-in alias table for price, OHLC, marketcap, and other endpoints, plus support for custom endpoint dictionaries.
Request resilience Injects API keys automatically, supports proxy-aware requests.Session, and retries with exponential backoff on 429/50x responses.
Pandas-native output DateTime index + MultiIndex columns flow directly into NumPy, pandas, polars, or backtesting engines.
Visualization ready Bundled Plotly script launches a TradingView-style ETH/SOL dashboard with one command.

📦 Installation

pip install glassnode-python           # install from PyPI (v0.3.0+)
pip install -e .[test]                 # developer setup
pip install -e .[viz]                  # Plotly dashboard extras

If you prefer a local checkout, run pip install . from the repo root.


⚡ Quickstart (30 seconds)

from glassnode_python import download
from dotenv import load_dotenv
import os

load_dotenv()
api_key = os.environ["GLASSNODE_API_KEY"]

btc = download("BTC", period="3mo", metrics=["price"], api_key=api_key)
print(btc.tail())

The helper returns a pandas dataframe with a DateTime index and a column MultiIndex of (Attribute, Ticker) by default.


🧰 Essential Recipes

Multi-asset OHLC (yfinance style)

rich = download(
	["BTC", "ETH", "SOL"],
	period="1y",
	interval="24h",
	metrics=["ohlc"],
	group_by="ticker",   # switch to (Ticker, Attribute)
	threads=True,
	api_key=api_key,
)

Mix & match metrics

matrix = download(
	"BTC",
	metrics=["price", "marketcap", "mvrv"],
	period="6mo",
	rounding=2,
	dropna=True,
	api_key=api_key,
)

Custom endpoint mapping

download(
	"ETH",
	metrics={
		"sopr": {"endpoint": "/v1/metrics/market/sopr"},
		"ohlc": {"endpoint": "/v1/metrics/market/price_usd_ohlc", "multi": True},
		"fees": {
			"endpoint": "/v1/metrics/transactions/transfers_volume_sum",
			"column": "TransferVolume",
		},
	},
	api_key=api_key,
)

Full-control client

from glassnode_python import GlassnodeClient
import requests

session = requests.Session()
session.headers.update({"User-Agent": "glassnode-python/0.2"})

client = GlassnodeClient(
	api_key=api_key,
	session=session,
	proxies={"https": "http://127.0.0.1:7890"},
	max_retries=5,
	retry_backoff=1.5,
)

df = client.download(
	["BTC", "SOL"],
	start="2025-01-01",
	end="2025-12-31",
	metrics=["price", "volume"],
	progress=False,
)

📊 Metric Alias Catalog

Alias Endpoint Columns
ohlc /v1/metrics/market/price_usd_ohlc Open, High, Low, Close
price /v1/metrics/market/price_usd_close Price
marketcap /v1/metrics/market/marketcap_usd Marketcap
volume /v1/metrics/market/spot_volume_daily_sum Volume
mvrv /v1/metrics/market/mvrv Mvrv
realizedcap /v1/metrics/market/realizedcap_usd RealizedCap

Aliases respect group_by, rounding, and fill methods so the dataframe layout stays predictable.


📺 TradingView-like Dashboard

pip install -e .[viz]
python scripts/eth_sol_tradingview.py
  • Fetches one year of daily OHLC candles for ETH and SOL (sequential mode to stay within rate limits).
  • Adds EMA20/EMA50 overlays plus Plotly dark theme, linked hover, and full zoom/pan controls.
  • Customize via the EMA_WINDOWS constant or export HTML with fig.write_html().

🔐 API Keys & Environment

echo "GLASSNODE_API_KEY=your-secret" >> .env
  • If api_key is omitted, the module lazily loads .env on first use.
  • Pass api_key= for one-off calls or client= to reuse a configured GlassnodeClient.

🧪 Testing & Release Flow

pip install -e .[test]
pytest

python -m build
twine upload dist/*

Update __version__ inside src/glassnode_python/__init__.py and the project.version in pyproject.toml before cutting a release.


📄 License

GNU GPLv3 — see LICENSE.

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

glassnode_python-0.3.1.tar.gz (51.7 kB view details)

Uploaded Source

Built Distribution

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

glassnode_python-0.3.1-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file glassnode_python-0.3.1.tar.gz.

File metadata

  • Download URL: glassnode_python-0.3.1.tar.gz
  • Upload date:
  • Size: 51.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for glassnode_python-0.3.1.tar.gz
Algorithm Hash digest
SHA256 6aa98472628f1404c766887b36fd861946f688d32e2f10d93c4001d8277f4e21
MD5 c470d612b61784babcd21597695cad69
BLAKE2b-256 4bb6d3398d90aaccc651f7a11617c1540635f8b4d3c28edc33f01e8e03b6fa07

See more details on using hashes here.

File details

Details for the file glassnode_python-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for glassnode_python-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 470b04e464bbf67e4e5e7e87c53a9e894237421d2c6278ae7ba5e5e2b25eb13b
MD5 d2f8a9cd375c4698f5428f7ac1eed7be
BLAKE2b-256 e82f3f5c2decf8bae60dbf748c39df5369d1deb29a5913f08d92d760d495feb9

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