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)
@mathayay
Copy link

Hello ! Thank you for this code, it really helps me with my side project. Just a question, I'm having an error "never" that seems to happen after 3 rounds of a game, do you know what it means ? Thank you !

@WindClan
Copy link
Author

The errors on the site are very cryptic on purpose. They only happen if you are detected as a bot. They spell out "Never gonna give you up"
Maybe you repeated a guess

@joshuajohncohen
Copy link

Do you know about submitting scores? I tried to implement similar code but i get {"error": "yawn"}

@qtqgyt
Copy link

qtqgyt commented May 2, 2025

Script is not updated for python 3.12 along with doesnt work anymore due to cloudflare.

@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