- XCHscan gives you two free API options — a REST API for simple data pulls and a GraphQL API for filtered, flexible queries.
- No API key is needed to get started — just a working internet connection and a few lines of Python or JavaScript.
- The REST API is rate-limited to 30 requests per minute (2 per minute for wallet balance lookups), so plan your polling accordingly.
- Any public-facing app must display “Powered by XCHscan.com APIs” as attribution — personal and private use is exempt.
- You can pull live XCH price, netspace, wallet balance, recent transactions, and block data all in one lightweight dashboard.
The xchscan API tutorial you actually need doesn’t have to be complicated. XCHscan exposes two clean, well-structured APIs — REST for simple data pulls and GraphQL for more targeted queries — that any developer with beginner Python skills can start using in under an hour. This guide walks you through building a real working dashboard that pulls live Chia Network data to your screen.
What Is XCHscan and Why Should Chia Developers Use It?
XCHscan is a block explorer and analytics platform built specifically for the Chia blockchain (XCH). Think of it like Etherscan, but designed from the ground up for Chia’s unique coin-based transaction model. It shows you live block data, transaction histories, wallet balances, farming stats, and network health metrics — all in one place.
For developers and miners, XCHscan matters because it fills a gap. The official Chia full-node RPC is powerful but requires a running local node. If you just want to read blockchain data — check a wallet’s balance, monitor recent transactions, or display live XCH prices — setting up and syncing a full node is overkill. XCHscan’s APIs let you access that same data remotely, with no node required and no authentication setup.
XCHscan vs. Official Chia RPC: Which One Should You Use?
This is a question that trips up a lot of new Chia developers. The short answer: use XCHscan APIs for reading data, and use the official Chia Wallet RPC when you need to write to the blockchain (send transactions, mint NFTs, create offers). XCHscan is read-only by design. It’s ideal for dashboards, monitors, bots, and analytics tools. The official Chia RPC, on the other hand, requires a synced local node and wallet — it’s the right tool when you need to interact with the chain rather than just observe it. The Chia developer documentation covers both approaches in detail if you need to understand when to switch between them.4
The XCHscan APIs are a community service — free, unauthenticated, and purpose-built for developers who want live Chia blockchain data without running a full node.
Understanding the Two XCHscan API Options
Before you write a single line of code, it helps to understand what each API is good at. XCHscan gives you two distinct paths: a REST API and a GraphQL API. Choosing the right one for your project will save you hours of troubleshooting.
The REST API: Your Fastest Route to Chia Data
The REST API uses standard HTTP GET requests and returns JSON. All endpoints share the base URL https://xchscan.com/api — just append the endpoint path to get started. This makes it incredibly easy to test in a browser or with a single curl command. The REST API covers the most common use cases: current XCH price, total netspace, circulating supply, wallet balance, recent transactions, and block data. Rate limits are 30 requests per minute across all endpoints, except for the account balance endpoint which has a stricter cap of 2 requests per minute.1
The GraphQL API: For Filtered, Flexible Queries
The GraphQL API sits at https://api.xchscan.com/v1/graphql and accepts POST requests only. It’s the better choice when you need precise control over what comes back — for example, fetching only the fields you care about from a wallet’s transaction history, or running aggregate queries like summing farmed XCH totals. GraphQL lets you request exactly the fields you need, which reduces response size and processing time. Worth noting: both the REST API and GraphQL API support address-based transaction lookups, but GraphQL gives you full field-level filtering and aggregation that the REST API doesn’t offer.2
| Goal | Best API | Why |
|---|---|---|
| Display live XCH price | REST | Single GET, no filtering needed |
| Show current netspace | REST | Simple endpoint, fast response |
| Check a wallet balance | REST | Direct address-to-balance lookup |
| Get all txns for an address | Either | Both APIs support address transaction lookups; GraphQL gives you field control |
| Filter txns by block height | GraphQL | REST doesn’t support this filter |
| Aggregate farming totals | GraphQL | Requires aggregate functions not in REST |
| Look up a specific block by hash | Either | Both work; REST is simpler |
| Build a personal farming monitor | REST | Simple, fast, no setup overhead |
xchscan API Tutorial: Set Up Your Python Environment
This tutorial uses Python 3 because it’s easy to read, widely used in the Chia community, and gets you a working result fast. You only need one external library: requests. If you already have Python 3 installed, you’re one command away from starting.
Install Dependencies
Open your terminal and run:
pip install requests
That’s the only dependency you need for the REST API version of this dashboard. For the GraphQL version, requests handles those calls too since GraphQL over HTTP is just a POST with a JSON body.
Key Rules Before You Write Your First Request
Two things you must know before building anything public with XCHscan APIs. First, the rate limit: 30 requests per minute for most endpoints, and only 2 requests per minute for the account balance endpoint (/api/account/balance). Exceeding these limits will result in your requests being blocked. Build a polling delay into any loop. Second, attribution: if you publish or share your dashboard, you must include the text “Powered by XCHscan.com APIs” or a link back to XCHscan. Personal or private use is exempt from this requirement.
Build the Dashboard: REST API Calls Step by Step
The dashboard we’re building will show four things on one screen: current XCH price, total network space (netspace), a wallet balance, and the 5 most recent transactions on the network. All of this uses the REST API — clean, simple, no GraphQL needed for this first version.
Step 1 — Fetch the XCH Price
The price endpoint returns the current XCH value in both USD and BTC, sourced from CoinMarketCap, CoinGecko, and LiveCoinWatch aggregated together.
import requests
def get_chia_price():
url = "//xchscan.com/api/chia-price"
r = requests.get(url, timeout=10)
r.raise_for_status()
return r.json()
price_data = get_chia_price()
print(f"XCH Price: ${price_data['usd']} USD")
Step 2 — Fetch the Network Space (Netspace)
Netspace returns a number in bytes representing total storage allocated to the Chia Network across all farmers globally. This is a key health metric for miners — a growing netspace means more competition; a shrinking one may indicate opportunity. You’ll want to convert bytes to a readable unit like exbibytes (EiB) since Chia netspace is typically measured in the tens of EiB range (note: this figure changes daily as farmers join or leave the network).
def get_netspace():
url = "//xchscan.com/api/netspace"
r = requests.get(url, timeout=10)
r.raise_for_status()
data = r.json()
# Convert bytes to EiB (1 EiB = 2^60 bytes)
eib = int(data['netspace']) / (2**60)
return round(eib, 2)
print(f"Netspace: {get_netspace()} EiB")
Step 3 — Fetch a Wallet Balance
This endpoint returns a wallet’s balance in both XCH (the human-readable unit) and mojos (the smallest divisible unit, where 1 XCH = 1,000,000,000,000 mojos). Remember: this endpoint is rate-limited to just 2 requests per minute, so never call it in a tight loop.
def get_wallet_balance(address: str):
url = "//xchscan.com/api/account/balance"
params = {"address": address}
r = requests.get(url, params=params, timeout=10)
r.raise_for_status()
return r.json()
my_address = "xch1yourwalletaddresshere"
balance = get_wallet_balance(my_address)
print(f"Balance: {balance['xch']} XCH")
Step 4 — Fetch Recent Transactions
The transactions endpoint returns the latest network-wide transactions, paginated. The maximum you can request in one call is 25 (limit max = 25). For the dashboard, 5 or 10 is plenty. Each transaction includes the coin ID, sender, receiver, amount in mojos, and block information.
def get_latest_transactions(limit=5):
url = "//xchscan.com/api/txns"
params = {"limit": limit, "offset": 0}
r = requests.get(url, params=params, timeout=10)
r.raise_for_status()
return r.json()
txns = get_latest_transactions(5)
for t in txns:
xch_amount = int(t['amount']) / 1_000_000_000_000
print(f" Coin: {t['coin'][:16]}... | Amount: {xch_amount:.4f} XCH")
Step 5 — Assemble the Full Dashboard
Now put it all together in a single script. This version prints a clean text dashboard to the terminal. From here you can wire it into a web app, a Telegram bot, a Grafana data source, or anything else.
import requests
import time
BASE = "//xchscan.com/api"
def get(endpoint, params=None):
r = requests.get(f"{BASE}/{endpoint}", params=params, timeout=10)
r.raise_for_status()
return r.json()
def run_dashboard(wallet_address: str):
print("=" * 50)
print(" XCH Dashboard — Powered by XCHscan.com APIs")
print("=" * 50)
# Price
price = get("chia-price")
print(f" XCH Price : ${price['usd']} USD")
# Netspace
ns = get("netspace")
eib = round(int(ns['netspace']) / (2**60), 2)
print(f" Netspace : {eib} EiB")
# Circulating supply
supply = get("circulating-supply")
print(f" Circulating : {supply} XCH")
# Wallet balance (rate limited: 2 req/min)
try:
bal = get("account/balance", {"address": wallet_address})
print(f" Wallet Balance : {bal['xch']} XCH")
except Exception as e:
print(f" Wallet Balance : Error — {e}")
# Recent transactions
print("\n Recent Transactions:")
txns = get("txns", {"limit": 5, "offset": 0})
for t in txns:
amount_xch = round(int(t['amount']) / 1e12, 6)
print(f" {t['coin'][:20]}... | {amount_xch} XCH")
print("=" * 50)
if __name__ == "__main__":
YOUR_WALLET = "xch1yourwalletaddresshere"
run_dashboard(YOUR_WALLET)
Level Up: Using GraphQL in Your xchscan API Tutorial Project
Once the REST dashboard is working, GraphQL opens up a much richer layer of data. While both APIs support address-based transaction lookups, GraphQL is the stronger choice for wallet history monitoring when you need precise field control — you can specify exactly which fields come back, combine multiple queries in one request, and run aggregations like summing farmed XCH totals across all coinbase transactions. These capabilities go well beyond what the REST API offers.
Python Helper for GraphQL Queries
GraphQL over HTTP is just a POST request with a JSON body. The function below handles all the boilerplate so you can focus on writing queries:
import requests
GQL = "//api.xchscan.com/v1/graphql"
def gql_query(query: str, variables: dict = None):
payload = {"query": query, "variables": variables or {}}
r = requests.post(GQL, json=payload, timeout=15)
r.raise_for_status()
result = r.json()
if "errors" in result:
raise RuntimeError(result["errors"])
return result["data"]
Query: Get All Transactions for a Wallet Address
This is the most useful GraphQL query for a farming monitor. It returns the most recent transactions where your wallet address is either the sender (from) or receiver (to):
ADDRESS_TXNS = """
query addrTxns($address: String, $limit: Int, $offset: Int) {
txns(
order_by: { timestamp: desc }
limit: $limit
offset: $offset
where: {
_or: [
{ from: { _eq: $address } }
{ to: { _eq: $address } }
]
}
) {
coin
amount
from
to
timestamp
block {
height
header_hash
}
}
}
"""
data = gql_query(ADDRESS_TXNS, {
"address": "xch1yourwalletaddresshere",
"limit": 10,
"offset": 0
})
for txn in data["txns"]:
print(txn)
REST API vs. GraphQL API: Side-by-Side Comparison
| Feature | REST API | GraphQL API |
|---|---|---|
| HTTP Method | GET only | POST only |
| Authentication | None required | None required |
| Rate Limit | 30 req/min (2 req/min for balance) | Not officially published |
| Response Format | JSON (fixed schema) | JSON (you define the fields) |
| Filtering | Limited (address, coin ID, hash) | Full field-level filtering |
| Aggregation | No | Yes (sum, count, etc.) |
| Pagination | limit (max 25) / offset (max 10,000) | limit / offset (same constraints) |
| Address transaction lookup | Yes — via /api/account/txns | Yes — with full field control |
| Best for beginners | Yes — simple URLs, easy to test | Moderate — requires query syntax |
| Best for dashboards | Yes — price, netspace, balance | Yes — filtered wallet history |
Real-World Applications: What You Can Build with xchscan API Data
The XCHscan API pattern — unauthenticated, REST-based, returning clean JSON — makes it a practical foundation for a wide range of tools. The most natural starting point is a wallet balance monitor: a short polling script that checks a farming address every few minutes and logs whenever the balance changes. Because the balance endpoint requires no setup beyond a valid XCH address, the entire tool can be written in under 30 lines of Python and run as a cron job or systemd service.
The community has taken the same concept in several directions. XCHscan itself ships a Chia farming profitability calculator that uses live netspace and price data from the same API endpoints this tutorial covers — showing how even simple REST calls can power a production-quality tool.5 Beyond the official tools, the Prometheus Chia Exporter project on GitHub is a well-known example of what monitoring infrastructure looks like in the Chia ecosystem. It connects to the official Chia full-node RPC to export farming metrics into a Grafana dashboard3 — a model you could replicate using XCHscan API endpoints instead of a local node, giving you the same visual dashboard without requiring a synced node on the same machine.
You don’t need to be a blockchain developer to build useful tools on top of XCHscan’s APIs — if you can make an HTTP GET request and parse JSON, you can build a live Chia dashboard today.
Common xchscan API Tutorial Mistakes and How to Avoid Them
Most problems beginners run into with the xchscan API fall into three categories. The first is hitting rate limits. The general limit of 30 requests per minute sounds generous, but if you’re polling multiple endpoints in a loop without a time.sleep() pause, you’ll exceed it fast. Add at least a 2-second delay between requests and a longer delay on the balance endpoint. Use Python’s r.raise_for_status() so HTTP 429 rate-limit errors surface immediately instead of failing silently.
The second issue is misreading the amount field. All transaction amounts are returned in mojos, not XCH. One XCH equals exactly 1,000,000,000,000 mojos (1012). Dividing by 1e12 gives you the human-readable XCH value. Skipping this conversion is the single most common mistake in new dashboard builds.
The third issue comes up when building for a public audience and forgetting the attribution requirement. The XCHscan terms are clear: any non-personal, non-private use must include a “Powered by XCHscan.com APIs” credit. This is easy to add as a footer line in your dashboard and keeps you compliant with the API’s terms of service.
Start Building Your xchscan API Dashboard Today
You now have everything you need to build a working Chia Network data dashboard from scratch. The XCHscan REST API gives you live XCH price, netspace, wallet balances, and transaction data with nothing more than Python’s requests library and a few clean GET calls. When you’re ready to filter by address, aggregate farming totals, or pull custom field sets, the GraphQL API is there waiting. The Chia ecosystem is growing fast, and developers who get comfortable with tools like this now are building the foundation for the next generation of on-chain applications. If you want to go deeper into how smart contracts interact with the coin data you’re now reading, check out our guide to Chialisp and next-gen smart contracts — understanding the coin model behind those transactions makes your dashboard data a whole lot more meaningful.
xchscan api tutorial FAQs
What is the xchscan API and how does it work?
The xchscan API is a free, public interface for reading Chia blockchain data. It offers two options: a REST API using simple HTTP GET requests and a GraphQL API for filtered queries — both return JSON and require no API key to use.
Do I need an API key to use xchscan API endpoints?
No — xchscan API endpoints are publicly accessible without authentication. You simply make HTTP requests to the documented URLs; the only requirement is staying within the rate limits of 30 requests per minute (2 per minute for balance lookups).
What is the difference between the xchscan REST API and the GraphQL API?
Both APIs support common lookups like address transactions, but they serve different needs. The REST API is best for simple, fixed data pulls like XCH price, netspace, and wallet balance. The GraphQL API adds full field-level filtering, aggregation, and custom field selection, making it the better choice for complex analytics and farming monitors.
Can I use xchscan API data in a public app or website?
Yes, but you must include “Powered by XCHscan.com APIs” as attribution in any public-facing application. Personal or private use is exempt from this requirement according to XCHscan’s terms of service.
What is the pagination limit for xchscan API results?
XCHscan API pagination limits allow a maximum of 25 results per request (the limit parameter) and a maximum offset of 10,000, meaning you can page through the most recent 10,000 records for endpoints like transactions and blocks.
xchscan api tutorial Citations
- XCHscan — Chia (XCH) REST API Documentation. https://xchscan.com/rest-api
- XCHscan — Chia (XCH) GraphQL API Documentation. https://xchscan.com/graphql-api
- GitHub — Prometheus Chia Exporter (speedmann). https://github.com/speedmann/prometheus-chia-exporter
- Chia Network — Official Developer Documentation. https://docs.chia.net/
- ChiaLinks — Chia Cryptocurrency Tools and Resources. https://chialinks.com/tools/
