首页 / API

开发者

HTTP API

基础地址 https://osim.live/api/v1 — 短信验证和旅行 eSIM。在控制台创建密钥,然后用 Bearer 调用。

身份验证

每个私有请求都要带上 API 密钥。密钥以 osim_ 开头,在账户页创建。

Authorization: Bearer osim_…

切勿把密钥嵌进公开的前端。请优先使用服务端或后端代理。

打开控制台密钥

响应格式

每个端点都返回带 success 标志的 JSON。错误使用同一结构,并带 error 字符串。

// Success
{ "success": true, "data": { … } }

// Error
{ "success": false, "error": "message" }
  • 基础 URL: https://osim.live/api/v1
  • Content-Type: application/json
  • 已为浏览器客户端启用 CORS (OPTIONS 已支持)
  • 金额以 USD cents 为单位,除非另有说明 (balanceCents, sellCents)
GET/api/v1

API 索引 — 版本和可用资源路径。无需密钥。

公开

curl https://osim.live/api/v1
GET/api/v1/me

与 API 密钥绑定的当前账户:id、email、name 和钱包余额。

需要 Bearer

curl https://osim.live/api/v1/me \
  -H "Authorization: Bearer osim_…"

// data
{
  "id": "…",
  "email": "[email protected]",
  "name": "…",
  "balanceCents": 2500,
  "balance": "$25.00"
}

短信验证

GET/api/v1/sms?catalog=1

服务、国家、USD 价格和允许租用时长的公开目录。

公开

curl "https://osim.live/api/v1/sms?catalog=1"

// data
{
  "services": [
    {
      "slug": "whatsapp",
      "service": "WhatsApp",
      "category": "…",
      "countries": [
        { "code": "TR", "name": "Turkey", "countryId": 12, "priceUsd": 0.35, "successRate": 92 }
      ]
    }
  ],
  "rentHours": [4, 12, 24, 72, 168]
}
GET/api/v1/sms

列出你最近的短信订单。

需要 Bearer

  • 默认:密钥所有者最近 50 笔短信订单
curl https://osim.live/api/v1/sms \
  -H "Authorization: Bearer osim_…"
POST/api/v1/sms

购买、租用、查询状态、取消、完成或重发。不提供 call-verify。

需要 Bearer

通用请求体

字段类型必填说明
actionstring是purchase | activation | rent | status | refresh | cancel | complete | resend
service / serviceSlugstring是目录 slug,例如 whatsapp
countryId / countrynumber否目录中的供应商国家 id(购买和租用时必填)
priceIdstring否可选,锁定到某一价格行
maxPricenumber否可选的美元上限
operatorstring否可选的网络偏好
hours / timenumber否仅租用:4 | 12 | 24 | 72 | 168
id / activationIdstring否用于查询状态、取消、完成和重发的订单 id

purchase / activation

一次性短信验证号码(约 20 分钟)。不提供来电验证。

curl -X POST https://osim.live/api/v1/sms \
  -H "Authorization: Bearer osim_…" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "purchase",
    "service": "whatsapp",
    "countryId": 12
  }'

rent

更长租用。允许的小时数:4、12、24、72、168。

{
  "action": "rent",
  "service": "telegram",
  "countryId": 16,
  "hours": 24
}

status / refresh

{ "action": "status", "id": "cm…" }

cancel · complete · resend

{ "action": "cancel", "id": "cm…" }
{ "action": "complete", "id": "cm…" }
{ "action": "resend", "id": "cm…" }  // 仅在支持时的租用线路

旅行 eSIM

GET/api/v1/esim?catalog=1

公开套餐目录(slug / packageCode、data、天数、售价)。

公开

curl "https://osim.live/api/v1/esim?catalog=1"
GET/api/v1/esim

列出你的 eSIM 订单,或按 id 获取一笔(可能时会刷新用量)。

需要 Bearer

  • 默认:最近 50 笔 eSIM 订单
  • 单笔订单并刷新用量: ?id=cm…
curl "https://osim.live/api/v1/esim?id=cm…" \
  -H "Authorization: Bearer osim_…"
POST/api/v1/esim

购买套餐、刷新配置、重命名、列出充值选项或应用充值。

需要 Bearer

字段类型必填说明
actionstring是purchase | refresh | rename | topup-options | topup
slug / packageCodestring否用于购买和充值的目录套餐
idstring否用于刷新、重命名和充值的订单 id
labelstring否重命名时的新显示名称
// Purchase
{
  "action": "purchase",
  "packageCode": "turkey-5gb-30d"
}

// Refresh profile / usage
{ "action": "refresh", "id": "cm…" }

// Rename
{ "action": "rename", "id": "cm…", "label": "Trip TR" }

// Top-up options + apply
{ "action": "topup-options", "id": "cm…" }
{ "action": "topup", "id": "cm…", "packageCode": "…" }

购买响应在可用时包含 LPA 激活字符串和 QR 图片 URL。

错误

HTTP何时
200success: true
400校验或业务错误(余额不足、未知操作……)
401缺少或无效的 API 密钥
404此账户下未找到订单

说明

  • 购买时按 USD 美分扣减余额。供应商购买失败会退款。
  • 一次性短信号码通常约 20 分钟。租用时长以目录中的小时数为准。
  • 可能适用速率限制和滥用控制。更高用量请联系支持。
  • OpenAPI/Swagger 导出尚未发布 — 本页为权威说明。