Skip to main content

glassnode-python

Glassnode API client with a yfinance-style download() helper.

中文文档


✨ Feature Highlights

Capability Details
yfinance-like ergonomics Single download() entry point covering period, interval, metrics, group_by, threads, progress, and more.
Metric alias registry Built-in aliases for price, ohlc, marketcap, etc., plus the ability to mix in custom endpoint mappings.
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.2+)
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": None,  # reuse built-in alias, columns become ohlc_open/high/low/close
		"fees": {
			"endpoint": "/v1/metrics/transactions/transfers_volume_sum",
			"column": "TransferVolume",
		},
	},
	api_key=api_key,
)

Column naming

  • OHLC metrics expose lowercase open/high/low/close columns.
  • All other metrics are renamed to the lowercase version of their alias (e.g. price, myfees).

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.

Metadata

Release files for glassnode-python 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glassnode-python 0.3.2
File Size Uploaded Provenance
glassnode_python-0.3.2.tar.gz 52.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for glassnode-python 0.3.2
File Interpreter ABI Platform
glassnode_python-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 88.7 kB

Release files / glassnode_python-0.3.2.tar.gz

Download URL glassnode_python-0.3.2.tar.gz
Size 52.0 kB
Tags Source
SHA-256 checksum
How to use checksums
445af40843ef10ed4cbab800c3f269c98ba617c38352b050ebc9be0fd9414af1
BLAKE2b-256 checksum
How to use checksums
0e7a6b7c275ab4dad9d07176ffe10b8e6d771488ae7bb95b4aa95c1c17e02ba4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Release files / glassnode_python-0.3.2-py3-none-any.whl

Download URL glassnode_python-0.3.2-py3-none-any.whl
Size 36.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
046fceeeb60e578e7f2d373b7ac9bdd338ad812b909a3f2718c390639cea880f
BLAKE2b-256 checksum
How to use checksums
91a6ef159856b1418d4488c14ecb26f8674dfd8b71db12f6fcf09b56dca100af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.11

Security for glassnode-python 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page