Skip to content

Instantly share code, notes, and snippets.

@WindClan
Last active May 2, 2025 19:29
Show Gist options
  • Select an option

  • Save WindClan/97861c7d6b37b86e2685ac961024739a to your computer and use it in GitHub Desktop.

Select an option

Save WindClan/97861c7d6b37b86e2685ac961024739a to your computer and use it in GitHub Desktop.
whatbeatsrock automation api (severely outdated)
import requests
import json
import uuid
url = "https://www.whatbeatsrock.com/api/vs"
previous = "rock"
headers = {
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, br, zstd',
'Accept-Language': 'en-US,en;q=0.5',
'Content-Type': 'application/json',
'Origin': 'https://www.whatbeatsrock.com/',
'Host': 'www.whatbeatsrock.com',
'Referer': 'https://www.whatbeatsrock.com/',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0'
}
#gameId = str(uuid.uuid4())
def submitGuess(gameId,guess):
global previous
dataJson = {
'gid': gameId,
'guess': guess,
'prev': previous
}
x = requests.post(url, json = dataJson,headers=headers)
resp = json.loads(x.text)
try:
if resp["data"]:
dat = resp["data"]
if dat["guess_wins"]:
previous = guess
else:
previous = "rock"
return dat["guess_wins"], dat["reason"], dat["cached"], dat["cache_count"], dat["guess_emoji"]
except:
err = resp["error"]:lower()
if err = "chill":
print("Rate limit exceeded!")
else:
#if err = "gonna":
# print("Something about your activity alerted the website that this isnt website traffic")
#else:
# print("Error code: "+err)
print("Error code: "+err)
@WindClan
Copy link
Author

WindClan commented May 2, 2025

this was written on python 3.12 plus thats to be expected, this was made when the game first came out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment