Jump to content

API help needed!


RomainTessier

Featured Comment

Posted

Hello everyone! I'm relatively new in the programming industry and I wanted to mess around a little bit with the Stake API because I'm into gambling. 

I want to know if someone could help me figure out the python script on order to be able to return the live odds of table tennis / pingpong matches. I did not find an answer as how to get live odds for specific event using the API , since there is absolutely no documentation. If someone could help me out, would be very helpful:)

 

Thank you

  • 4 weeks later...
  • 3 weeks later...
Posted

Stake API is very powerful and we are a lot using it.

You don't need any documentation to use, it, just look at the request made by your browser (F12-> Dev options).

You will see graphql requests, you can use them to do anything you do in real, like get balance, get live matches, place a bet, play dice, BJ,...

I use it everyday, in the graphql request you can see the payload, just send this to the endpoint that your browser use, usually https://stake.com/_api/graphql

my generic function look like this:

 

        res = session.post(

        "https://stake.com/_api/graphql",

        headers={"x-access-token": api_key,},json={"query": query,"variables":variables})
        response_data = res.json()
        return response_data 

 

where query is your query, for example to retrieve balance:

query = "query StakeBalances($available: Boolean = true, $vault: Boolean = false) {\r\n  user {\r\n    id\r\n    balances {\r\n      available @include(if: $available) {\r\n        currency\r\n        amount\r\n        __typename\r\n      }\r\n      vault @include(if: $vault) {\r\n        currency\r\n        amount\r\n        __typename\r\n      }\r\n      __typename\r\n    }\r\n    __typename\r\n  }\r\n}";

 

you can adapt this as you need, of course. 

variables is used for some requests, if you need to send data, like which sports,...for balances just send "{}"

 

 

  • 3 weeks later...
Posted

Could anybody provide a working example in Python? - Thank you!

This below is not working for me.
____

# START

import requests

API_KEY = <HERE COMES MY STAKE API KEY>
__cf_bm = <HERE COMES THIS COOKIE>
url = "https://stake.com/_api/graphql"
myObj = { "query": {}, "variables": {} }
headers = { "X-Access-Token": API_KEY, "__cf_bm": __cf_bm }

def stake(): 
       res = requests.post(url = url, headers = headers, json = myObj)
       data = res.json()
       print(data)

stake()

# END

  • 1 month later...
Posted
On 03/03/2024 at 11:54, reallyLucky said:

Alguém poderia fornecer um exemplo prático em Python? - Obrigado!

Isso abaixo não está funcionando para mim.
____

# INICIAR

solicitações de importação

API_KEY = <AQUI VEM MINHA CHAVE DE API STAKE>
__cf_bm = <AQUI VEM ESTE COOKIE>
url = "https://stake.com/_api/graphql"
myObj = { "query": {}, "variáveis ": {} }
cabeçalhos = { "X-Access-Token": API_KEY, "__cf_bm": __cf_bm }

def stake(): 
       res = requests.post(url = url, headers = headers, json = myObj)
       data = res.json()
       print(data)

aposta()

# FIM

Create a session using the tls_client library (install it using pip install)

Use this session to make post requests. No need to include cf_clearance in the request

  • 4 months later...
Posted
22 minutes ago, ErRubio said:

Good afternoon,

I am trying to launch a request with HttpClientInterface symfony PHP with API token and I always get a 403 error and the response is an HTML with the text just a moment. Could someone pass a working example of any request that accesses stake.

Thanks for everything.

 

On 2/15/2024 at 4:30 PM, Blackshires said:

Stake API is very powerful and we are a lot using it.

You don't need any documentation to use, it, just look at the request made by your browser (F12-> Dev options).

You will see graphql requests, you can use them to do anything you do in real, like get balance, get live matches, place a bet, play dice, BJ,...

I use it everyday, in the graphql request you can see the payload, just send this to the endpoint that your browser use, usually https://stake.com/_api/graphql

my generic function look like this:

 

        res = session.post(

        "https://stake.com/_api/graphql",

        headers={"x-access-token": api_key,},json={"query": query,"variables":variables})
        response_data = res.json()
        return response_data 

 

where query is your query, for example to retrieve balance:

query = "query StakeBalances($available: Boolean = true, $vault: Boolean = false) {\r\n  user {\r\n    id\r\n    balances {\r\n      available @include(if: $available) {\r\n        currency\r\n        amount\r\n        __typename\r\n      }\r\n      vault @include(if: $vault) {\r\n        currency\r\n        amount\r\n        __typename\r\n      }\r\n      __typename\r\n    }\r\n    __typename\r\n  }\r\n}";

 

you can adapt this as you need, of course. 

variables is used for some requests, if you need to send data, like which sports,...for balances just send "{}"

 

 

 

Posted

Hey @ErRubio, I am seeing the same. I tried with code in JS and Python, and in every case, the same error. I suspect based on the returned HTML that it is a Cloudflare thing that is preventing us from making the API call, but I am not sure if it is because we are making a wrong call or some other thing.

 

If anyone can provide a full working example (and recent) in any language, that would help a lot. 

 

Thanks in advance!

 

Posted

API_KEY = <HERE COMES MY STAKE API KEY>
__cf_bm = <HERE COMES THIS COOKIE>
url = "https://stake.com/_api/graphql"
myObj = { "query": {}, "variables": {} }
headers = { "X-Access-Token": API_KEY, "__cf_bm": __cf_bm }

def stake(): 
       res = requests.post(url = url, headers = headers, json = myObj)
       data = res.json()
       print(data)


this mate try now

  • 2 weeks later...
Posted

I have managed to get an http 200 OK, but the problem is that when doing the getContent() of the response. I get the following error.

Idle timeout reached for "https://stake.com/_api/graphql"

  • 4 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

Privacy Policy Terms of Use