Jump to content
Stake Forum

Featured Comment

Hi everyone,

I'm entering a new world of trying to connect to the API. So far I have been able to connect, bet and change the bet amount under certain conditions.

Now, I'm trying to fetch some data, for example my balance. I've tried some things in the Playground (https://api.stake.com/graphql) but to no avail :(

Could someone provide me the JSON string to query my balance? I think if I have seen some more examples, I can figure out most of the other settings. Thanks in advance!

Share this post


Link to post
Share on other sites

Umm why do you need it tho ? Because if you already have the bet amount changer it looks like you want to create a bot for a certain game. 

Share this post


Link to post
Share on other sites
1 hour ago, Kate said:

Umm why do you need it tho ? Because if you already have the bet amount changer it looks like you want to create a bot for a certain game. 

I want the bet amount being dependent on my balance... for example: high balance --> high bet amount, low balance --> low bet amount

Share this post


Link to post
Share on other sites
3 minutes ago, cryptonesiac said:

Hmmm, maybe I'm stupid... but this is the outcome (censored the ID, just in case):

https://pastebin.com/raw/PLm4Bb9G

that's strange, my output looks more or less like this: (i obviously changed id and some numbers)

Quote

[{"data":{"user":{"id":"70d3d80b-9b77-4ca3-bfd1-fcabcdd0db58","balances":[{"available":{"currency":"bch","amount":0.12345711908036148,"__typename":"Balance"},"__typename":"UserBalance"},{"available":{"currency":"btc","amount":0.234561595439795773,"__typename":"Balance"},"__typename":"UserBalance"},{"available":{"currency":"doge","amount":0.3456797704543,"__typename":"Balance"},"__typename":"UserBalance"},{"available":{"currency":"eth","amount":0.4567850066562882,"__typename":"Balance"},"__typename":"UserBalance"},{"available":{"currency":"ltc","amount":0.567890529888832749,"__typename":"Balance"},"__typename":"UserBalance"}],"__typename":"User"}}}]

it is also the exact same way as the site gets the balances, too. for reference here is the corresponding curl command, that creates the above output for me (with the api key removed):

Quote

curl 'https://api.stake.com/graphql' -H 'accept: */*' -H 'Referer: https://stake.com/' -H 'Origin: https://stake.com' -H 'x-lockdown-token: undefined' -H 'x-access-token: REMOVED' -H 'content-type: application/json' --data-binary '[{"operationName":"StakeBalances","variables":{"available":true,"vault":false},"query":"query StakeBalances($available: Boolean = false, $vault: Boolean = false) {\n  user {\n    id\n    balances {\n      available @include(if: $available) {\n        currency\n        amount\n        __typename\n      }\n      vault @include(if: $vault) {\n        currency\n        amount\n        __typename\n      }\n      __typename\n    }\n    __typename\n  }\n}\n"}]' --compressed

it works like a charme for me.

Share this post


Link to post
Share on other sites
28 minutes ago, cryptonesiac said:

query StakeBalances($available: Boolean = false, $vault: Boolean = false) {

first Boolean = false should become Boolean = true


query StakeBalances($available: Boolean = true, $vault: Boolean = false) {

then it's working like a charm! Thanks a lot :D

hehe i definitely didn't change anything but anything that works, i guess :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×