CGyinliu/代理 API
← 返回商店

代理 API 对接文档

面向代理 / 分销商:查询商品与库存、按代理价下单、自动发货、下载账号文件。全部走 HTTPS,使用 API 密钥鉴权。

1. 快速开始

  1. 在 本站 注册账号(邮箱 + 密码)
  2. 登录后点右上「安全」→「API 密钥」→ 生成,复制 cgyl_... 密钥(只显示一次)
  3. 用 USDT-TRC20 充值(站内「充值」,按页面显示的精确金额转账,自动到账)
  4. 调 GET /api/v1/products 取商品和库存
  5. 调 POST /api/v1/orders 下单,然后轮询订单状态,完成后下载

2. 鉴权

所有接口都要带请求头:

X-Api-Key: cgyl_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
密钥与账号绑定,扣的是该账号的美元余额。密钥在「安全 → API 密钥」里生成,可生成多个、可随时删除(删除后立即失效)。

3. 商品列表

GET/api/v1/products?shop=tg|cg|baos

shop说明
tg商店一(session+json 协议号为主)
cg商店三(tdata 直登号)
baos商店二(多国协议号 / 会员号)
GET /api/v1/products?shop=tg
X-Api-Key: cgyl_xxx

{
  "ok": true, "shop": "tg", "total": 120,
  "items": [
    {
      "sku": "tgd3f613de",
      "name": "🇨🇴+58哥伦比亚(苹果协议)",
      "category": "协议号 / 直登号(全区)",
      "stock": 2418,
      "price": 0.30,        // 你的代理价(USD)
      "format": "session_json",
      "currency": "USD"
    }
  ]
}

4. 余额

GET/api/v1/balance

{"ok": true, "balance": 25.00, "currency": "USD"}

5. 下单

POST/api/v1/orders

字段类型必填说明
shopstring是tg / cg / baos
skustring是商品编号(baos 用 uni)
countint是数量 1~50
POST /api/v1/orders
X-Api-Key: cgyl_xxx
{"shop":"tg","sku":"tgd3f613de","count":1}

200 {"ok":true,"order_id":"0472f567a8f74296","usd_total":0.30,"status":"pending","shop":"tg"}
400 {"ok":false,"error":"余额不足(需 $0.30,当前 $0.10)"}
409 {"ok":false,"error":"库存不足(当前剩 3 个),请刷新后重试"}
下单即扣余额(原子操作);发货失败/部分发货会自动退回差额。

6. 查询订单

GET/api/v1/orders/{order_id} 单个

GET/api/v1/orders?limit=50 列表

GET /api/v1/orders/0472f567a8f74296
X-Api-Key: cgyl_xxx

{"ok":true,"order":{
  "order_id":"0472f567a8f74296","status":"delivered",
  "product":"🇨🇴+58哥伦比亚(苹果协议)","count":1,"usd_total":0.30,
  "created":1795175526,"error":null,
  "download_path":"/api/v1/orders/0472f567a8f74296/download"}}
status含义
pending处理中(供应商发货中)
delivered已发货,可下载
failed失败(已自动退款)
refunded已退款

建议每 3~5 秒查一次,直到 status 变成终态。

7. 下载账号文件

GET/api/v1/orders/{order_id}/download

GET /api/v1/orders/0472f567a8f74296/download
X-Api-Key: cgyl_xxx

→ 返回 zip 文件(Content-Disposition: attachment)
文件是供应商原始账号包:session+json 或 tdata 目录,按商品 format 字段判断。

8. 完整示例(Python)

import requests, time

KEY = "cgyl_xxxxxxxxxxxxxxxxxxxxxxxx"
B   = "https://cgyinliu.vip"
H   = {"X-Api-Key": KEY}

# 余额
print(requests.get(B + "/api/v1/balance", headers=H).json())

# 取商品
items = requests.get(B + "/api/v1/products", params={"shop": "tg"}, headers=H).json()["items"]
sku = items[0]["sku"]

# 下单
o = requests.post(B + "/api/v1/orders", headers=H,
                  json={"shop": "tg", "sku": sku, "count": 1}).json()
oid = o["order_id"]

# 轮询
while True:
    d = requests.get(B + "/api/v1/orders/" + oid, headers=H).json()["order"]
    if d["status"] in ("delivered", "failed", "refunded"):
        break
    time.sleep(4)

# 下载
if d["status"] == "delivered":
    r = requests.get(B + "/api/v1/orders/" + oid + "/download", headers=H)
    open("accounts.zip", "wb").write(r.content)

9. 价格与结算

10. 错误码

HTTPerror说明
401invalid_api_key密钥错误或已删除
400bad_shop / 参数错误检查 shop、sku、count
402 / 400余额不足充值后重试
409库存不足 / not_ready刷新商品或等发货完成
404order_not_found订单不属于该密钥账号
429下单太频繁每账号 6 次/分钟
接口可能新增字段,请容忍未知字段。对接问题:站内「支持」留言。

Reseller API

For resellers / distributors: browse products and stock, place orders at reseller price, auto-delivery and file download. HTTPS only, authenticated with an API key.

1. Quick start

  1. Create an account on the store (email + password)
  2. Sign in → top-right “Security” → “API keys” → Create, copy the cgyl_... key (shown once)
  3. Top up with USDT-TRC20 (use the exact amount shown; credited automatically)
  4. Call GET /api/v1/products to list products and stock
  5. Call POST /api/v1/orders, poll the order, then download

2. Authentication

X-Api-Key: cgyl_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Keys are bound to your account and spend that account's USD balance. Create or revoke keys under Security → API keys.

3. Products

GET/api/v1/products?shop=tg|cg|baos

shopDescription
tgShop 1 · Daxi (API supplier, session+json mostly)
cgShop 3 · Chunge (tdata accounts)
baosShop 2 (protocol / membership accounts)
GET /api/v1/products?shop=tg
X-Api-Key: cgyl_xxx

{
  "ok": true, "shop": "tg", "total": 120,
  "items": [
    {"sku":"tgd3f613de","name":"🇨🇴+57 Colombia (Apple session)",
     "category":"session+json / tdata","stock":2418,
     "price":0.30,"format":"session_json","currency":"USD"}
  ]
}

4. Balance

GET/api/v1/balance

{"ok":true,"balance":25.00,"currency":"USD"}

5. Create order

POST/api/v1/orders

FieldTypeRequiredNotes
shopstringyestg / cg / baos
skustringyesProduct id (baos uses uni)
countintyes1–50
POST /api/v1/orders
X-Api-Key: cgyl_xxx
{"shop":"tg","sku":"tgd3f613de","count":1}

200 {"ok":true,"order_id":"0472f567a8f74296","usd_total":0.30,"status":"pending","shop":"tg"}
400 {"ok":false,"error":"Insufficient balance (need $0.30, have $0.10)"}
409 {"ok":false,"error":"Out of stock (3 left), please refresh"}
Balance is deducted atomically at order time. Failures/partial deliveries are refunded automatically.

6. Order status

GET/api/v1/orders/{order_id} single

GET/api/v1/orders?limit=50 list

GET /api/v1/orders/0472f567a8f74296
X-Api-Key: cgyl_xxx

{"ok":true,"order":{"order_id":"0472f567a8f74296","status":"delivered",
 "product":"🇨🇴+57 Colombia (Apple session)","count":1,"usd_total":0.30,
 "created":1795175526,"error":null,
 "download_path":"/api/v1/orders/0472f567a8f74296/download"}}
statusMeaning
pendingProcessing (supplier delivering)
deliveredDelivered, ready to download
failedFailed (auto-refunded)
refundedRefunded

Poll every 3–5 seconds until a final status.

7. Download

GET/api/v1/orders/{order_id}/download

GET /api/v1/orders/0472f567a8f74296/download
X-Api-Key: cgyl_xxx

→ zip file (Content-Disposition: attachment)
Files are the supplier's original packages: session+json or tdata, per the product's format field.

8. Example (Python)

import requests, time

KEY = "cgyl_xxxxxxxxxxxxxxxxxxxxxxxx"
B   = "https://cgyinliu.vip"
H   = {"X-Api-Key": KEY}

print(requests.get(B + "/api/v1/balance", headers=H).json())

items = requests.get(B + "/api/v1/products", params={"shop": "tg"}, headers=H).json()["items"]
sku = items[0]["sku"]

o = requests.post(B + "/api/v1/orders", headers=H,
                  json={"shop": "tg", "sku": sku, "count": 1}).json()
oid = o["order_id"]

while True:
    d = requests.get(B + "/api/v1/orders/" + oid, headers=H).json()["order"]
    if d["status"] in ("delivered", "failed", "refunded"):
        break
    time.sleep(4)

if d["status"] == "delivered":
    r = requests.get(B + "/api/v1/orders/" + oid + "/download", headers=H)
    open("accounts.zip", "wb").write(r.content)

9. Pricing & billing

10. Errors

HTTPerrorNotes
401invalid_api_keyKey invalid or revoked
400bad_shop / bad paramsCheck shop, sku, count
402 / 400insufficient balanceTop up and retry
409out of stock / not_readyRefresh products or wait
404order_not_foundOrder belongs to another account
429rate limited6 orders/minute per account
New fields may be added; tolerate unknown keys. Need help? Use the in-site Support chat.