### Glassnode CLI Quick Start Examples Source: https://docs.glassnode.com/basic-api/glassnode-cli Basic commands to list available assets and fetch Bitcoin's closing price for the last 30 days. ```bash # List available assets gn asset list ``` ```bash # Fetch Bitcoin's closing price for the last 30 days gn metric get market/price_usd_close --asset BTC --since 30d ``` -------------------------------- ### Dynamic Documentation Query Example Source: https://docs.glassnode.com/basic-api/api-key Illustrates how to query the documentation dynamically by making an HTTP GET request with an 'ask' query parameter. This is useful for retrieving specific information not explicitly found on the page. ```http GET https://docs.glassnode.com/basic-api/api-key.md?ask= ``` -------------------------------- ### Install Glassnode CLI (Linux/macOS) Source: https://docs.glassnode.com/basic-api/glassnode-cli Installs the latest release of the Glassnode CLI to /usr/local/bin. Uses sudo if necessary. To install to a custom directory, set the INSTALL_DIR environment variable. ```bash curl -sSL https://raw.githubusercontent.com/glassnode/glassnode-cli/main/install.sh | bash ``` ```bash INSTALL_DIR=~/bin curl -sSL https://raw.githubusercontent.com/glassnode/glassnode-cli/main/install.sh | bash ``` -------------------------------- ### Install Glassnode CLI (Windows PowerShell) Source: https://docs.glassnode.com/basic-api/glassnode-cli Installs the Glassnode CLI to %LOCALAPPDATA%\glassnode\bin and adds it to the user PATH if needed. ```powershell irm https://raw.githubusercontent.com/glassnode/glassnode-cli/main/install.ps1 | iex ``` -------------------------------- ### Example Prompts for Glassnode MCP Source: https://docs.glassnode.com/guides-and-tutorials/glassnode-mcp-server These are example natural language prompts to get information from the Glassnode MCP tools. Use these to understand the types of queries supported. ```plaintext What can Glassnode mcp do? ``` ```plaintext - What market metrics Glassnode has for Ethereum? - What assets does Glassnode support? - Bitcoin price, use 10 minute resolution ``` ```plaintext - SOPR and MVRV for Bitcoin and Ethereum, values for the past month - Show me Bitcoin whale activity - Compare the market caps of Bitcoin, Ethereum, and Solana over the last month ``` -------------------------------- ### Install Glassnode MCP Server (Public Access) Source: https://docs.glassnode.com/guides-and-tutorials/glassnode-mcp-server Use this command to install the Glassnode MCP server for public access. This command auto-detects and configures installed AI clients. ```bash npx add-mcp https://mcp.glassnode.com ``` -------------------------------- ### Backtesting Example Source: https://docs.glassnode.com/guides-and-tutorials/workbench-guide Provides an example of how to use the `backtest` function to simulate a trading strategy. ```APIDOC ## POST /api/backtest ### Description Simulates a trading strategy based on provided conditions and parameters. This example simulates a simple moving average cross-over strategy. ### Method POST ### Endpoint `/api/backtest` ### Parameters #### Query Parameters - **m1** (string) - Required - The primary metric series (e.g., price). - **strategy** (string) - Required - The trading strategy logic (e.g., `if(sma(m1, 20), ">", sma(m1, 50), 1, 0)`). - **since** (timestamp) - Required - The starting timestamp for the backtest. - **initial_investment** (float) - Required - The initial investment amount in USD. - **trading_cost** (float) - Required - The approximated trading cost per trade (e.g., 0.001 for 0.1%). ### Request Example ```json { "m1": "BTC", "strategy": "if(sma(m1, 20) > sma(m1, 50), 1, 0)", "since": "2020-01-01", "initial_investment": 1000, "trading_cost": 0.001 } ``` ### Response #### Success Response (200) - **backtest_results** (object) - Contains performance metrics like NAV curve, total return, Sharpe ratio, etc. #### Response Example ```json { "backtest_results": { "nav_curve": [ {"timestamp": 1577836800, "value": 1000.0}, {"timestamp": 1577923200, "value": 1020.5} ], "total_return": 0.0205, "sharpe_ratio": 1.5 } } ``` ``` -------------------------------- ### HTTP Examples for API Key Usage Source: https://docs.glassnode.com/basic-api/api-key Shows how to use your API key with the http command-line tool, including examples for both query parameter and request header methods. Your API key should be set as an environment variable. ```bash export API_KEY=YOUR-KEY # using query parameter http "https://api.glassnode.com/v1/metrics/assets" api_key==$API_KEY # using request header http "https://api.glassnode.com/v1/metrics/assets" "X-Api-Key:${API_KEY}" ``` -------------------------------- ### Query Glassnode Documentation via HTTP GET Source: https://docs.glassnode.com/data/general-information Perform an HTTP GET request to the current page URL with the 'ask' query parameter to dynamically query the documentation. The question should be specific and self-contained. ```http GET https://docs.glassnode.com/data/general-information.md?ask= ``` -------------------------------- ### Get Single Metric Value with GN.METRIC Source: https://docs.glassnode.com/guides-and-tutorials/glassnode-excel-add-in Retrieve a specific metric for an asset on a given date using the GN.METRIC function. For example, to get yesterday's BTC USD close price. ```excel =GN.METRIC("BTC", "/market/price_usd_close", TODAY()-1) ``` -------------------------------- ### Simulate Daily Dollar Cost Averaging (DCA) Installments Source: https://docs.glassnode.com/guides-and-tutorials/workbench-guide A helper function that simulates daily DCA installments. Parameters include a price series `m1`, start timestamp `since`, total investment in USD `total_invest_usd`, and number of installments `numb_installments`. Returns a step function visualizing daily installments (in USD), usable as input `f1` to the `dca` function. ```glassnode-query-language dca_installments(m1, "2020-01-01", 1230, 1000) ``` -------------------------------- ### Install Glassnode CLI from Source Source: https://docs.glassnode.com/basic-api/glassnode-cli Installs the Glassnode CLI from source using Go. The default binary name is 'glassnode-cli'. To use 'gn' as the command, build with 'go build -o gn .'. Ensure the binary is in your PATH. ```bash go install github.com/glassnode/glassnode-cli@latest ``` ```bash go build -o gn . ``` -------------------------------- ### Install Glassnode MCP Server (Authenticated) Source: https://docs.glassnode.com/guides-and-tutorials/glassnode-mcp-server Install the Glassnode MCP server with authenticated access using an API key. This method removes the 30-day time limit but consumes API credits. Replace YOUR_API_KEY with your actual key. ```bash npx add-mcp https://mcp.glassnode.com --header "X-Api-Key:YOUR_API_KEY" ``` -------------------------------- ### Get Metric Data for a Date Range with GN.METRIC Source: https://docs.glassnode.com/guides-and-tutorials/glassnode-excel-add-in Fetch metric data for a specified date range using the GN.METRIC function. This example retrieves the last 10 days of BTC USD close prices. ```excel =GN.METRIC("BTC", "/market/price_usd_close", TODAY()-11, TODAY()-1) ``` -------------------------------- ### Calculate Net Asset Value (NAV) Curve with DCA Source: https://docs.glassnode.com/guides-and-tutorials/workbench-guide Returns the net asset value (NAV) curve of an aggregated position in asset `m1`. `f1` defines daily DCA installments and `since` defines the starting timestamp. The function calculates `cumsum(f1/m1, since)*m1`. ```glassnode-query-language dca(m1, f1, "2020-01-01") ``` -------------------------------- ### Query Documentation Dynamically via HTTP GET Source: https://docs.glassnode.com/further-information Use this method to ask questions about the documentation. The response includes direct answers and relevant sources. Ensure your question is specific and self-contained. ```http GET https://docs.glassnode.com/further-information.md?ask= ``` -------------------------------- ### Query Documentation with 'ask' Parameter Source: https://docs.glassnode.com/guides-and-tutorials/metric-guides/lifespan/spent-output-age-bands-soab Perform an HTTP GET request to query documentation dynamically. The question should be specific and self-contained. ```http GET https://docs.glassnode.com/guides-and-tutorials/metric-guides/lifespan/spent-output-age-bands-soab.md?ask= ``` -------------------------------- ### Perform HTTP GET Request with `ask` Parameter Source: https://docs.glassnode.com/guides-and-tutorials/getting-started/get-started-with-glassnode-metrics Use this method to query documentation dynamically. The question should be specific and self-contained. The response includes a direct answer and relevant excerpts. ```http GET https://docs.glassnode.com/guides-and-tutorials/getting-started/get-started-with-glassnode-metrics.md?ask= ``` -------------------------------- ### DCA Installments Helper Function Source: https://docs.glassnode.com/guides-and-tutorials/workbench-guide A helper function to simulate daily DCA installments, which can be used as input for the `dca` function. ```APIDOC ## POST /api/dca_installments ### Description A helper function that simulates daily DCA (dollar cost averaging) installments. The parameters are: a price series `m1`, a timestamp when DCA begins: `since`, the total target investment in USD: `total_invest_usd`, how many installments in total: `numb_installments`. The function returns a step function visualizing the daily installments (in USD). This serves as possible input `f1` to the `dca` function. ### Method POST ### Endpoint `/api/dca_installments` ### Parameters #### Query Parameters - **m1** (string) - Required - The price series of the asset. - **since** (timestamp) - Required - The timestamp when DCA begins. - **total_invest_usd** (float) - Required - The total target investment in USD. - **numb_installments** (integer) - Required - The total number of installments. ### Request Example ```json { "m1": "BTC", "since": "2020-01-01", "total_invest_usd": 1230, "numb_installments": 1000 } ``` ### Response #### Success Response (200) - **installments** (array) - A step function visualizing the daily installments in USD. #### Response Example ```json { "installments": [ {"timestamp": 1577836800, "value": 1.23}, {"timestamp": 1577923200, "value": 1.23} ] } ``` ``` -------------------------------- ### Query Documentation Index via GET Request Source: https://docs.glassnode.com/api/market Use this method to ask specific questions about the documentation. Append your question to the 'ask' parameter in the URL. The response includes a direct answer and relevant sources. ```http GET https://docs.glassnode.com/basic-api/endpoints/market.md?ask= ``` -------------------------------- ### GET /metrics/exchange-flows Source: https://docs.glassnode.com/basic-api/endpoints/pit Retrieves exchange flow metrics for a specified asset. This endpoint allows you to get data on how assets are moving into and out of exchanges. ```APIDOC ## GET /metrics/exchange-flows ### Description Retrieves exchange flow metrics for a specified asset. ### Method GET ### Endpoint /metrics/exchange-flows ### Parameters #### Query Parameters - **asset** (string) - Required - The asset to retrieve data for (e.g., 'bitcoin', 'ethereum'). - **since** (string) - Optional - The start date for the data in RFC 3339 format or a humanized string (e.g., '2023-01-01', '2 weeks ago'). - **limit** (integer) - Optional - The maximum number of data points to return. Defaults to 100. - **unit** (string) - Optional - The time unit for the data. Allowed values: 'day', 'hour'. Defaults to 'day'. - **interval** (integer) - Optional - The interval in the specified unit. Defaults to 1. - **timestamp_format** (string) - Optional - The format for the timestamp in the response. Allowed values: 'unix', 'humanized'. Defaults to 'unix'. ### Request Example ```json { "asset": "bitcoin", "since": "2023-10-26T00:00:00Z", "limit": 50, "unit": "day", "interval": 1, "timestamp_format": "humanized" } ``` ### Response #### Success Response (200) - **status** (string) - The status of the response ('ok' or 'error'). - **request** (object) - Details of the API request. - **result** (array) - An array of data points, where each point contains a timestamp and the corresponding metric value. #### Response Example ```json { "status": "ok", "request": { "asset_id": "bitcoin", "metric_id": "exchange_inflow", "from": 1698278400, "to": 1698364800, "interval": 1, "limit": 50, "unit": "day" }, "result": [ { "timestamp": 1698278400, "value": 1500.75 }, { "timestamp": 1698364800, "value": 1650.20 } ] } ``` #### Error Response (400, 401, 429) - **status** (string) - The status of the response ('error'). - **error_code** (string) - A code indicating the type of error. - **error_message** (string) - A human-readable message describing the error. ``` -------------------------------- ### Query Documentation with 'ask' Parameter Source: https://docs.glassnode.com/basic-api/api Perform an HTTP GET request to query the documentation dynamically. Use this when the answer is not explicitly present, for clarification, or to retrieve related documentation sections. ```HTTP GET https://docs.glassnode.com/basic-api/api.md?ask= ``` -------------------------------- ### Querying Documentation Dynamically Source: https://docs.glassnode.com/basic-api/endpoints/eth2 To get information not explicitly present, make a GET request to the page URL with an 'ask' query parameter containing your question. ```http GET https://docs.glassnode.com/basic-api/endpoints/eth2.md?ask= ``` -------------------------------- ### Perform HTTP GET Request with 'ask' Parameter Source: https://docs.glassnode.com/guides-and-tutorials/metric-guides/lifespan/median-spent-output-lifespan-msol Use this method to query documentation dynamically. The question should be specific and self-contained. The response includes an answer and relevant excerpts. ```http GET https://docs.glassnode.com/guides-and-tutorials/metric-guides/lifespan/median-spent-output-lifespan-msol.md?ask= ``` -------------------------------- ### Multi-Timeseries PIT Metric Example Source: https://docs.glassnode.com/data/point-in-time-metrics This example demonstrates a multi-timeseries Point-in-Time metric response, showing various aggregated values for different timeframes. The `computed_at` field is included. ```json [ { "t": 1758585600, "o": { "1d_1w": 67801800.87019362, "1m_3m": 61961089.16651055, "1w_1m": 7858184.390406752, "1y_2y": 212210.47253626725, "24h": 136026264.4282406, "2y_3y": 77661.69283392503, "3m_6m": 2498347.3922234857, "3y_5y": 145433.61576217506, "5y_7y": 0, "6m_12m": 1737574.3098036172, "7y_10y": 0, "aggregated": 278318566.33851117, "more_10y": 0 }, "computed_at": 1758684766 }, ... ``` -------------------------------- ### Querying Documentation Dynamically Source: https://docs.glassnode.com/basic-api/endpoints/macro To get information not explicitly present on a page, make a GET request to the page URL with an 'ask' query parameter containing your question in natural language. ```http GET https://docs.glassnode.com/basic-api/endpoints/macro.md?ask= ```