Jump to content
Stake Forum
Dan

Using the Stake API

Featured Comment

Using the Stake API
https://api.stake.com/graphql

Authentication

You can authenticate with graphql via the http header. If you are using the playground (via https://api.stake.com/graphql) you can simply add it to the HTTP HEADERS input at the bottom of the interface by adding your jwt token (found in local storage of your browser) and adding it to the "x-access-token" property within the header object.

For example:

{
  "x-access-token": "token goes here"
}

This process also applies for development outside the scope of the playground built into the API endpoint.

 

Schema

You can view the schema for the entire API via the following button on the right of the playground interface. From here you can search and browse all the possible queries and mutations. Queries are the equivalent of a GET request, where you are asking for information to be returned, whereas a mutation is a POST request where you invoke an action.

 

image.png

 

Examples

Send Message Mutation (sends a message to a chat channel)  [Authenticated]

mutation {
  sendMessage(chatId: "chat_id_goes_here", message: "message_goes_here") {
    id
    user {
      name
    }
  }
}

Public Chats Query (search for all public chat channels) [Unrestricted]

query {
  publicChats {
    id
    name
  }
}

Bet List Query (lookup a players bet history)  [Unrestricted]

{
  user(name: "dan") {
    betList(limit: 50, offset: 0) {
      iid
      game
      payout
      amountMultiplier
      payoutMultiplier
      amount
      currency
      createdAt
    }
  }
}

Roll Dice (play stakes dice game) [Authenticated]

mutation {
  diceRoll (amount: 1, target: 50, condition: above, currency: doge) {
    iid
    payout
    currency
    game
    nonce
  }
}

 

Share this post


Link to post
Share on other sites

Can you clarify how do you place bets from token directly ?  

whats the schema, getting token from browser is so 2014 PRIMEDICE 

Can you do this example ? 

 

diceRoll(
amount: Float!
target: Float!
condition: BetGameDiceConditionEnum!
currency: CurrencyEnum!
): Bet!




 

Share this post


Link to post
Share on other sites
On 3/29/2019 at 12:36 AM, besoeasy said:

Can you clarify how do you place bets from token directly ?  

whats the schema, getting token from browser is so 2014 PRIMEDICE 

Can you do this example ? 

 


diceRoll(
amount: Float!
target: Float!
condition: BetGameDiceConditionEnum!
currency: CurrencyEnum!
): Bet!

 

You can also get your token (with limited privileges, cant tip/withdraw/etc) from the settings page: https://stake.com/settings/tokens 

mutation {
  diceRoll (amount: 1, target: 50, condition: above, currency: doge) {
    iid
    payout
    currency
    game
    nonce
  }
}

Here is the mutation for diceRoll

The values in the curly brackets are what fields you want returned when the result is reached. There are more than the ones I omitted, which can be found via the schema.

Share this post


Link to post
Share on other sites
Posted (edited)

Hello!

I work with Python. I'm programming a roulette bot. What would be the data to bet on RouletteBetRangesInput?

Thankful.

 

rouletteBet(
currency: CurrencyEnum!
colors: [RouletteBetColorsInput]
numbers: [RouletteBetNumbersInput]
parities: [RouletteBetParitiesInput]
ranges: [RouletteBetRangesInput]
rows: [RouletteBetRowsInput]
): Bet!

 

@edit

I already managed to solve :)

----------------------------------------------

Edited by IqueSouza

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.


×