Skip to content

Instantly share code, notes, and snippets.

@scmanjarrez
Last active December 2, 2023 02:01
Show Gist options
  • Save scmanjarrez/78632ca7ab0802ca2df47353b3002627 to your computer and use it in GitHub Desktop.
Save scmanjarrez/78632ca7ab0802ca2df47353b3002627 to your computer and use it in GitHub Desktop.
genshin resin api
import hashlib
import time
import random
import string
import requests as req
salt = "6cqshh5dhw73bzxn20oexa9k516chk7s" # borrowed from https://github.com/thesadru/genshinstats
uid = 12345678 # int
ltoken = "verylargestringtokenxxxxxxxxxxxxxxxxxxx" # str
ltuid = "87654321" # str
def calculate_ds(): # borrowed from https://github.com/thesadru/genshinstats
t = int(time.time())
r = "".join(random.choices(string.ascii_letters, k=6))
h = hashlib.md5(f"salt={salt}&t={t}&r={r}".encode()).hexdigest()
return f"{t},{r},{h}"
USER_AGENT = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36")
headers = {
# required headers
"x-rpc-app_version": "1.5.0",
"x-rpc-client_type": "4",
"x-rpc-language": "en-us",
# authentications headers
"ds": calculate_ds(),
# recommended headers
"user-agent": USER_AGENT
}
resp = req.get(
'https://bbs-api-os.hoyoverse.com/game_record/genshin/api/dailyNote',
params=dict(server='os_euro', role_id=uid, schedule_type=1),
headers=headers,
cookies={'ltuid': ltuid, 'ltoken': ltoken})
print(resp.text)
@lInightshadowIl
Copy link

ahora si me funciona, me faltaba solamente calcular lo del md5, muchas gracias

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