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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@newngapi/ngapi-npm

v1.0.0

Published

专为NG游戏平台设计的官方TypeScript SDK,让您能简单、高效地与NG游戏平台的API服务进行集成。

Readme

NG API SDK (TypeScript/JavaScript)

NPM Version NPM Downloads License Build Status

项目概述

NG API SDK 是一个专为 NG 游戏平台设计的官方 TypeScript 开发工具包。它提供了一套完整的、类型安全的接口,帮助开发者快速、安全地集成 NG 游戏平台的各项功能。

主要功能

  • 玩家账户管理 (创建、查询余额)
  • 资金转账 (转入、转出、一键回收)
  • 交易记录查询 (实时、历史、按订单号)
  • 额度查询 (查询商户余额)
  • 游戏 URL 生成 (普通游戏、试玩游戏)
  • 游戏信息查询 (获取游戏代码)

安装

npm install @newngapi/ngapi-npm

或者

yarn add @newngapi/ngapi-npm

快速上手

下面是一个简单的使用示例。我们强烈建议您查看 examples 目录以获取更完整、可直接运行的范例。

import { Client, CurrencyCode } from '@newngapi/ngapi-npm';

// 1. 初始化客户端
// 请将 baseUrl 替换为您的实际 API 地址
// sn 和 secretKey 请联系 NG 获取
const client = new Client({
    baseUrl: 'https://api.ng777.net',
    sn: 'YOUR_SN',
    secretKey: 'YOUR_SECRET_KEY'
});

async function main() {
    try {
        const playerId = 'testuser01';
        const currency: CurrencyCode = 'CNY';

        // 2. 创建玩家
        const createResponse = await client.createPlayer('ag', playerId, currency);
        if (createResponse.code === 10000) {
            console.log(`玩家 ${playerId} 创建成功!`);
        }

        // 3. 查询余额
        const balanceResponse = await client.getBalance('ag', playerId, currency);
        if (balanceResponse.code === 10000) {
            console.log(`玩家 ${playerId} 的余额为:`, balanceResponse.data);
        }

    } catch (error) {
        console.error('请求时发生意外错误:', error);
    }
}

main();

运行官方示例

本项目提供了一个包含所有 SDK 功能的详细示例文件,这是学习和调试 SDK 的最佳方式。

  1. 克隆项目

    git clone https://github.com/newngapi/ngapi-npm.git
    cd ngapi-npm
  2. 安装依赖

    npm install
  3. 配置示例文件 打开 examples/usage.ts 文件,将文件顶部的 config 对象替换为您的真实配置:

    const config = {
      baseUrl: "https://api.ng777.net", // 您的 API 地址
      sn: "YOUR_SN",                   // 您的 sn
      secretKey: "YOUR_SECRET_KEY",    // 您的 secretKey
    };
  4. 安装 ts-node ts-node 是一个可以直接运行 TypeScript 文件的工具。

    npm install -g ts-node
  5. 运行示例

    ts-node examples/usage.ts

    您将在控制台看到每个 API 调用的详细请求路径、参数和返回结果。您可以随意注释掉 main 函数中的某些调用,来单独测试您感兴趣的功能。

本地开发与测试

我们欢迎社区贡献。如果您希望参与开发或在本地进行调试,请遵循以下步骤。

安装依赖

npm install

运行测试

本项目使用 Jest 进行单元测试,确保了代码的质量和稳定性。

# 运行所有测试
npm test

# 生成测试覆盖率报告
npm test -- --coverage

代码风格检查

本项目使用 ESLint 和 Prettier 保证代码风格的一致性。

# 检查代码风格
npm run lint

# 自动修复代码风格问题
npm run lint -- --fix

错误处理

SDK 会在发起 API 请求前进行参数校验,并以与 NG 官方 API 相同的格式返回错误响应。详细的错误码列表请参考 NG 官方文档

{
    "code": 10001, // 错误码, 10000 代表成功
    "msg": "错误信息",
    "data": null
}

官方资源

许可证

本项目基于 MIT 协议开源。