Graphql API
The XCHscan Chia Developer APIs are provided as a community service and without warranty, so please use what you need and no more.
Source attribution via a link back or mention that your app is "Powered by XCHscan.com APIs" is required except for personal/private usage.
You can access the GraphQL APIs using the cURL, or any GraphQL/HTTP client. We support POST requests only.
GraphQL endpoint:
POST https://api.xchscan.com/v1/graphql
cURL example:
curl -X POST \
https://api.xchscan.com/v1/graphql \
-d '{"query": "query {\n block_state {\n space\n }\n}", "variables": null}'
Netspace
Query
query {
block_state {
space
}
}
Response
{
"data": {
"block_state": [
{
"space": 23806667044453120000
}
]
}
}
Chia Price
Query
query {
block_state {
chia_price
}
}
Response
{
"data": {
"block_state": [
{
"chia_price": 531.59
}
]
}
}
Farmed XCH
Query
query {
txns_aggregate(where: {coinbase: {_eq: true}}) {
aggregate {
sum {
amount
}
}
}
}
Response
{
"data": {
"txns_aggregate": {
"aggregate": {
"sum": {
"amount": 21822913958416100000
}
}
}
}
}
Latest Blocks
Query
query blocks(
$limit: Int
$offset: Int
) {
blocks(
order_by: { height: desc }
limit: $limit
offset: $offset
) {
id
height
header_hash
transaction_fees
transaction_timestamp
}
}
Variables
{
"limit": 10,
"offset": 0
}
Response
{
"data": {
"blocks": [
{
"id": "484c1fdf-39ec-4972-b072-a31b73adc0ce",
"height": 411341,
"header_hash": "0xe64b82f2af6b7ab341fcb66dfeb42d54cdcc689928130d0ad3d58763ece49b1b",
"transaction_fees": 100000027,
"transaction_timestamp": 1623328450
},
...
]
}
}
Latest Transactions
Query
query txns(
$limit: Int
$offset: Int
) {
txns(
order_by: { timestamp: desc }
limit: $limit
offset: $offset
) {
id
coin
amount
from
spent
to
timestamp
block {
id
height
header_hash
}
}
}
Variables
{
"limit": 10,
"offset": 0
}
Response
{
"data": {
"txns": [
{
"id": "6e240b74-6707-485a-b24c-cf16eb1d1d70",
"coin": "0x09f9ec3fc6c28cb6ffe0a3e567f6d72b83c589e2c5efd98598c27b62696b5f7a",
"amount": 1750000000000,
"from": null,
"spent": false,
"to": "xch1mvyu5dtymckswsu065an34lw26fug3aq0wc8hx26khd4fkaaevzqhprzal",
"timestamp": 1623328450,
"block": {
"id": "484c1fdf-39ec-4972-b072-a31b73adc0ce",
"height": 411341,
"header_hash": "0xe64b82f2af6b7ab341fcb66dfeb42d54cdcc689928130d0ad3d58763ece49b1b"
}
},
...
]
}
}
Single Block
Query
query block($height: bigint) {
blocks(
where: {
height: { _eq: $height }
}
) {
id
height
header_hash
transaction_fees
transaction_timestamp
}
}
Variables
{
"height": 411341
}
Response
{
"data": {
"blocks": [
{
"id": "484c1fdf-39ec-4972-b072-a31b73adc0ce",
"height": 411341,
"header_hash": "0xe64b82f2af6b7ab341fcb66dfeb42d54cdcc689928130d0ad3d58763ece49b1b",
"transaction_fees": 100000027,
"transaction_timestamp": 1623328450
},
]
}
}
Single Transaction
Query
query txn($coin: String) {
txns(
where: {
coin: { _eq: $coin }
}
) {
id
coin
amount
from
spent
to
timestamp
block {
id
height
header_hash
}
}
}
Variables
{
"coin": "0x09f9ec3fc6c28cb6ffe0a3e567f6d72b83c589e2c5efd98598c27b62696b5f7a"
}
Response
{
"data": {
"txns": [
{
"id": "6e240b74-6707-485a-b24c-cf16eb1d1d70",
"coin": "0x09f9ec3fc6c28cb6ffe0a3e567f6d72b83c589e2c5efd98598c27b62696b5f7a",
"amount": 1750000000000,
"from": null,
"spent": false,
"to": "xch1mvyu5dtymckswsu065an34lw26fug3aq0wc8hx26khd4fkaaevzqhprzal",
"timestamp": 1623328450,
"block": {
"id": "484c1fdf-39ec-4972-b072-a31b73adc0ce",
"height": 411341,
"header_hash": "0xe64b82f2af6b7ab341fcb66dfeb42d54cdcc689928130d0ad3d58763ece49b1b"
}
}
]
}
}
Block Transactions
Query
query txn(
$height: bigint
$limit: Int
$offset: Int
) {
txns(
order_by: { timestamp: desc }
where: {
block: { height: { _eq: $height } }
}
limit: $limit
offset: $offset
) {
id
coin
amount
from
spent
to
timestamp
block {
id
height
header_hash
transaction_fees
transaction_timestamp
}
}
}
Variables
{
"height": 411341,
"limit": 10,
"offset": 0
}
Response
{
"data": {
"txns": [
{
"id": "225b101b-4058-4abd-a8b1-358739855864",
"coin": "0x1d62d876b00573605cc1a8bd46611b6b19bf8d5486769f7ac4233f47a4ec4ad7",
"amount": 2000,
"from": "xch1f088frkkrahjmfwd5x5ptsydw6tgx50gju07a22u8fmhhupw7v8sjgwlsx",
"spent": false,
"to": "xch18tq5zh834vgjre0clquklues8aa3gr09966q9h32csq8588gp6yqdkaqhf",
"timestamp": 1623328450,
"block": {
"id": "484c1fdf-39ec-4972-b072-a31b73adc0ce",
"height": 411341,
"header_hash": "0xe64b82f2af6b7ab341fcb66dfeb42d54cdcc689928130d0ad3d58763ece49b1b",
"transaction_fees": 100000027,
"transaction_timestamp": 1623328450
}
},
...
]
}
}
Address Balance
Query
query txns_aggregate($address: String) {
balance: txns_aggregate(
where: { to: { _eq: $address }, spent: { _eq: false } }
) {
aggregate {
sum {
amount
}
}
}
}
Variables
{
"address": "xch1f0ryxk6qn096hefcwrdwpuph2hm24w69jnzezhkfswk0z2jar7aq5zzpfj"
}
Response
{
"data": {
"balance": {
"aggregate": {
"sum": {
"amount": 53985953434018930
}
}
}
}
}
Address Transactions
Query
query txns(
$address: String
$limit: Int
$offset: Int
) {
txns(
order_by: { timestamp: desc }
limit: $limit
offset: $offset
where: {
_or: [{ from: { _eq: $address } }, { to: { _eq: $address } }]
}
) {
id
amount
from
spent
to
timestamp
block {
id
height
header_hash
}
}
}
Variables
{
"address": "xch1f0ryxk6qn096hefcwrdwpuph2hm24w69jnzezhkfswk0z2jar7aq5zzpfj",
"limit": 10,
"offset": 0
}
Response
{
"data": {
"txns": [
{
"id": "1c976ae0-eb56-4811-bd7b-a952260ea9c3",
"amount": 1000000000000,
"from": "xch1f0ryxk6qn096hefcwrdwpuph2hm24w69jnzezhkfswk0z2jar7aq5zzpfj",
"spent": false,
"to": "xch1f0ryxk6qn096hefcwrdwpuph2hm24w69jnzezhkfswk0z2jar7aq5zzpfj",
"timestamp": 1623312457,
"block": {
"id": "6aee0565-5ddb-4685-a261-82e982421b5f",
"height": 410447,
"header_hash": "0xdcff3fe582a085c4bffdf6fe9e63156101f5d2418af7d1c5bfb32ab44cf6fbbe"
}
},
...
]
}
}