iznotsu Posted September 28, 2024 #1 Posted September 28, 2024 Hello! Im trying to get access to the stake API in python but can't reach any request im always getting the 403 error here is my code : import requests import json def stake_api_request(query): url = 'https://stake.com/_api/graphql' headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0", 'cookie': '__cf_bm=XXXXX; cf_clearance=XXXXX', 'Origin': 'https://stake.com/', 'x-access-token': 'XXXXX', 'content-type': 'application/json' } payload = { "query": query } try: response = requests.post(url, headers=headers, json=payload) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: print(f"ERROR : {e}") return None if __name__ == "__main__": sample_query = """ query { user { } } """ result = stake_api_request(sample_query) if result: print(json.dumps(result, indent=2)) else: print("ERROR") Anyone of you did know how to fix that ? Thanks !
daveyj Posted September 28, 2024 #2 Posted September 28, 2024 Can you post your full query? It has to be for yourself you can't query other users
MrArthur Posted September 29, 2024 #3 Posted September 29, 2024 Just copy request from browsers inspect element > network. Thats how you will have all required headers and etc..
Featured Comment
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 accountSign in
Already have an account? Sign in here.
Sign In Now