Some days ago i found the API section on stake:
https://stake.com/settings/apiAnd 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.
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")