Skip to content

Instantly share code, notes, and snippets.

@jogerj
Last active September 2, 2024 16:57
Show Gist options
  • Save jogerj/0339e61a92e0de2e360c5212a94854e8 to your computer and use it in GitHub Desktop.
Save jogerj/0339e61a92e0de2e360c5212a94854e8 to your computer and use it in GitHub Desktop.
Get Wish History URL in Genshin Impact on PC from cache. Moved to https://github.com/jogerj/genshin-wish-url

genshin-wish-url

Further development has been moved to its own repository: https://github.com/jogerj/genshin-wish-url

Usage

  1. Win+R and open powershell (or pwsh if Powershell 6+ installed)
  2. Paste and run following
  • All versions (Global/China)
Set-ExecutionPolicy Bypass -Scope CurrentUser -Force;
iex (irm 'https://github.com/jogerj/genshin-wish-url/raw/main/Get-WishUrl.ps1')
# This is for legacy compatibility to redirect old URL to the new script
# Please use script from https://github.com/jogerj/genshin-wish-url
iex (irm 'https://github.com/jogerj/genshin-wish-url/raw/main/Get-WishUrl.ps1')
@KitKit0w
Copy link

I'm getting this error even though history page is open in-game...
Link found but it is expired/invalid! Open Wish History again to fetch a new link
No valid link found! Make sure Genshin Impact is installed and open Wish History page at least once.
Press Enter to continue...:

@jogerj
Copy link
Author

jogerj commented Jan 29, 2024

@KitKit0w delete the webCaches folder inside GenshinImpact_Data folder. Then reopen wish history and retry.

@KitKit0w
Copy link

Thank you so much, it works now!

@RedContritio
Copy link

RedContritio commented Apr 24, 2024

I use this script today to get history of version 4.6, but it returns nothing, I use devTools and the request as following:

request url ( 200 OK):

https://public-operation-hk4e.mihoyo.com/gacha_info/api/getGachaLog?win_mode=fullscreen&authkey_ver=1&sign_type=2&auth_appid=webview_gacha&init_type=301&gacha_id=24bada4a726757897b03172565dc46980147074a&timestamp=1713916142&lang=zh-cn&device_type=pc&game_version=CNRELWin4.6.0_R22608561_S22543584_D22626513&region=cn_gf01&authkey=<hidden_long_key>&game_biz=hk4e_cn

response:

{
    "retcode": 0,
    "message": "OK",
    "data": {
        "page": "0",
        "size": "6",
        "total": "0",
        "list": [],
        "region": "cn_gf01"
    }
}

after captured packet, the correct format will be

https://public-operation-hk4e.mihoyo.com/gacha_info/api/getGachaLog?win_mode=fullscreen&authkey_ver=1&sign_type=2&auth_appid=webview_gacha&init_type=301&gacha_id=24bada4a726757897b03172565dc46980147074a&timestamp=1713916142&lang=zh-cn&device_type=pc&game_version=CNRELWin4.6.0_R22608561_S22543584_D22626513&region=cn_gf01&authkey=<hidden_long_key>&game_biz=hk4e_cn&gacha_type=301&page=1&size=5&end_id=0

I think the import keys changed will be page, size, end_id, region

@jogerj
Copy link
Author

jogerj commented Apr 24, 2024

@RedContritio not an issue as long as response is 200 OK, means the authKey is valid and not expired. As for other query parameters depends on application (e.g. paimon.moe) utilizing the URL to query the wish itself.

@RedContritio
Copy link

@RedContritio not an issue as long as response is 200 OK, means the authKey is valid and not expired. As for other query parameters depends on application (e.g. paimon.moe) utilizing the URL to query the wish itself.

Thank you, you are right.
sorry for bother you, again. 🫡

@DiaborMagics2
Copy link

Is this what is also used on genshin.hotgames? It looks the same. The problem I'm having this time (while up to december when I last updated I could update just fine) is I'm getting an error all day when I paste the result in the site.

hoyoverse api error (undefined). Unexpected error. Maybe Genshin changed something. Maybe servers are overloaded.
Please try again later.

I've tried like 5 times today, but the result is the same every time. Any ideas on if it's something other than full servers?

@jogerj
Copy link
Author

jogerj commented Jun 24, 2024

@DiaborMagics2 Yes. I've checked and they are hosting the script version for Genshin pre-4.6. Hoyoverse did change their APIs, while the old ones still worked (for some time) they might have deprecated it at this point.

@DiaborMagics2
Copy link

Oh I see. So I should probably wait for hotgames to update then? Or can I just run your command and paste that result instead?

@jogerj
Copy link
Author

jogerj commented Jun 24, 2024

@DiaborMagics2 yes, should work.

@DiaborMagics2
Copy link

@DiaborMagics2 yes, should work.

Awesome thank you so much! Will try soon.

@DiaborMagics2
Copy link

Unfortunately it gives me the same error.

@jogerj
Copy link
Author

jogerj commented Jun 25, 2024

@DiaborMagics2 write me here. Some known issues involve having the game path containing unicode characters (non-latin characters), too old powershell/OS, or DNS errors (try ipconfig /flushdns then ipconfig /renew). Can't really tell without having a full output

@DiaborMagics2
Copy link

I figured it out, I guess. Nothing wrong on my end. the ipconfig commands also changed nothing.
However, I tried it on paimon.moe instead of hotgames.gg and there it worked. So I think its on hotgames' end. I can at least continue keeping track now. Many thanks!
Just a shame I now have to switch sites and don't have all the data in one place, but it is what it is.

@jogerj
Copy link
Author

jogerj commented Jun 25, 2024

@DiaborMagics2 the script will only return a valid wish URL, it'll prompt an error otherwise when a link is not found or expired (for sample output, run the script some 24 hours after you last checked wish history). Any other error would be an error on whatever tool/website is used to track your wishes.

@ArberSupremo
Copy link

ArberSupremo commented Jun 26, 2024

@jogerj I think Hotgames.gg still uses 6 months wish history, does a script that makes you extract only 6 months instead of 1 year of wish history exist?

@jogerj
Copy link
Author

jogerj commented Jun 26, 2024

@ArberSupremo Doesn't matter, same wish url. The url is used to fetch the data and scrolls through the pages until earliest wish is loaded. In normal circumstances, if existing data for wishes up to the last imported wish is already loaded, there should not be no new wishes appearing before that point, so the script stops scrolling further. The extension from 6 to 12 months of wish history is a one time exception that breaks this rule.

In paimon.moe you'd solve this by force import (which ignores existing wish data)

@jogerj
Copy link
Author

jogerj commented Aug 31, 2024

Hello, this repository has been moved to https://github.com/jogerj/genshin-wish-url for ease of issue reporting and tracking changes. Please use the script directly from the linked repo. Thank you :)

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