npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@genshin-kit/core

v2.6.2

Published

An API wrapper for fetching player data of Genshin Impact from any servers.

Downloads

21

Readme

GenshinKit Core 原神开发工具核心包

简体中文 | English

Total alerts Language grade: JavaScript

一个用于获取《原神》任意服务器玩家数据的 API 封装库。

完全使用 TypeScript 编写,API 返回值的全部 typings 均已由作者手动扣出来,现代 IDE 自动显示代码提示,轻松调用无压力!

安装

# Via yarn
yarn add @genshin-kit/core
# Or via npm
npm install @genshin-kit/core

使用

一些完整的示例代码可以点击这里查看。

下面是 GenshinKit 的文档。


主要方法

GenshinKit {class}

GenshinKit 实例。

返回:GenshinKit的应用实例。

const { GenshinKit } = require('genshin-kit')
const App = new GenshinKit()

App.loginWithCookie(cookie: string): this

使用米游社网站的 cookie 登录实例。

⚠️ 注意 ⚠️:请妥善保存您的 cookies。绝对不要把你的 cookies 交给任何人!绝对绝对不要把你的 cookies 交给任何人!!绝对绝对绝对不要把你的 cookies 交给任何人!!!

国服获取方法:使用网页版米游社登录 https://bbs.mihoyo.com/ys/,然后前往 https://bbs.mihoyo.com/,在控制台输入 document.cookie,返回的结果就是 cookie,一般来说一个 cookie 可以使用一段时间,如果失效了就再次获取一遍。

App.loginWithCookie(process.env.MHY_COOKIE)

App.setServerType(type: 'cn' | 'os'): this

设置要查询的 UID 所在的服务器分区。若不设置,预设查询cn(国服)数据。

  • cn 中国服(官服、B 服)
  • os 国际服

App.getUserInfo(uid: number, noCache?: boolean): Promise<UserInfo>

使用 UID 查询玩家的游戏基础信息。

返回:UserInfo

App.getUserInfo(100000001).then(console.log)

App.getAllCharacters(uid: number, noCache?: boolean): Promise<Character[]>

通过 UID 获取玩家详细的角色信息。包括角色的装备情况。

返回:Character[]

App.getSpiralAbyss(uid: number, type?: 1 | 2, noCache?: boolean): Promise<Abyss>

根据 UID 获取“深境螺旋”信息。

type 1 代表当期,2 代表上一期

返回:Abyss

快速查询の糖:App.getCurrentAbyss(<uid:number>): Promise<Abyss> App.getPreviousAbyss(<uid:number>): Promise<Abyss>

App.getActivities(uid: number): Promise<Activities>

通过 UID 获取玩家的“风来人”等限时 raid 战绩。

返回:Activities


辅助工具

const { util } = require('genshin-kit')

util.getTheActivedConstellationsNumberOfSpecifiedGenshinImpactCharacter(character: Character): number 获取角色的命座数

好吧,其实用util.activedConstellations就行了,~~这里巨 TM 长的方法名是作者和朋友探讨这个方法该如何命名时的恶趣味。~~

返回指定角色的命座数量。

util.CharactersFilter(characters: Character[]) {class} 角色筛选工具

一个角色筛选工具类。封装了一系列过滤角色信息的方法。

返回:Filter

const { CharactersFilter } = require('genshin-kit').util
App.getAllCharacters(100000001).then((data) => {
  const Filter = new CharactersFilter(data)
  // ...
}, console.error)

all(): Character[]

获取特定玩家的全部角色列表。

id(id: number): Character | null

获取特定玩家的指定 id 的角色信息。

name(name: string): Character | null

获取特定玩家的指定名称的角色信息。

name:角色名称,建议使用“简体中文”语言中的标准名称。但是同时支持使用别称搜索,详见CharacterNickname

element(element: string): Character[]

获取特定玩家的指定元素的角色信息。

element:可以是中文或者英文,例如pyro都是可以接受的名称。

rarity(rarity: number | number[]): Character[]

获取特定玩家的指定稀有度的角色信息。

rarity:必须是数字或者数字组成的数组,例如45以及[4, 5]

nicknameFilter: CharacterNickname

暴露过滤器使用的CharacterNickname实例。

util.CharacterNickname {class} 角色昵称工具

返回:Nickname

setNicknames(id: number, nicknames: string[]): this

通过角色 ID 添加一批昵称。

getIdByNickname(keyword: string): number | undefined

通过昵称获取角色 ID,可能不存在。

getNicknamesById(id: number): string[] | undefined

通过角色 ID 获取可能的昵称列表,可能不存在。

util.isValidCnUid(uid: any): boolean 国服 uid 验证工具

判断输入值是否为合法的国服 uid。


For communication and learning only.

All game data & pictures from query: ©miHoYo

API endpoint: Refer Azure99/GenshinPlayerQuery (Apache-2.0 License)

Copyright 2021 Genshin-Kit

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0