Skip to main content

Get Started

Prerequisites

Installation

$ npm install hoyoapi
$ yarn add hoyoapi
  1. To begin, login with your HoYoLab account or from Genshin Battlepass.
  2. Type java in the address bar followed by the script down below.
  3. script: (function() {
    if (document.cookie.includes('ltoken') && document.cookie.includes('ltuid')) {
    const input = document.createElement('input');
    input.value = document.cookie;
    document.body.appendChild(input);
    input.focus();
    input.select();
    var result = document.execCommand('copy');
    document.body.removeChild(input);
    if (result) {
    alert('HoYoLAB cookie copied to clipboard');
    } else {
    prompt('Failed to copy cookie. Manually copy the cookie below:\n\n', input.value);
    }
    } else {
    alert('Please logout and log back in. Cookie is expired/invalid!');
    }
    })();
  4. Once you've successfully ran the script, click the Click here to copy! button to copy the cookie.
  5. Finally, you can copy your cookie