Bitcoin Forum
July 10, 2025, 04:48:08 AM *
News: Latest Bitcoin Core release: 29.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Stake API  (Read 69 times)
seoincorporation (OP)
Legendary
*
Offline Offline

Activity: 3570
Merit: 3285


View Profile
May 28, 2025, 01:48:26 AM
 #1

Some days ago i found the API section on stake: https://stake.com/settings/api

And i try to make a bot to place bet with it, but looks like the API doesn't work that way, when i try my betting bot i get an error, but i think the problem wasn't the bot, the problem was that stake doesn't let us bet with the API.

So, i would like to know if someone here has used that API in the past and what implementations have the community done with that API. I will share my code even if it doesn't work, at least some users could have an idea about how the API is supposed to work. And is important to mention that stake doesn't provide any documentation for this API.

Code:
import requests
import time

API_URL = "https://api.stake.com/graphql"
API_TOKEN = "MyToken"

def place_dice_bet(amount, chance):
    query = """
    mutation placeBet($input: PlaceBetInput!) {
      placeBet(input: $input) {
        bet {
          id
          amount
          payout
          win
          profit
          roll
        }
      }
    }
    """
    variables = {
        "input": {
            "amount": amount,
            "game": "dice",
            "chance": chance,
            "multiplier": round((100 / chance), 4),
            "clientSeed": "seed123",  # Opcional, para fairness
            "currency": "BTC"
        }
    }

    headers = {
        "Authorization": f"Bearer {API_TOKEN}",
        "Content-Type": "application/json"
    }

    response = requests.post(API_URL, json={"query": query, "variables": variables}, headers=headers)

    if response.status_code == 200:
        data = response.json()
        if "errors" in data:
            print("Error en la apuesta:", data["errors"])
            return None
        bet_info = data["data"]["placeBet"]["bet"]
        return bet_info
    else:
        print(f"Error HTTP: {response.status_code} - {response.text}")
        return None

if __name__ == "__main__":
    amount = 0.00001  # apuesta en BTC
    chance = 50       # probabilidad en %

    bet_result = place_dice_bet(amount, chance)
    if bet_result:
        print("Apuesta realizada:")
        print(f"ID: {bet_result['id']}")
        print(f"Monto apostado: {bet_result['amount']} BTC")
        print(f"Roll: {bet_result['roll']}")
        print(f"Ganó: {'Sí' if bet_result['win'] else 'No'}")
        print(f"Ganancia/Perdida: {bet_result['profit']} BTC")
seuntjie
Legendary
*
Offline Offline

Activity: 1726
Merit: 1127



View Profile WWW
July 06, 2025, 01:45:14 PM
Merited by yahoo62278 (1)
 #2

Stake has cloudflare protection across all of their endpoints and you need find a way to bypass it. It used to be as (relatively) simple as getting a valid cf_clearance cookie and passing that along with your request, but they've gotten a lot more snazzy with their requirements. You can take a look at Gambler.Bots usage of the stake api in the bots' source code on github, but it won't mean much unless you can bypass CF.

Fivestar4everMVP
Legendary
*
Online Online

Activity: 2688
Merit: 1115


Leading Crypto Sports Betting & Casino Platform


View Profile
July 06, 2025, 07:57:05 PM
 #3

Some days ago i found the API section on stake: https://stake.com/settings/api

And i try to make a bot to place bet with it, but looks like the API doesn't work that way, when i try my betting bot i get an error, but i think the problem wasn't the bot, the problem was that stake doesn't let us bet with the API.

So, i would like to know if someone here has used that API in the past and what implementations have the community done with that API. I will share my code even if it doesn't work, at least some users could have an idea about how the API is supposed to work. And is important to mention that stake doesn't provide any documentation for this API.

I don't know much about codes or how to even read them, but I think what seuntjie said makes absolute sense to me, from what I am seeing or assume, I think contacting a stake customer representative would likely be the best thing to do, as they are the ones in the best position to tell you if it was possible to bet on stake through your bot utilizing the Stake's API.

If this is possible to do, then maybe they can also tell you how to easily bypass the Cloudflare which is blocking the bot access to the casino and from successfully placing a bet.
But on the other hand, this is also if all of this is not against the casinos terms and conditions anyway.

..Stake.com..   ▄████████████████████████████████████▄
   ██ ▄▄▄▄▄▄▄▄▄▄            ▄▄▄▄▄▄▄▄▄▄ ██  ▄████▄
   ██ ▀▀▀▀▀▀▀▀▀▀ ██████████ ▀▀▀▀▀▀▀▀▀▀ ██  ██████
   ██ ██████████ ██      ██ ██████████ ██   ▀██▀
   ██ ██      ██ ██████  ██ ██      ██ ██    ██
   ██ ██████  ██ █████  ███ ██████  ██ ████▄ ██
   ██ █████  ███ ████  ████ █████  ███ ████████
   ██ ████  ████ ██████████ ████  ████ ████▀
   ██ ██████████ ▄▄▄▄▄▄▄▄▄▄ ██████████ ██
   ██            ▀▀▀▀▀▀▀▀▀▀            ██ 
   ▀█████████▀ ▄████████████▄ ▀█████████▀
  ▄▄▄▄▄▄▄▄▄▄▄▄███  ██  ██  ███▄▄▄▄▄▄▄▄▄▄▄▄
 ██████████████████████████████████████████
▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄
█  ▄▀▄             █▀▀█▀▄▄
█  █▀█             █  ▐  ▐▌
█       ▄██▄       █  ▌  █
█     ▄██████▄     █  ▌ ▐▌
█    ██████████    █ ▐  █
█   ▐██████████▌   █ ▐ ▐▌
█    ▀▀██████▀▀    █ ▌ █
█     ▄▄▄██▄▄▄     █ ▌▐▌
█                  █▐ █
█                  █▐▐▌
█                  █▐█
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀█
▄▄█████████▄▄
▄██▀▀▀▀█████▀▀▀▀██▄
▄█▀       ▐█▌       ▀█▄
██         ▐█▌         ██
████▄     ▄█████▄     ▄████
████████▄███████████▄████████
███▀    █████████████    ▀███
██       ███████████       ██
▀█▄       █████████       ▄█▀
▀█▄    ▄██▀▀▀▀▀▀▀██▄  ▄▄▄█▀
▀███████         ███████▀
▀█████▄       ▄█████▀
▀▀▀███▄▄▄███▀▀▀
..PLAY NOW..
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!