GraphQL API
We provide GraphQL API for solana programs instead of REST API because GraphQL is flexible, fast and developer-friendly. You can choose to query for the exact data you want from the program accounts and get it faster.
How to get data from GraphQL API?
Using curl
You can use a simple curl command to pass the query and get your desired data.
curl -X POST -H "Content-Type: application/json" -H "x-hasura-admin-secret: {your_admin_secret}" -d '{"query": "user { authority }"}' https://yourprogram.conciselabs.io/v1/graphqlUsing GraphiQL
You can also play around with the queries using GraphiQL - https://cloud.hasura.io/public/graphiql
GraphQL Clients
There are many GraphQL clients available. Listing some of them below for your reference.
Examples
Sample Query 1
curl -X POST \
-H "Content-Type: application/json" \
-H "x-hasura-admin-secret: {your_admin_secret}" \
-d '{"query": "query StakeAccount {\n stakeaccount {\n bondedshares\n owner\n stakepool\n unbondingshares\n voterweightrecord\n }\n}"}' \
https://super-stag-90.hasura.app/v1/graphqlResponse
{
"data": {
"stakeaccount": [
{
"bondedshares": 0,
"owner": "BubwQg3rMQFk9V1DZSP5KFeZ4pNJh5RHc3Kh9SHnfY7j",
"stakepool": "4o7XLNe2NYtcxhFpiXYKSobgodsuQvHgxKriDiYqE2tP",
"unbondingshares": 0,
"voterweightrecord": "8GB8uK5y5wHKG28s4d5WF2hwGJQqopUNUYocgDfa3riK"
},
{
"bondedshares": 327694027,
"owner": "7skH3e6qq2wo7LwPJGz4MJ4xUKK6NYR2Y7Qw57g2CZqG",
"stakepool": "4o7XLNe2NYtcxhFpiXYKSobgodsuQvHgxKriDiYqE2tP",
"unbondingshares": 0,
"voterweightrecord": "AuqPcsbFS5VyjnAaQqLosaXAJDGa9bDji4Uy3K7c8nLj"
},
{
"bondedshares": 41983899522,
"owner": "5VzraLSQ96QinHQPt5K3MUPijczZJCy7r6PSZzunGTxL",
"stakepool": "4o7XLNe2NYtcxhFpiXYKSobgodsuQvHgxKriDiYqE2tP",
"unbondingshares": 0,
"voterweightrecord": "BFrhyYCgyJDx2XPzZ42iGXbSqbRLx1x55vo4tP9Shfuy"
},
...
...
{
"bondedshares": 839848739,
"owner": "4B6pBb6RXdYMVMrkj9eyWaz3Ljs6Y7uDrm8iKd5WwcX2",
"stakepool": "4o7XLNe2NYtcxhFpiXYKSobgodsuQvHgxKriDiYqE2tP",
"unbondingshares": 0,
"voterweightrecord": "kQH4rEG4deX93havJRTdXYzr6iTQFVaiggpi1VqPFZ5"
}
]
}
}Sample Query 2
curl -X POST \
-H "Content-Type: application/json" \
-H "x-hasura-admin-secret: {your_admin_secret}" \
-d '{"query": "query StakePool {\n stakepool {\n authority\n bonded\n bumpseed\n governancerealm\n maxvoterweightrecord\n seed\n seedlen\n stakecollateralmint\n stakepoolvault\n tokenmint\n unbonding\n unbondperiod\n vaultamount\n }\n}"}' \
https://super-stag-90.hasura.app/v1/graphqlResponse
{
"data": {
"stakepool": [
{
"authority": "CkkWJtdPoq22CVdfWBhV5vo9MXNVaPXJAjrVmsRpYGC1",
"bonded": {
"tokens": "1eb510c6f410c9",
"shares": "3ab3ba54366d36"
},
"governancerealm": "78TbURwqF71Qk4w1Xp6Jd2gaoQb6EC7yKBh5xDJmq6qh",
"maxvoterweightrecord": "3jNVDLb7bj4jYCzVKxbMqA5zE7eKkq3osLR7s9Qpwbm2",
"stakecollateralmint": "11111111111111111111111111111111",
"stakepoolvault": "CoiMvpzT7pPmncy81XvsLvfjvXKdkE4TgsYFpEY8Zroc",
"tokenmint": "JET6zMJWkCN9tpRT2v2jfAmm5VnQFDpUBCyaKojmGtz",
"unbonding": {
"tokens": "0170a3cdf9a76e",
"shares": "0e66660bc08a4c"
},
"unbondperiod": 2551443,
"vaultamount": 9048656777689144
}
]
}
}Last updated