Skip to content

soga-client-v1 API 文档 ​

介绍 ​

soga-client-v1 是 soga 客户端使用的一系列用户端接口,面板按以下文档实现后,客户端即可登录、查看订阅、购买套餐、提交工单等。

base_url 配置 ​

可自定义路径,客户端访问接口时自动拼接 base_url 与接口 uri,例如 https://www.website.com/your/custom/uri/api/v1/me

base_url=https://www.website.com/your/custom/uri/

通用约定 ​

所有接口均使用 json 格式传递数据,GET 接口的参数放在 query 中

每个请求均会带上以下请求头

Key说明
AuthorizationBearer <access_token>,登录后的接口必须携带,access_token 由登录、注册接口返回
Accept-Language客户端语言,如 zh-CN en-US,面板按此语言返回提示文字
User-Agent客户端名称和版本,如 soga-client/1.2.0 (windows)

HTTP 状态码正常为 200,请求是否成功以返回数据中的 success 为准

成功时 success 为 true,返回数据放在 data 中

json
{
  "success": true,
  "data": {}
}

列表分页的接口,请求参数为 page(从 1 开始,默认 1)和 page_size(默认 20,最大 100),返回数据多一个 pagination

json
{
  "success": true,
  "data": [],
  "pagination": {
    "page": 1,
    "page_size": 20,
    "total": 57       // 总条数
  }
}

失败时 success 为 false,错误信息放在 error 中

json
{
  "success": false,
  "error": {
    "message": "邮箱或密码错误"          // 直接展示给用户的提示文字
  }
}

以下错误需要客户端做特殊处理,需在 error 中带上 code

json
{
  "success": false,
  "error": {
    "code": 1001,
    "message": "登录已过期,请重新登录"
  }
}
错误码说明
1001未登录或登录已过期,客户端会清除登录状态并回到登录页

其他错误只需返回 message,客户端直接展示

客户端同时识别常见的 HTTP 状态码,面板也可以直接返回这些状态码

HTTP 状态码客户端处理
200按 success 判断
401同错误码 1001,清除登录状态并回到登录页
403提示无权访问
404提示面板不支持该功能
429提示请求过于频繁
500 502 503 504提示服务器错误,请稍后重试

非 200 时,如果返回数据是 json 且带有 error.message,优先展示 error.message

数据格式约定

  • 时间统一为 Unix 时间戳,单位秒
  • 金额统一为整数,单位分
  • 流量统一为整数,单位字节
  • 布尔值统一为 true / false
  • 值不存在时返回 null,列表为空时返回 []

只返回成功、没有数据的接口返回

json
{
  "success": true
}

公共接口 ​

以下接口不需要登录

获取站点配置 GET <base_url>/api/v1/config ​

返回数据 ​

json
{
  "success": true,
  "data": {
    "site_name": "Example",
    "site_url": "https://www.website.com",          // 网页面板地址
    "tos_url": "https://www.website.com/tos",       // 服务条款,可为 null
    "currency": "CNY",                              // 货币代码
    "currency_symbol": "¥",                         // 货币符号
    "register": {
      "enabled": true,                              // 开放注册
      "email_verify": true,                         // 注册需要邮箱验证码
      "invite_required": false,                     // 注册必须填写邀请码
      "email_whitelist": ["gmail.com", "qq.com"]    // 允许注册的邮箱后缀,[] 表示不限制
    },
    "telegram": {
      "enabled": true,                              // 启用 Telegram 机器人
      "bot_username": "example_bot",                // 机器人用户名,不含 @
      "discuss_url": "https://t.me/example_group"   // 交流群,可为 null
    },
    "commission": {
      "withdraw_enabled": true,                     // 开放佣金提现
      "withdraw_methods": ["支付宝", "USDT"],        // 提现方式
      "withdraw_minimum": 10000,                    // 最低提现金额
      "distribution_enabled": false,                // 开启三级分销
      "distribution_rates": [50, 30, 20]            // 一至三级分销比例,百分比
    },
    "features": {                                   // 功能开关,缺少的项视为 false
      "deposit": true,                              // 余额充值
      "gift_card": true,                            // 礼品卡兑换
      "gift_card_preview": true,                    // 礼品卡兑换前预览、兑换记录
      "telegram_unbind": true,                      // 解绑 Telegram
      "new_period": true,                           // 流量用尽后提前开启新周期
      "sessions": true                              // 查看、移除登录设备
    }
  }
}

获取套餐列表 GET <base_url>/api/v1/plans ​

返回可购买的套餐。带 Authorization 请求时,当前订阅的套餐即使已下架,只要允许续费也会返回

返回数据 ​

json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "name": "年付套餐",
      "content": "<p>100G 流量</p>",       // 套餐说明,HTML,可为 null
      "transfer_enable": 107374182400,     // 每周期流量,字节
      "device_limit": 3,                   // 设备数限制,null 表示不限制
      "speed_limit": null,                 // 限速 Mbps,null 表示不限制
      "sold_out": false,                   // 名额已满,不可新购
      "prices": [                          // 可购买的周期及价格,未开放的周期不返回
        { "period": "month", "amount": 1500 },
        { "period": "year", "amount": 15000 },
        { "period": "reset_traffic", "amount": 500 }
      ]
    }
  ]
}

period 可选值: month quarter half_year year two_year three_year onetime reset_traffic(流量重置包)

获取套餐详情 GET <base_url>/api/v1/plan ​

请求参数 ​

id=1

返回数据 ​

json
{
  "success": true,
  "data": {
    // 同套餐列表中的一项
  }
}

获取客户端版本 GET <base_url>/api/v1/app/version ​

返回数据 ​

json
{
  "success": true,
  "data": {
    "windows": {                                              // 未设置的平台为 null
      "version": "1.4.0",                                     // 最新版本
      "download_url": "https://www.website.com/app.exe"
    },
    "macos": null,
    "android": {
      "version": "1.4.0",
      "download_url": "https://www.website.com/app.apk"
    }
  }
}

登录注册 ​

发送邮箱验证码 POST <base_url>/api/v1/auth/email_code ​

提交数据 ​

json
{
  "email": "[email protected]",
  "scene": "register"          // 可选: register 注册,reset_password 重置密码
}

返回数据 ​

json
{
  "success": true
}

注册 POST <base_url>/api/v1/auth/register ​

提交数据 ​

json
{
  "email": "[email protected]",
  "password": "password",
  "email_code": "123456",      // 可省略,站点开启邮箱验证时必填
  "invite_code": "abcd"        // 可省略,站点要求邀请码时必填
}

返回数据 ​

json
{
  "success": true,
  "data": {
    "access_token": "xxxxxxxx",       // 登录凭据,之后的请求放在 Authorization: Bearer <access_token>
    "expires_at": 1796112000,         // 凭据过期时间
    "is_admin": false
  }
}

登录 POST <base_url>/api/v1/auth/login ​

提交数据 ​

json
{
  "email": "[email protected]",
  "password": "password"
}

返回数据 ​

json
{
  "success": true,
  "data": {
    "access_token": "xxxxxxxx",
    "expires_at": 1796112000,
    "is_admin": false
  }
}

重置密码 POST <base_url>/api/v1/auth/reset_password ​

重置成功后该账户所有登录设备都需要重新登录

提交数据 ​

json
{
  "email": "[email protected]",
  "email_code": "123456",
  "password": "new_password"
}

返回数据 ​

json
{
  "success": true
}

退出登录 POST <base_url>/api/v1/auth/logout ​

使当前 access_token 失效

返回数据 ​

json
{
  "success": true
}

账户 ​

以下接口都需要登录

获取用户信息 GET <base_url>/api/v1/me ​

返回数据 ​

json
{
  "success": true,
  "data": {
    "email": "[email protected]",
    "avatar_url": "https://www.website.com/avatar.png",   // 可为 null
    "balance": 1000,                                      // 余额
    "commission_balance": 500,                            // 可用佣金
    "discount": 90,                                       // 专属折扣百分比,null 表示无
    "commission_rate": 10,                                // 专属佣金比例百分比,null 表示使用站点默认
    "remind_expire": true,                                // 到期提醒
    "remind_traffic": true,                               // 流量提醒
    "telegram_id": 123456,                                // 已绑定的 Telegram id,未绑定为 null
    "created_at": 1700000000,
    "last_login_at": 1764547200
  }
}

修改提醒设置 POST <base_url>/api/v1/me/update ​

提交数据 ​

json
{
  "remind_expire": true,        // 可省略,省略表示不修改
  "remind_traffic": false       // 可省略,省略表示不修改
}

返回数据 ​

json
{
  "success": true
}

获取待处理数量 GET <base_url>/api/v1/me/stat ​

返回数据 ​

json
{
  "success": true,
  "data": {
    "pending_orders": 1,        // 待支付订单数
    "open_tickets": 0,          // 未关闭工单数
    "invited_users": 5          // 已邀请用户数
  }
}

修改密码 POST <base_url>/api/v1/me/change_password ​

修改成功后其他登录设备需要重新登录

提交数据 ​

json
{
  "old_password": "password",
  "new_password": "new_password"
}

返回数据 ​

json
{
  "success": true
}

获取网页免登录链接 POST <base_url>/api/v1/me/web_login_url ​

提交数据 ​

json
{
  "redirect": "plan"            // 可省略,登录后跳转的网页面板路径,默认首页
}

返回数据 ​

json
{
  "success": true,
  "data": {
    "url": "https://www.website.com/#/login?verify=xxxx",    // 一次性链接,60 秒内有效
    "expires_at": 1764547260
  }
}

获取登录设备 GET <base_url>/api/v1/me/sessions ​

返回数据 ​

json
{
  "success": true,
  "data": [
    {
      "id": "a1b2c3",                           // 会话 id
      "ip": "1.2.3.4",                          // 可为 null
      "user_agent": "soga-client/1.2.0 (windows)",  // 可为 null
      "login_at": 1764547200,
      "last_used_at": 1764550800,               // 可为 null
      "is_current": true                        // 是当前设备
    }
  ]
}

移除登录设备 POST <base_url>/api/v1/me/session/remove ​

提交数据 ​

json
{
  "id": "a1b2c3"
}

返回数据 ​

json
{
  "success": true
}

解绑 Telegram POST <base_url>/api/v1/me/telegram/unbind ​

返回数据 ​

json
{
  "success": true
}

订阅 ​

以下接口都需要登录

获取订阅信息 GET <base_url>/api/v1/subscription ​

返回数据 ​

json
{
  "success": true,
  "data": {
    "plan": {                                     // 当前套餐,未购买为 null
      "id": 1,
      "name": "年付套餐"
    },
    "upload": 1073741824,                         // 本周期已用上传流量,字节
    "download": 5368709120,                       // 本周期已用下载流量,字节
    "transfer_enable": 107374182400,              // 流量额度,字节
    "expired_at": 1811808000,                     // 到期时间,null 表示长期有效
    "is_expired": false,                          // 已过期或从未购买
    "next_reset_at": 1767225600,                  // 下次流量重置时间,null 表示不重置
    "device_limit": 3,                            // 设备数限制,null 表示不限制
    "speed_limit": null,                          // 限速 Mbps,null 表示不限制
    "alive_ip": 1,                                // 当前在线设备数,可为 null
    "subscribe_url": "https://sub.website.com/s/xxxx",
    "can_new_period": false                       // 可以提前开启新周期
  }
}

重置订阅地址 POST <base_url>/api/v1/subscription/reset ​

重置订阅地址和节点认证信息,旧订阅地址立即失效

返回数据 ​

json
{
  "success": true,
  "data": {
    "subscribe_url": "https://sub.website.com/s/yyyy"     // 新的订阅地址
  }
}

提前开启新周期 POST <base_url>/api/v1/subscription/new_period ​

流量用尽时清零已用流量,到期时间提前一个流量重置周期,仅 can_new_period 为 true 时可用

返回数据 ​

json
{
  "success": true
}

获取订阅内容 GET <subscribe_url> ​

供其他客户端导入使用,不需要 Authorization;soga 客户端通过 /servers 获取节点,不请求订阅地址

请求参数 ​

flag=sing-box/1.12.0        // 配置格式,可选: general clash-meta sing-box,sing-box 可带内核版本

返回数据 ​

对应格式的配置文本,返回头需带上

subscription-userinfo: upload=1073741824; download=5368709120; total=107374182400; expire=1811808000

订阅不可用(未购买、已过期、已封禁)时返回

json
{
  "success": false,
  "error": {
    "message": "订阅已过期"
  }
}

获取流量记录 GET <base_url>/api/v1/traffic_logs ​

返回本月每天的流量记录,按日期倒序

返回数据 ​

json
{
  "success": true,
  "data": [
    {
      "record_at": 1764547200,      // 当天 0 点
      "upload": 10485760,           // 上传流量,字节
      "download": 524288000,        // 下载流量,字节
      "rate": 1.5                   // 节点倍率,计入额度的流量 = (upload + download) × rate
    }
  ]
}

获取节点配置 GET <base_url>/api/v1/servers ​

返回节点的连接配置和分流规则,见 soga-client-v1 节点接口文档

订单 ​

以下接口都需要登录

购买流程: 获取套餐列表 → 创建订单 → 支付订单 → 轮询订单详情直到状态不是 pending processing

校验优惠券 POST <base_url>/api/v1/coupon/check ​

提交数据 ​

json
{
  "code": "NEWUSER",
  "plan_id": 1,
  "period": "year"
}

返回数据 ​

json
{
  "success": true,
  "data": {
    "name": "新用户九折",
    "type": "percent",          // 可选: amount 减免金额,percent 减免百分比
    "value": 10                 // type 为 amount 时是金额,percent 时是百分比
  }
}

创建订单 POST <base_url>/api/v1/order/create ​

提交数据 ​

json
{
  "plan_id": 1,
  "period": "year",
  "coupon_code": "NEWUSER"      // 可省略
}

返回数据 ​

json
{
  "success": true,
  "data": {
    "trade_no": "2026120108300012345"     // 订单号
  }
}

创建充值订单 POST <base_url>/api/v1/order/deposit ​

features.deposit 为 true 时可用

提交数据 ​

json
{
  "amount": 10000               // 充值金额
}

返回数据 ​

json
{
  "success": true,
  "data": {
    "trade_no": "2026120108300012346"
  }
}

获取订单列表 GET <base_url>/api/v1/orders ​

请求参数 ​

status=pending              // 可省略,可选: pending processing completed cancelled
page=1
page_size=20

返回数据 ​

json
{
  "success": true,
  "data": [
    // 同订单详情
  ],
  "pagination": {
    "page": 1,
    "page_size": 20,
    "total": 3
  }
}

获取订单详情 GET <base_url>/api/v1/order ​

请求参数 ​

trade_no=2026120108300012345

返回数据 ​

json
{
  "success": true,
  "data": {
    "trade_no": "2026120108300012345",
    "plan": {                       // 充值订单为 null
      "id": 1,
      "name": "年付套餐"
    },
    "period": "year",               // 充值订单为 null
    "status": "pending",            // 可选: pending 待支付,processing 开通中,completed 已完成,cancelled 已取消,discounted 已折抵
    "total_amount": 13500,          // 应付金额
    "discount_amount": 1500,        // 优惠金额
    "surplus_amount": 0,            // 旧订阅折抵金额
    "balance_amount": 0,            // 余额抵扣金额
    "handling_amount": 0,           // 支付手续费
    "created_at": 1764547200,
    "paid_at": null
  }
}

取消订单 POST <base_url>/api/v1/order/cancel ​

提交数据 ​

json
{
  "trade_no": "2026120108300012345"
}

返回数据 ​

json
{
  "success": true
}

获取支付方式 GET <base_url>/api/v1/payment_methods ​

返回数据 ​

json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "name": "支付宝",
      "icon": "https://www.website.com/alipay.png",   // 可为 null
      "handling_fee_fixed": 0,                        // 固定手续费
      "handling_fee_percent": 0,                      // 百分比手续费
      "stripe_public_key": null                       // Stripe 信用卡支付时的公钥,其他支付方式为 null
    }
  ]
}

支付订单 POST <base_url>/api/v1/order/checkout ​

提交数据 ​

json
{
  "trade_no": "2026120108300012345",
  "method": 1,                  // 支付方式 id,应付金额为 0 时可省略
  "stripe_token": "tok_xxx"     // 可省略,Stripe 信用卡支付时必填
}

返回数据 ​

json
{
  "success": true,
  "data": {
    "type": "redirect",                          // 可选: paid 已支付无需跳转,qrcode 展示二维码,redirect 打开链接
    "url": "https://pay.website.com/xxxx"        // type 为 paid 时为 null
  }
}

礼品卡 ​

以下接口都需要登录

预览礼品卡 POST <base_url>/api/v1/gift_card/check ​

features.gift_card_preview 为 true 时可用

提交数据 ​

json
{
  "code": "GIFT-XXXX-XXXX"
}

返回数据 ​

json
{
  "success": true,
  "data": {
    "name": "30 天体验卡",
    "description": "赠送 30 天有效期",    // 可为 null
    "can_redeem": true,                  // 当前账户能否兑换
    "reason": null,                      // 不能兑换的原因
    "balance": null,                     // 奖励余额
    "transfer_enable": null,             // 奖励流量,字节
    "expire_days": 30,                   // 延长有效期天数
    "device_limit": null,                // 增加设备数
    "plan_name": null,                   // 开通的套餐名
    "plan_days": null,                   // 开通套餐的天数
    "reset_traffic": false               // 清零已用流量
  }
}

兑换礼品卡 POST <base_url>/api/v1/gift_card/redeem ​

提交数据 ​

json
{
  "code": "GIFT-XXXX-XXXX"
}

返回数据 ​

json
{
  "success": true
}

获取兑换记录 GET <base_url>/api/v1/gift_card/history ​

features.gift_card_preview 为 true 时可用

返回数据 ​

json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "code": "GIFT-****-XXXX",     // 部分打码的兑换码
      "name": "30 天体验卡",
      "created_at": 1764547200
    }
  ]
}

邀请 ​

以下接口都需要登录

获取邀请信息 GET <base_url>/api/v1/invite ​

返回数据 ​

json
{
  "success": true,
  "data": {
    "codes": [                          // 未使用的邀请码
      {
        "code": "abcd",
        "pv": 12,                       // 访问次数
        "created_at": 1764547200
      }
    ],
    "invited_users": 5,                 // 已邀请用户数
    "commission_rate": 10,              // 佣金比例,百分比
    "total_commission": 3000,           // 累计获得佣金
    "pending_commission": 500,          // 确认中佣金
    "available_commission": 2500        // 可用佣金
  }
}

生成邀请码 POST <base_url>/api/v1/invite/create ​

返回数据 ​

json
{
  "success": true
}

获取佣金记录 GET <base_url>/api/v1/invite/commissions ​

请求参数 ​

page=1
page_size=20

返回数据 ​

json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "trade_no": "2026120108300012345",
      "order_amount": 15000,          // 订单金额
      "get_amount": 1500,             // 获得的佣金
      "created_at": 1764547200
    }
  ],
  "pagination": {
    "page": 1,
    "page_size": 20,
    "total": 1
  }
}

佣金转入余额 POST <base_url>/api/v1/invite/transfer ​

提交数据 ​

json
{
  "amount": 1000                  // 转入金额
}

返回数据 ​

json
{
  "success": true
}

申请提现 POST <base_url>/api/v1/invite/withdraw ​

提现全部可用佣金,面板会生成一个工单人工处理

提交数据 ​

json
{
  "method": "支付宝",              // 取自站点配置 commission.withdraw_methods
  "account": "[email protected]"     // 收款账号
}

返回数据 ​

json
{
  "success": true
}

公告与知识库 ​

以下接口都需要登录

获取公告 GET <base_url>/api/v1/notices ​

请求参数 ​

page=1
page_size=20

返回数据 ​

json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "title": "系统维护通知",
      "content": "<p>今晚 22 点维护</p>",     // HTML
      "img_url": null,
      "created_at": 1764547200
    }
  ],
  "pagination": {
    "page": 1,
    "page_size": 20,
    "total": 1
  }
}

获取知识库 GET <base_url>/api/v1/knowledge ​

返回当前语言的文章目录,按分类分组,不含正文

请求参数 ​

keyword=windows             // 可省略,按标题和正文搜索

返回数据 ​

json
{
  "success": true,
  "data": [
    {
      "category": "使用教程",
      "articles": [
        {
          "id": 1,
          "title": "Windows 使用教程",
          "updated_at": 1764547200
        }
      ]
    }
  ]
}

获取知识库文章 GET <base_url>/api/v1/knowledge/article ​

请求参数 ​

id=1

返回数据 ​

json
{
  "success": true,
  "data": {
    "id": 1,
    "category": "使用教程",
    "title": "Windows 使用教程",
    "body": "<p>下载客户端后……</p>",     // HTML
    "updated_at": 1764547200
  }
}

工单 ​

以下接口都需要登录

获取工单列表 GET <base_url>/api/v1/tickets ​

请求参数 ​

page=1
page_size=20

返回数据 ​

json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "subject": "无法连接",
      "level": 1,                   // 0 低,1 中,2 高
      "is_closed": false,
      "is_replied": true,           // 客服已回复
      "created_at": 1764547200,
      "updated_at": 1764550800
    }
  ],
  "pagination": {
    "page": 1,
    "page_size": 20,
    "total": 1
  }
}

获取工单详情 GET <base_url>/api/v1/ticket ​

请求参数 ​

id=1

返回数据 ​

json
{
  "success": true,
  "data": {
    "id": 1,
    "subject": "无法连接",
    "level": 1,
    "is_closed": false,
    "is_replied": true,
    "created_at": 1764547200,
    "updated_at": 1764550800,
    "messages": [                   // 按时间正序
      {
        "id": 1,
        "is_me": true,              // true 为用户发送,false 为客服发送
        "message": "所有节点都连不上",
        "created_at": 1764547200
      },
      {
        "id": 2,
        "is_me": false,
        "message": "请更新订阅后重试",
        "created_at": 1764550800
      }
    ]
  }
}

创建工单 POST <base_url>/api/v1/ticket/create ​

提交数据 ​

json
{
  "subject": "无法连接",
  "level": 1,                       // 0 低,1 中,2 高
  "message": "所有节点都连不上"
}

返回数据 ​

json
{
  "success": true,
  "data": {
    "id": 1                         // 工单 id
  }
}

回复工单 POST <base_url>/api/v1/ticket/reply ​

提交数据 ​

json
{
  "id": 1,
  "message": "已经更新,还是不行"
}

返回数据 ​

json
{
  "success": true
}

关闭工单 POST <base_url>/api/v1/ticket/close ​

提交数据 ​

json
{
  "id": 1
}

返回数据 ​

json
{
  "success": true
}