Client
Client contains all routes, and you could login with the ltoken and ltuid.
const client = new Client();
client.login("LTUID", "LTOKEN");
Routes
To send a request to the API you could use the following methods:
await client.<route>.<method>(<params>);
💡
You wouldn't have to pass the ltoken and ltuid every time you want to send a request when using client.
Cache Sweeper
Client has built-in cache sweeper that would clear the cache every minute. You could customize the sweeper.
Custom Cache Sweeper
const client = new Client({
cacheOptions: {
maxAge: 60, // the cache will be deleted after 60 seconds
maxSize: 0, // it wouldn't cache anythings
},
});
More information about caching can be found here.
Cookies Manager
Client could using cookies manager for multiple cookies.
const { Client } = require("genshin-kit.js");
// import { Client } from "genshin-kit.js"; (if you use typescript)
const client = new Client();
client.addCookies([{ ltoken: "LTOKEN", ltuid: "LTUID" }, {}, {}, {}]);
More information about cookies can be found here.