API 和 SDK

API 和 SDK

将 Atli 接入你自己的应用或网站,使用你自己的界面。

Atli eSIM API

v1.0.0

Buy and manage travel eSIMs: browse the catalogue, quote and buy a plan, install and track an eSIM, share one as a gift, and run a group account.

Paths are unversioned and the version of this document is in info.version, as on heyatli.com's published API. A breaking change will arrive under a new base URL rather than by changing what a path here means.

基础 URL
https://api.heyatli.com
OpenAPI 文件
https://api.heyatli.com/openapi.yaml

主要流程

API 的主要流程创建用户,获取报价,购买并付款,获取 eSIM,安装并跟踪用量。可选分支:正式账户、保存银行卡、群组卡、充值、折扣,以及购买后分享,再分享链接供他人领取。
创建用户POST /login
获取报价POST /plan/quote
购买并付款POST /plan/purchase
获取 eSIMGET /fulfillment/…
安装GET /esims
跟踪用量POST /esims/{id}/sync
正式账户邮箱、Telegram、WhatsApp
保存银行卡Stripe SetupIntent
群组卡group_id
充值target_esim_id
折扣优惠券、积分、推荐
购买后分享is_gift, max_claims
分享链接GET /public/gifts/{code}
领取可能需要正式账户
主要流程可选

在地图上选择一个流程,查看其步骤。

SDK

用我们的 OpenAPI 文件,为你使用的语言生成可直接使用的客户端。

docker run --rm -v "$PWD:/out" \
  openapitools/openapi-generator-cli generate \
  -i https://api.heyatli.com/openapi.yaml \
  -g typescript-fetch -o /out/atli-sdk

Authentication

Most routes need a bearer token, issued by signing in through /login, /register or one of the /oauth/* flows, and refreshed at /refresh. Each operation states whether a token is required, read when sent, or ignored. Tokens identify a person, not an application; there is no application API key yet.

Enums

A field with a listed set of values may gain new ones: that ships as a minor version, never a new base URL. Treat a value you do not recognise as one you do not handle yet, not as invalid, and never let it fail parsing.

Errors

Every failed request answers with the same body: a stable code, an English message, a trace_id to quote when reporting a problem, and sometimes params. Branch on code and never on message.

查看常见错误代码
400

请求无效

401

缺少登录信息或登录已过期

402

付款失败

403

此用户无权执行此操作

404

不存在,或不属于此用户

429

请求过多,请等待 Retry-After 指定的时间

500

我们这边出了问题

Rate limits

Sign-in, registration, token refresh, email codes, voucher redemption, quotes, reviews and eSIM sync are throttled per caller. A refused request answers 429 with Retry-After in whole seconds, alongside X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. Wait out Retry-After rather than retrying in a loop.

Language and currency

Send X-Locale (or Accept-Language, or ?lang=) to choose the language; the language answered in comes back as Content-Language, falling back to English. Prices follow the signed-in person's currency, or the currency a quote asks for.

Buying a plan

Quote first at /plan/quote, then pass the quote_id to /plan/purchase so the price you showed is the price charged. Send an idempotency_key on every purchase: the same key never buys twice.