Skip to content

Releases

v1.3.0 — 新增 Java SDK

Choose a tag to compare

@hujuncheng-ddd hujuncheng-ddd released this 15 Oct 07:17

☕ v1.3.0 —— 新增 Java SDK

在 PHP / Python / Node.js / Go 基础上,新增 Java 官方 SDK,五个 SDK 的 API 完全对齐,均已通过线上接口实测(含错误路径负测试)。

安装(JitPack)

pom.xml 添加仓库与依赖:

<repository><id>jitpack.io</id><url>https://jitpack.io</url></repository>

<dependency>
    <groupId>com.github.hujuncheng-ddd.gold-api-cn</groupId>
    <artifactId>gold-api-sdk</artifactId>
    <version>1.3.0</version>
</dependency>

要求:Java ≥ 8,零第三方依赖(HttpURLConnection + 内置极简 JSON 解析器),客户端线程安全可全局复用。

快速开始

GoldApiClient client = new GoldApiClient("gk_your_appkey");

Map<String, Quote> quotes = client.realtime("1051", "1061", "hf_GC");  // 黄金T+D + 黄金现货 + 纽约金

for (Quote q : quotes.values()) {
    System.out.println(q.getVarietyName() + " " + q.getLastPrice() + "(" + q.getChangeMargin() + ")");
}

能力一览(与其他语言 SDK 对齐)

能力 方法
批量实时行情(单次 ≤ 50 品种,每品种 11 字段) realtime()
单品种快捷查询 realtimeOne()
品种列表(免认证) varieties()
配额 / 限流感知 getLastRateLimit() / getLastRequestId()
异常(msgId / requestId / httpCode + 限流判断) GoldApiException + isRateLimit()

变更清单

  • ✨ 新增 java/:GoldApiClient / Quote / Variety / RateLimit / GoldApiException,X-API-KEY 请求头认证
  • ✨ 根目录新增聚合 pom.xml(JitPack 多模块构建入口,不影响其他语言 SDK)
  • 📖 README 升级为五语言门户(PHP / Python / Node.js / Go / Java)

链接

v1.2.0 — 新增 Go SDK

Choose a tag to compare

@hujuncheng-ddd hujuncheng-ddd released this 15 Oct 06:57

🚀 v1.2.0 —— 新增 Go SDK

在 PHP / Python / Node.js 基础上,新增 Go 官方 SDK,四个 SDK 的 API 完全对齐,均已通过线上接口实测(含错误路径负测试)。

安装

go get github.com/hujuncheng-ddd/gold-api-cn/go

要求:Go ≥ 1.21,零第三方依赖(标准库 net/http 实现),客户端并发安全。

快速开始

client := goldapi.NewClient("gk_your_appkey")   // 免费注册获取: https://www.gold-api.cn/client/register.php

quotes, _ := client.Realtime("1051", "1061", "hf_GC")  // 黄金T+D + 黄金现货 + 纽约金

for _, q := range quotes {
    fmt.Println(q.VarietyName, q.LastPrice, q.ChangeMargin)
}

能力一览(与其他语言 SDK 对齐)

能力 方法
批量实时行情(单次 ≤ 50 品种,每品种 11 字段) Realtime()
单品种快捷查询 RealtimeOne()
品种列表(免认证) Varieties()
配额 / 限流感知 LastRateLimit() / LastRequestID()
错误(MsgID / RequestID / HTTPCode + 限流判断) *goldapi.Error + IsRateLimit()

变更清单

  • ✨ 新增 go/:Realtime / RealtimeOne / Varieties / LastRateLimit,X-API-KEY 请求头认证
  • 📖 README 升级为四语言门户(PHP / Python / Node.js / Go)
  • 🔧 各语言示例统一切换到数据干净的品种组合

链接

v1.1.0 — 新增 Python & Node.js SDK

Choose a tag to compare

@hujuncheng-ddd hujuncheng-ddd released this 15 Oct 04:06

🎉 v1.1.0 —— 三语言 SDK 全家桶

在 PHP SDK(v1.0.0)基础上,新增 Python 与 Node.js 官方 SDK,三个 SDK 的 API 完全对齐,均已通过线上接口冒烟测试。

安装(任选其一)

composer require gold-api/sdk-php   # PHP     ≥ 7.2,零依赖
pip install gold-api            # Python  ≥ 3.7,零依赖
npm install gold-api            # Node.js ≥ 18,零依赖(内置 fetch)

快速开始

Python
from gold_api import GoldApiClient

client = GoldApiClient("gk_your_appkey")
quotes = client.realtime(["1061", "hf_GC", "nf_AU0"])

for q in quotes.values():
    print(q["varietyName"], q["lastPrice"], q["changeMargin"])

print(client.last_rate_limit())   # 配额感知
Node.js
import { GoldApiClient, GoldApiException } from 'gold-api';

const client = new GoldApiClient('gk_your_appkey');
const quotes = await client.realtime(['1061', 'hf_GC', 'nf_AU0']);

for (const q of Object.values(quotes)) {
  console.log(q.varietyName, q.lastPrice, q.changeMargin);
}

console.log(client.getLastRateLimit());  // 配额感知
PHP(v1.0.0 起)
use GoldApi\Sdk\GoldApiClient;

$client = new GoldApiClient('gk_your_appkey');
$quotes = $client->realtime(['1061', 'hf_GC', 'nf_AU0']);

变更清单

  • ✨ 新增 python/gold_api:realtime() / realtime_one() / varieties() / last_rate_limit(),异常含 msg_id / request_id / http_code 与 is_rate_limit()
  • ✨ 新增 node/src:ESM 导出,realtime() / realtimeOne() / varieties() / getLastRateLimit(),同样的异常体系
  • 📖 README 升级为三语言门户(选择你的语言 → 安装 → 快速开始)
  • 🛡 三个 SDK 均默认 X-API-KEY 请求头认证,密钥不进 URL / 访问日志
  • ✅ Python / Node SDK 已对线上 varieties 接口完成冒烟测试

链接

v1.0.0 — PHP SDK 首发

Choose a tag to compare

@hujuncheng-ddd hujuncheng-ddd released this 15 Oct 04:04

📦 GoldAPI PHP SDK v1.0.0

GoldAPI 贵金属行情 PHP SDK 首发:一次请求,批量拿回黄金 / 白银 / 铂金 / 钯金等 70+ 品种实时行情。

安装

composer require gold-api/sdk-php

要求:PHP ≥ 7.2 + ext-curl,零第三方依赖。

快速开始

use GoldApi\Sdk\GoldApiClient;

$client = new GoldApiClient('gk_your_appkey');   // 免费注册获取: https://www.gold-api.cn/client/register.php

$quotes = $client->realtime(['1061', 'hf_GC', 'nf_AU0']);  // 黄金现货 + 纽约金 + 沪金主力

foreach ($quotes as $q) {
    echo $q['varietyName'], ' 最新价 ', $q['lastPrice'], '(', $q['changeMargin'], ')', PHP_EOL;
}

核心能力

能力 方法
批量实时行情(单次 ≤ 50 品种) realtime()
单品种快捷查询 realtimeOne()
品种列表(免认证) varieties()
配额 / 限流感知 getLastRateLimit() / getLastRequestId()
异常携带 msgId / requestId / httpCode GoldApiException::isRateLimit()

安全设计:默认通过 X-API-KEY 请求头认证,appkey 不进 URL 与访问日志。

链接