PHPackages                             newngapi/ngapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. newngapi/ngapi

ActiveLibrary[API Development](/categories/api)

newngapi/ngapi
==============

A PHP SDK for integrating with the NG gaming platform API. This SDK provides a simple and efficient way to interact with the NG gaming platform's API services.

v1.0.0(1y ago)1181MITPHPPHP &gt;=7.0

Since Apr 15Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/newngapi/ngapi)[ Packagist](https://packagist.org/packages/newngapi/ngapi)[ Docs](https://www.neapi.com)[ RSS](/packages/newngapi-ngapi/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

NG API PHP SDK
==============

[](#ng-api-php-sdk)

NG游戏平台API的PHP SDK。此SDK提供了一种简单高效的方式来与NG游戏平台的API服务进行交互。

官方资源
----

[](#官方资源)

- NG官方网站:
- NG文档:
- 联系邮箱:

系统要求
----

[](#系统要求)

- PHP &gt;= 7.0
- Composer
- Guzzle HTTP客户端

安装
--

[](#安装)

```
composer require newngapi/ngapi
```

使用方法
----

[](#使用方法)

```
use Newngapi\Ngapi\Client;

// 初始化客户端
$client = new Client(
    'https://api.example.com', // 基础URL
    'your_sn',                // NG平台的SN
    'your_secret_key'        // NG平台的密钥
);

// 创建玩家
$result = $client->createPlayer('ag', 'player123', 'CNY');

// 获取玩家余额
$balance = $client->getBalance('ag', 'player123', 'CNY');

// 获取游戏URL
$gameUrl = $client->getGameUrl(
    'ag',
    'player123',
    '1',  // 游戏类型: 1=视讯, 2=老虎机, 3=彩票, 4=体育, 5=电竞, 6=捕鱼, 7=棋牌
    'CNY',
    'device1'  // device1=电脑网页版, device2=手机网页版
);

// 资金转账
$transfer = $client->transfer(
    'ag',
    'player123',
    'CNY',
    '100.00',
    '1',  // 1=转入, 2=转出
    'order1234567890123456'  // 可选的订单ID
);
```

开发
--

[](#开发)

### 安装

[](#安装-1)

```
git clone https://github.com/newngapi/ngapi.git
cd ngapi
composer install
```

### 测试

[](#测试)

```
./vendor/bin/phpunit
```

### 代码规范

[](#代码规范)

本项目遵循PSR-4自动加载标准和PSR-12编码风格。

可用方法
----

[](#可用方法)

1. `createPlayer(string $platType, string $playerId, string $currency)` - 创建玩家
2. `getBalance(string $platType, string $playerId, string $currency)` - 获取玩家余额
3. `getAllBalance(string $playerId, string $currency)` - 获取所有平台余额
4. `transferAll(string $playerId, string $currency)` - 全部转账
5. `getGameUrl(string $platType, string $playerId, string $gameType, string $currency, string $ingress, ?string $lang = null, ?string $gameCode = null, ?string $returnUrl = null, ?string $oddsType = null)` - 获取游戏URL
6. `getDemoUrl(string $platType, string $playerId, string $gameType, string $currency, string $ingress, ?string $lang = null, ?string $gameCode = null, ?string $returnUrl = null)` - 获取试玩URL
7. `getRealTimeRecords(string $currency, ?string $pageNo = null, ?string $pageSize = null)` - 获取实时记录
8. `getOrderRecords(string $currency, string $orderIds)` - 获取订单记录
9. `getHistoryRecords(string $currency, string $startTime, string $endTime, ?string $pageNo = null, ?string $pageSize = null)` - 获取历史记录
10. `transfer(string $platType, string $playerId, string $currency, string $amount, string $type, ?string $orderId = null)` - 转账
11. `getTransferStatus(string $playerId, string $currency, string $orderId)` - 获取转账状态
12. `getGameCode(string $platType)` - 获取游戏代码
13. `getQuota()` - 获取配额

错误处理
----

[](#错误处理)

SDK会对无效参数抛出`InvalidArgumentException`异常，并以以下格式返回错误响应：

```
[
    'code' => 10001,  // 错误代码
    'msg' => '错误信息',
    'data' => null
]
```

### 常见错误代码

[](#常见错误代码)

- 10000: 成功
- 10001: 请求错误
- 10002: 玩家ID已存在
- 10003: 玩家ID不存在
- 10004: 玩家ID格式错误
- 10005: 转账错误
- 10006: 金额错误
- 10007: 时间格式错误
- 10008: 返回URL错误
- 10009: 接口请求过于频繁
- 10010: 游戏不支持试玩
- 10011: 订单ID格式错误
- 10012: 订单ID已存在
- 10013: 订单ID不存在
- 10014: 配额不足
- 10015: 商户余额不足
- 10403: IP访问受限
- 10404: 签名验证失败
- 10405: 缺少参数
- 10406: 参数过多
- 10407: 平台代码错误
- 10408: 游戏类型错误
- 10409: 转账类型错误

游戏类型说明
------

[](#游戏类型说明)

- 1: 视讯游戏
- 2: 老虎机游戏
- 3: 彩票游戏
- 4: 体育博彩
- 5: 电子竞技
- 6: 捕鱼游戏
- 7: 棋牌游戏

设备类型说明
------

[](#设备类型说明)

- device1: 电脑网页版
- device2: 手机网页版

转账类型说明
------

[](#转账类型说明)

- 1: 转入（从平台转入游戏）
- 2: 转出（从游戏转出到平台）

技术支持
----

[](#技术支持)

如需技术支持或有疑问，请联系：

- 邮箱:
- 文档:

贡献
--

[](#贡献)

1. Fork本仓库
2. 创建您的功能分支 (`git checkout -b feature/amazing-feature`)
3. 提交您的更改 (`git commit -m 'Add some amazing feature'`)
4. 推送到分支 (`git push origin feature/amazing-feature`)
5. 开启Pull Request

许可证
---

[](#许可证)

MIT

---

*此文档为中文版本，如需查看英文版本请访问 [README.en.md](README.en.md)*

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance54

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

398d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f02bd8f1f93bed2f84f4cd33bf2bbf695338e705f14b7023fe5111f64cbb7ba?d=identicon)[newngapi](/maintainers/newngapi)

---

Top Contributors

[![newngapi](https://avatars.githubusercontent.com/u/97209687?v=4)](https://github.com/newngapi "newngapi (6 commits)")

---

Tags

ngapisdkapisdkREST APIbettingphp-sdkintegrationgamblingcasinogamingNGgame-platformonline-gamingsports-bettinglive-casinoslot-games

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/newngapi-ngapi/health.svg)

```
[![Health](https://phpackages.com/badges/newngapi-ngapi/health.svg)](https://phpackages.com/packages/newngapi-ngapi)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[resend/resend-php

Resend PHP library.

574.7M21](/packages/resend-resend-php)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[leapfu/cloud-printer

高扩展性云小票打印SDK，支持飞鹅云、芯烨云、易联云、快递100、映美云、佳博云、中午云、优声云等主流云打印服务，兼容 Laravel、ThinkPHP 等主流框架，统一API，易集成，易扩展。

104.5k](/packages/leapfu-cloud-printer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
