| 用户名 | 密码 | 限速 | 操作 |
|---|
本工具整合两个能力: Telegram api_id/api_hash 申请网关 + HTTP 代理转发。共用 ADMIN_SECRET(管理员登录)与 APIKEYS(Bearer 鉴权), 在「配置」页统一管理。
mytelegram_config.json + tgapi_stats.json, 立即生效; Cloudflare 通过环境变量, 重新部署后生效。| 端点 | 鉴权 | 请求体 |
|---|---|---|
| POST /api/send-code | Bearer APIKey | {"phone":"+86138..."} |
| POST /api/verify-code | Bearer APIKey | {"phone","random_hash","code"} |
| POST /api/get-app | Bearer APIKey | {"stel_token"} |
| POST /api/create-app | Bearer APIKey | {"stel_token","app_title","app_shortname","app_url?","app_platform?","app_desc?"} |
| POST /api/login / /api/logout | ADMIN_SECRET | {"secret"} 管理员登录(HMAC Cookie, 2h) |
| POST /api/check-key | - | {"key"} 校验 API Key |
| GET /api/admin/config | 管理员 | 读取全部配置与状态 |
| POST /api/admin/save | 管理员 | {"section":"apikeys|proxies|admin_secret|proxy_paths|proxy_domains|proxy_users|rate", ...} |
| POST /api/admin/test-proxies | 管理员 | {"proxies":[...]} 测试上游代理 |
| POST /api/admin/test-proxy-service | 管理员 | HTTP 代理自检 |
| GET /api/stats | 管理员(Node) | 读取调用统计 |
| GET /api/health | 无 | 健康检查 |
curl -X POST https://你的域名/api/send-code \
-H "Authorization: Bearer <你的APIKEY>" \
-H "Content-Type: application/json" \
-d '{"phone":"+8613800000000"}'
# → {"ok":true,"phone":"...","random_hash":"...","cookies":{...}}
# 限流 → {"ok":false,"error":"Sorry, too many tries...","field":false}
curl -x https://<域名>/<路径>/ https://target.com/api/x curl https://user:pass@<域名>/<路径>/https://target.com/api/x curl -H "Authorization: Bearer <APIKEY>" https://<域名>/<路径>/https://target.com/api/x
| 变量 | 用途 | 分隔 |
|---|---|---|
| ADMIN_SECRET | 管理员登录密钥 | 单值 |
| APIKEYS | Bearer 鉴权 Key 列表 | ; 分隔 |
| PROXIES | 申请网关上游代理池 | ; 分隔 |
| CF_PROXY_DOMAINS | HTTP 代理域名白名单 | ; 分隔 |
| CF_PROXY_PATHS | HTTP 代理路径(/xxx:1 透传) | ; 分隔 |
| CF_PROXY_USERS | HTTP 代理 Basic 账户(user:pass[:limit:window]) | ; 分隔 |
| CF_PROXY_RATE | off 关闭限速 | 单值 |
Cloudflare Workers: npx wrangler deploy worker.js --name tg-api-proxy。在线写回需 CF_ACCOUNT_ID + CF_API_TOKEN(Workers Scripts:Edit) + CF_SCRIPT_NAME。
Node(≥ 18, 零依赖): node mytelegram_client.mjs serve --port 8787。首次运行生成 mytelegram_config.json(含随机 admin_secret)。配置保存立即生效, 统计写入 tgapi_stats.json。
Cloudflare Pages: 见 cloudflare-pages/ 目录, wrangler pages deploy。