Jump to content

Using the Stake API


Featured Comment

2 hours ago, Saaho2019 said:

@Dan How to send Tip to other user

Please example with dummy input :) thanks 

You have the answer to that in a previous post (page 3).

image.png

This is a tip example. All you need to do is change the userId with the userId of the user you wish to send to and the chatId.

You can get the userId like this (from the main post):

query{
  user(name: "Dan") {
    id
  }
}

And the chatId like this (also in the main post):

query {
  publicChats {
    id
    name
  }
}

Bear in mind! You need to have an api key that has access to tip! Not the one from the settings on the platform but rather the one from your local storage of your browser. If you use Google Chrome, check out what Dan said in a previous post on how to get that key. If you have Mozilla/other browser, you'd have to look up on Google "How to find JWT Token on X browser". Depending on the browser there might be some extensions/plugins to do it for you automatically.

Edited by skywallkee
Link to post
Share on other sites
34 minutes ago, skywallkee said:

This is a tip example. All you need to do is change the userId with the userId of the user you wish to send to and the chatId.

Ok let me try this :) 

Yeah working fine :) 

i had the jwt token form local storage damn but i didn't noticed it was unchecked till now 
now working fine :) 

 

Edited by Saaho2019
Link to post
Share on other sites
 

how do i return roulette bet history

This should help you with your problem:

query{
  user(name: "username here") {
    houseBetList(limit: 50, offset: 0, game:roulette) {
      id
      iid
      bet {
        ... on CasinoBet {
          game
          payout
          amountMultiplier
          payoutMultiplier
          amount
          currency
          createdAt
        }
      }
    }
  }
}

You can replace roulette with any enum from the game list (dice, limbo, hilo, keno, mines, plinko, blackjack, roulette, slots, wheel, diamondPoker, baccarat, crash, videoPoker)

You can also find this on the first post @Dan did, excepting the "filtering" part with the game (but it isn't really that hard to figure out).

Link to post
Share on other sites
  • Forum Admin
 

is the sportBet implemented?

Im looking into placing a bet once a certain multiplier gets satisfied, for example:
Miami heat Vs Chicago bulls
current odds are:

Heat: 1.78, Bulls: 2.1

I would like to place a bet once bulls reach 2.2 for 1000 Tron for example.

This type of functionality is not supported currently. We will be building a public API in the coming months to support such strategy betting.

Link to post
Share on other sites

@Dan

Is it possible to withdraw through the API?

mutation {
  createWithdrawal(currency: doge, address: "wrgwrhwrhwrshwrh", amount: 500) {
    id
    name
    address
    amount
    refFee
    status
  }

 

I am getting restricted.

{
    "errors": [
        {
            "path": [
                "createWithdrawal"
            ],
            "message": "API access restricted",
            "errorType": "restrictedScope",
            "data": {}
        }
    ],
    "data": null
}

 

Edited by eothica
Link to post
Share on other sites
4 hours ago, eothica said:

@Dan

Is it possible to withdraw through the API?


mutation {
  createWithdrawal(currency: doge, address: "wrgwrhwrhwrshwrh", amount: 500) {
    id
    name
    address
    amount
    refFee
    status
  }

 

I am getting restricted.


{
    "errors": [
        {
            "path": [
                "createWithdrawal"
            ],
            "message": "API access restricted",
            "errorType": "restrictedScope",
            "data": {}
        }
    ],
    "data": null
}

 

This might be because you're using the wrong API key. The one found in the account settings will only allow you to do bets (and I believe search history and so, but definitely not withdrawing). If you want to find the correct API key, Dan did a comment on how to do so here:

On 10/15/2019 at 2:38 AM, Dan said:

Restricted scope means you arent authenticating correctly with the API, you are probably using the token found under your account settings, but if you want to tip, you need ot use your jwt token. How to obtain your jwt token you need to right click on the stake website, and go to 'inspect' or developer tools. Then go to application > local storage > stake.com

From there you can copy your jwt token and it will have enough privileges to send a tip.

Currently it is not possible to lookup transactional data beyond 500 offset. Our system doesn't handle it very well.

That explanation works with Google Chrome, for Firefox, you might have to look it up a little on the internet (as I am a Firefox user and it was a little harder, reason why you could try just taking it off of Google Chrome even if you're a Firefox user).

Edited by skywallkee
If you have any problem finding your API key, send me a PM and will guide you through
Link to post
Share on other sites
3 hours ago, 0hora said:

using the API I can get history of the roulette rolls?

Yes, you can. I just posted how to do so a few posts above:

On 12/17/2019 at 1:59 AM, skywallkee said:

This should help you with your problem:


query{
  user(name: "username here") {
    houseBetList(limit: 50, offset: 0, game:roulette) {
      id
      iid
      bet {
        ... on CasinoBet {
          game
          payout
          amountMultiplier
          payoutMultiplier
          amount
          currency
          createdAt
        }
      }
    }
  }
}

You can replace roulette with any enum from the game list (dice, limbo, hilo, keno, mines, plinko, blackjack, roulette, slots, wheel, diamondPoker, baccarat, crash, videoPoker)

You can also find this on the first post @Dan did, excepting the "filtering" part with the game (but it isn't really that hard to figure out).

If this is not the problem you're looking for, please describe it a little better as this command will give you the last 50 bets in your roulette history. As I remember, the limit is 500, for more you have to use the archive.

Link to post
Share on other sites

I managed to get a list of my last sport bets, albeit with not much info

{
  user(name: "cryptonesiac") {
    houseBetList(limit: 50, offset: 0) {
      id
      iid
      bet {
        ... on SportBet {
          payout
          amount
          currency
          createdAt
        }
      }
    }
  }
}

result looks like:

{
  "data": {
    "user": {
      "houseBetList": [
        {
          "id": "88f0e3da-7e0a-4597-8a83-92944db4bcc8",
          "iid": "house:13560921362",
          "bet": {}
        },
  • Is there other info to be pulled from this query (final result, payout, etc.)?
  • Is there any info on coming / live games I can get from the API and can I make sport bets through the API?
Link to post
Share on other sites
  • Forum Admin
3 hours ago, ThomasTV2 said:

Hey @Dan Have you ever thought about making a Github page for the documentation? Would be a nice little side project. I might make an unofficial one today if I have the time. Just wanted to know if there was one all ready so I dont waste any time. 

We are in the process of opening the API up again to the public.

Link to post
Share on other sites
2 minutes ago, Dan said:

We are in the process of opening the API up again to the public.

Awesome! Does that me you guys will be doing a proper documentation website ie; docs.stake.com or something like that? 

Also, if you could open a privet message with me since I am not at the level yet that would be great. 

Thanks! 

Link to post
Share on other sites
  • Forum Admin
9 hours ago, cryptonesiac said:

I managed to get a list of my last sport bets, albeit with not much info


{
  user(name: "cryptonesiac") {
    houseBetList(limit: 50, offset: 0) {
      id
      iid
      bet {
        ... on SportBet {
          payout
          amount
          currency
          createdAt
        }
      }
    }
  }
}

result looks like:


{
  "data": {
    "user": {
      "houseBetList": [
        {
          "id": "88f0e3da-7e0a-4597-8a83-92944db4bcc8",
          "iid": "house:13560921362",
          "bet": {}
        },
  • Is there other info to be pulled from this query (final result, payout, etc.)?
  • Is there any info on coming / live games I can get from the API and can I make sport bets through the API?

Sportbet fields

id: String!
status: SportBetStatusEnum!
active: Boolean!
bonus: Boolean!
amount: Float!
currency: CurrencyEnum!
cashoutMultiplier: Float!
payoutMultiplier: Float!
payout: Float!
updatedAt: String!
createdAt: String!
system: Int!
outcomes: [SportBetOutcome!]!
events: [SportBetEvent!]!
user: User

 

35 minutes ago, ThomasTV2 said:

Awesome! Does that me you guys will be doing a proper documentation website ie; docs.stake.com or something like that? 

Also, if you could open a privet message with me since I am not at the level yet that would be great. 

Thanks! 

It will just be a basic graphiql interface.

Link to post
Share on other sites

Hi Dan,

In your example  of  a Bet List Query, I notice result is not listed. Does this mean its not possible to get the bet result from an api query?
 

{ user(name: "Dan") { houseBetList(limit: 50, offset: 0) { id iid bet { ... on CasinoBet { game payout amountMultiplier payoutMultiplier amount currency createdAt } } } }

Link to post
Share on other sites
On 1/9/2020 at 3:46 PM, Seoulmate said:

Does this mean its not possible to get the bet result from an api query?

I'm not @Dan, but yes, it is possible:

query BetList($user: String) {
	user(name: $user) {
		houseBetList(limit: 50, offset: 0) {
			...BetFragment
		}
	}
}

fragment BetFragment on Bet {
	id
	iid
	type
	bet {
		... on CasinoBet {
			...CasinoBetFragment
		}
		... on MultiplayerCrashBet {
			...MultiplayerCrashBetFragment
		}
	}
}

fragment CasinoBetFragment on CasinoBet {
	id
	active
	payoutMultiplier
	amountMultiplier
	amount
	payout
	updatedAt
	currency
	game
	state {
		... on CasinoGameDice {
			...DiceStateFragment
		}
		... on CasinoGameLimbo {
			...LimboStateFragment
		}
		... on CasinoGameHilo {
			...HiloStateFragment
		}
		... on CasinoGameKeno {
			...KenoStateFragment
		}
		... on CasinoGameMines {
			...MinesStateFragment
		}
		... on CasinoGamePlinko {
			...PlinkoStateFragment
		}
		... on CasinoGameBlackjack {
			...BlackjackStateFragment
		}
		... on CasinoGameRoulette {
			...RouletteStateFragment
		}
		... on CasinoGameVideoPoker {
			...VideoPokerStateFragment
		}
		... on CasinoGameWheel {
			...WheelStateFragment
		}
		... on CasinoGameDiamondPoker {
			...DiamondPokerStateFragment
		}
		... on CasinoGameBaccarat {
			...BaccaratStateFragment
		}
		... on CasinoGameSlots {
			...SlotsStateFragment
		}
	}
}

fragment DiceStateFragment on CasinoGameDice {
	dice_result: result
	dice_target: target
	dice_condition: condition
}

fragment LimboStateFragment on CasinoGameLimbo {
	limbo_result: result
	limbo_multiplierTarget: multiplierTarget
}

fragment HiloStateFragment on CasinoGameHilo {
	hilo_startCard: startCard {
		suit
		rank
	}
	hilo_rounds: rounds {
		card {
			suit
			rank
		}
		guess
		payoutMultiplier
	}
}

fragment KenoStateFragment on CasinoGameKeno {
	keno_drawnNumbers: drawnNumbers
	keno_selectedNumbers: selectedNumbers
}

fragment MinesStateFragment on CasinoGameMines {
	mines_mines: mines
	mines_minesCount: minesCount
	mines_rounds: rounds {
		field
		payoutMultiplier
	}
}

fragment PlinkoStateFragment on CasinoGamePlinko {
	plinko_risk: risk
	plinko_rows: rows
	plinko_point: point
	plinko_path: path
}

fragment BlackjackStateFragment on CasinoGameBlackjack {
	blackjack_player: player {
		value
		actions
		cards {
			rank
			suit
		}
	}
	blackjack_dealer: dealer {
		value
		actions
		cards {
			rank
			suit
		}
	}
}

fragment RouletteStateFragment on CasinoGameRoulette {
	roulette_result: result
	roulette_colors: colors {
		amount
		value
	}
	roulette_numbers: numbers {
		amount
		value
	}
	roulette_parities: parities {
		amount
		value
	}
	roulette_ranges: ranges {
		amount
		value
	}
	roulette_rows: rows {
		amount
		value
	}
}

fragment VideoPokerStateFragment on CasinoGameVideoPoker {
	videopoker_playerHand: playerHand {
		suit
		rank
	}
	videopoker_initialHand: initialHand {
		suit
		rank
	}
	videopoker_handResult: handResult
}

fragment WheelStateFragment on CasinoGameWheel {
	wheel_result: result
	wheel_segments: segments
	wheel_risk: risk
}

fragment DiamondPokerStateFragment on CasinoGameDiamondPoker {
	diamondpoker_dealerHand: dealerHand
	diamondpoker_playerHand: playerHand
}

fragment BaccaratStateFragment on CasinoGameBaccarat {
	baccarat_playerCards: playerCards {
		suit
		rank
	}
	baccarat_bankerCards: bankerCards {
		suit
		rank
	}
	baccarat_tie: tie
	baccarat_player: player
	baccarat_banker: banker
	baccarat_result: result
}

fragment SlotsStateFragment on CasinoGameSlots {
	slots_lines: lines
	slots_rounds: rounds {
		offsets
		paylines {
			payline
			hits
			multiplier
			symbol
		}
		scatterMultiplier
		roundMultiplier
		totalMultiplier
		bonusRemaining
		bonusTotal
	}
}

fragment MultiplayerCrashBetFragment on MultiplayerCrashBet {
	id
	user {
		id
		name
	}
	payoutMultiplier
	gameId
	amount
	payout
	currency
	result
	updatedAt
	cashoutAt
	btcAmount: amount(currency: btc)
	ethAmount: amount(currency: eth)
	ltcAmount: amount(currency: ltc)
	bchAmount: amount(currency: bch)
	dogeAmount: amount(currency: doge)
	trxAmount: amount(currency: trx)
	xrpAmount: amount(currency: xrp)
}

 

Link to post
Share on other sites
On 1/10/2020 at 11:08 PM, toohoola said:

I'm not @Dan, but yes, it is possible:


query BetList($user: String) {
	user(name: $user) {
		houseBetList(limit: 50, offset: 0) {
			...BetFragment
		}
	}
}

fragment BetFragment on Bet {
	id
	iid
	type
	bet {
		... on CasinoBet {
			...CasinoBetFragment
		}
		... on MultiplayerCrashBet {
			...MultiplayerCrashBetFragment
		}
	}
}

fragment CasinoBetFragment on CasinoBet {
	id
	active
	payoutMultiplier
	amountMultiplier
	amount
	payout
	updatedAt
	currency
	game
	state {
		... on CasinoGameDice {
			...DiceStateFragment
		}
		... on CasinoGameLimbo {
			...LimboStateFragment
		}
		... on CasinoGameHilo {
			...HiloStateFragment
		}
		... on CasinoGameKeno {
			...KenoStateFragment
		}
		... on CasinoGameMines {
			...MinesStateFragment
		}
		... on CasinoGamePlinko {
			...PlinkoStateFragment
		}
		... on CasinoGameBlackjack {
			...BlackjackStateFragment
		}
		... on CasinoGameRoulette {
			...RouletteStateFragment
		}
		... on CasinoGameVideoPoker {
			...VideoPokerStateFragment
		}
		... on CasinoGameWheel {
			...WheelStateFragment
		}
		... on CasinoGameDiamondPoker {
			...DiamondPokerStateFragment
		}
		... on CasinoGameBaccarat {
			...BaccaratStateFragment
		}
		... on CasinoGameSlots {
			...SlotsStateFragment
		}
	}
}

fragment DiceStateFragment on CasinoGameDice {
	dice_result: result
	dice_target: target
	dice_condition: condition
}

fragment LimboStateFragment on CasinoGameLimbo {
	limbo_result: result
	limbo_multiplierTarget: multiplierTarget
}

fragment HiloStateFragment on CasinoGameHilo {
	hilo_startCard: startCard {
		suit
		rank
	}
	hilo_rounds: rounds {
		card {
			suit
			rank
		}
		guess
		payoutMultiplier
	}
}

fragment KenoStateFragment on CasinoGameKeno {
	keno_drawnNumbers: drawnNumbers
	keno_selectedNumbers: selectedNumbers
}

fragment MinesStateFragment on CasinoGameMines {
	mines_mines: mines
	mines_minesCount: minesCount
	mines_rounds: rounds {
		field
		payoutMultiplier
	}
}

fragment PlinkoStateFragment on CasinoGamePlinko {
	plinko_risk: risk
	plinko_rows: rows
	plinko_point: point
	plinko_path: path
}

fragment BlackjackStateFragment on CasinoGameBlackjack {
	blackjack_player: player {
		value
		actions
		cards {
			rank
			suit
		}
	}
	blackjack_dealer: dealer {
		value
		actions
		cards {
			rank
			suit
		}
	}
}

fragment RouletteStateFragment on CasinoGameRoulette {
	roulette_result: result
	roulette_colors: colors {
		amount
		value
	}
	roulette_numbers: numbers {
		amount
		value
	}
	roulette_parities: parities {
		amount
		value
	}
	roulette_ranges: ranges {
		amount
		value
	}
	roulette_rows: rows {
		amount
		value
	}
}

fragment VideoPokerStateFragment on CasinoGameVideoPoker {
	videopoker_playerHand: playerHand {
		suit
		rank
	}
	videopoker_initialHand: initialHand {
		suit
		rank
	}
	videopoker_handResult: handResult
}

fragment WheelStateFragment on CasinoGameWheel {
	wheel_result: result
	wheel_segments: segments
	wheel_risk: risk
}

fragment DiamondPokerStateFragment on CasinoGameDiamondPoker {
	diamondpoker_dealerHand: dealerHand
	diamondpoker_playerHand: playerHand
}

fragment BaccaratStateFragment on CasinoGameBaccarat {
	baccarat_playerCards: playerCards {
		suit
		rank
	}
	baccarat_bankerCards: bankerCards {
		suit
		rank
	}
	baccarat_tie: tie
	baccarat_player: player
	baccarat_banker: banker
	baccarat_result: result
}

fragment SlotsStateFragment on CasinoGameSlots {
	slots_lines: lines
	slots_rounds: rounds {
		offsets
		paylines {
			payline
			hits
			multiplier
			symbol
		}
		scatterMultiplier
		roundMultiplier
		totalMultiplier
		bonusRemaining
		bonusTotal
	}
}

fragment MultiplayerCrashBetFragment on MultiplayerCrashBet {
	id
	user {
		id
		name
	}
	payoutMultiplier
	gameId
	amount
	payout
	currency
	result
	updatedAt
	cashoutAt
	btcAmount: amount(currency: btc)
	ethAmount: amount(currency: eth)
	ltcAmount: amount(currency: ltc)
	bchAmount: amount(currency: bch)
	dogeAmount: amount(currency: doge)
	trxAmount: amount(currency: trx)
	xrpAmount: amount(currency: xrp)
}

 

Holy shit thats a lot of code just to get the bet result. Thanks very much for your help man.

 

Link to post
Share on other sites
  • Forum Admin
On 1/13/2020 at 12:42 AM, Seoulmate said:

Holy shit thats a lot of code just to get the bet result. Thanks very much for your help man.

 

The result for a bet is inside the state { ...fragment } demonstrated in tahoola's example.

For dice games it would be:

query BetList($user: String) {
  user(name: $user) {
    houseBetList(limit: 50, offset: 0) {
      ...BetFragment
    }
  }
}

fragment BetFragment on Bet {
  id
  iid
  type
  bet {
    ... on CasinoBet {
      ...CasinoBetFragment
    }
  }
}

fragment CasinoBetFragment on CasinoBet {
  id
  active
  payoutMultiplier
  amountMultiplier
  amount
  payout
  updatedAt
  currency
  game
  state {
    ... on CasinoGameDice {
      ...DiceStateFragment
    }
  }
}

fragment DiceStateFragment on CasinoGameDice {
  result
  target
  condition
}

 

Link to post
Share on other sites
2 hours ago, paddyspub said:

@Dan can you pls provide me an example for a direct message check.

You can check the latest direct messages with this:

query ChatList($offset: Int = 0, $limit: Int = 10) {
	user {
		id
		name
		chatList(limit: $limit, offset: $offset) @connection(key: "ChatList") {
			...ChatFragment
			lastMessage {
				...MessageFragment
			}
		}
	}
}

Direct messages with a specific user:

query MessageList($userId: String) {
	chat(userId: $userId) {
		...ChatFragment messageList(limit: 30, offset: 0) {
			...MessageFragment
		}
	}
}

You can use this subscription, if you want to process the messages you receive as soon as you possible:

subscription MessengesSubscription {
	messages {
		chat {
			id
			members {
				user {
					id
					name
				}
			}
		}
		...MessageFragment
	}
}

Finally, some fragments you might need:

fragment ChatFragment on Chat {
	id
	updatedAt
	members {
		user {
			id
			name
		}
	}
}

fragment MessageFragment on ChatMessage {
	id
	data {
		... on ChatMessageDataText { message }
	}
	createdAt
	user {
		id
		name
	}
}

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...