Last active
December 2, 2023 02:01
-
-
Save scmanjarrez/78632ca7ab0802ca2df47353b3002627 to your computer and use it in GitHub Desktop.
genshin resin api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Este código es bastante antiguo, usa https://github.com/thesadru/genshin.py
Este código es bastante antiguo, usa https://github.com/thesadru/genshin.py
solo quería la api para hacer las consultas por que estoy usando javascript, de todas formas gracias
Hola, he revisado el código y me funciona perfectamente, estás calculando bien el ds? Y los parámetros? el uid es un entero, el ltoken es un string muy largo, y el ltuid es otro entero pero pasado como un string.
He actualizado el código eliminando librerías externas para que puedas implementarlo en js, sólo necesitas una librería que calcule md5.
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
👍