Recipes For Querying Steem Engine Data Using Steem Engine QL

in #steem-engine5 years ago (edited)

The Steem Engine side-chain layer is built on top of the Steem blockchain, as such, all of the data is out there publicly available but if you're not a developer, getting access to it isn't exactly easy. And even if you are a developer, knowing what API calls to make or values to pass to the SSC client isn't always obvious.

For close to a year now, I have been operating an open-source GraphQL API for Steem Engine (and in part, Steem) allowing you to query data. In-fact, the new Steem Engine DEX is using it because GraphQL cuts down on a lot of boilerplate code when needing to perform various queries on Steem Engine (some of which require combining multiple pieces of data together).

I thought it would be a great idea to share some recipes you can run in the GraphQL playground (an interactive way to query the GraphQL API) to get different types of data. Nothing to install, no coding knowledge required, just paste the code in and hit the big play button.

For all of these code snippets, just copy and paste them into the left-hand side of the playground and then hit the play button. You will see your results on the right-hand side.

The playground can be found here.

Determining if you have any pending withdrawals

One of the most common queries I see in the Steem Engine Discord is people who have initiated withdrawals for Steem (sometimes quite substantial) and have been waiting a day or two for them to be manually approved. Because the old DEX doesn't show you if you have any pending withdrawals, you are left to wonder if everything is okay. If you're moving thousands of Steem out, you want to make sure everything is okay.

{
    pendingWithdrawals(account: "beggars") {
        quantity,
        recipient,
        type
    }
}

If you have any pending withdrawals, simply replace the username in the quotation marks with your username and it should show up in the right-hand side. As you can see, I have a pending withdrawal for 2979 STEEM which is displayed to the right.

image.png

Seeing all pending withdrawals

This might not be that useful other than being curious, but you can query for all pending withdrawals to see who else has requests that are waiting to be reviewed. The account argument is optional.

{
    pendingWithdrawals {
        quantity,
        recipient,
        type
    }
}

image.png

The current Steem and Steem Backed Dollars (SBD) price

If you want to know the current Steem and or Steem Backed Dollars price, you can query for them. Only want to know one or the other? Simply remove whatever price you're not interested in. If you only want the Steem price, just remove the sbd value in the below query.

{
    steemPrice {
        steem,
        sbd
    }
}

image.png

Query account balances (including USD value of each holding)

If you want to query a specific account for their token holdings, including quantity, symbol and the USD value of each, the following will return these details. Consult the playground for other fields you can query on token balances, including delegations and token information.

{
    balances(account: "beggars") {
        symbol,
        balance,
        usdValue,
        usdValueFormatted
    }
}

image.png

Get the current price of a token

To get the last price of a specific token, using the metrics resolver method you can get the lastPrice metric value.

{
    metrics(symbol: "PAL") {
        lastPrice
    }
}

Get token metadata (icon, description and URL)

If you want to get the icon, description and or URL of a specific token, the following query is what you're looking for.

{
    tokens(symbol: "ENG") {
        metadata {
            url,
            icon,
            desc
        }
    }
}

image.png

See account history and actions

This will allow you to see all actions associated with buy and sell orders on the market, deposits (including tokens other than Steem) as well as withdrawals from Steem Engine.

{
    history(account: "ackza") {
        timestamp,
        symbol,
        from,
        from_type,
       to,
       to_type,
       memo,
       quantity
  }
}

image.png

Sort:  

Am I missing it somewhere - I don't see a link to the playground where you can try out these code snippets?

Well spotted. Apologies. I've updated the post and the playground can be found here: https://graphql.steem.services/

@beggars, Old Chap! I have 1.4 mn "FUTURE" tokens and I was wondering about the benefits of staking these. What is the earning potential and also wonder if you would like a large curating account randomly dropping in on the users... 😎
PS: what is the power down schedule like?
My parent account holds the tokens, I'd deli them to this one...