Skip to content

Quick Start

Justintunsday edited this page Sep 14, 2026 · 4 revisions

快速开始

方式一:直接调用在线服务(推荐体验)

线上地址(已验证全部端点):

Cloudflare Workers(推荐,无冷启动): https://ts-api.tundrey.com
Vercel                              : https://chelaile-api-server.vercel.app
curl "https://ts-api.tundrey.com/v1/cities"
{
  "origin": "github",
  "updatedAt": "2026-09-14T08:54:05.173Z",
  "hotOnly": true,
  "count": 12,
  "total": 480,
  "cities": [
    { "cityId": "027", "cityName": "北京", "pinyin": "BeiJing", "supportSubway": true, "hot": true },
    { "cityId": "034", "cityName": "上海", "pinyin": "ShangHai", "supportSubway": true, "hot": true }
  ]
}

服务默认无鉴权、可直接调用;如被滥用可自行部署并设置 API_KEY(见 Deployment)。

方式二:本地运行

要求 Node.js 18+。

git clone https://github.com/Justintunsday/chelaile-api-server.git
cd chelaile-api-server
npm install
npm run build
npm start
# chelaile-api v2.0.0 listening on http://0.0.0.0:8787

测试:

curl "http://127.0.0.1:8787/v1/health"
curl "http://127.0.0.1:8787/v1/search?city_id=034&keyword=71"
  • 城市列表默认读取仓库内 data/cities.json(无需网络)。
  • 实时类端点会回源 web.chelaile.net.cn,需要能访问该域名。
  • 修改代码后可用 npm run dev 热重载。

方式三:Docker

docker build -t chelaile-api .
docker run -d --name chelaile-api -p 8787:8787 chelaile-api

方式四:从仓库一键部署到云

平台 操作 备注
Cloudflare Workers npx wrangler deploy -c worker/wrangler.toml 无冷启动;需绑自定义域名(*.workers.dev 大陆不可用)
Vercel https://vercel.com/new 导入本仓库 vercel.json 已声明 Services + 容器;建议加 DATA_BASE_URL 环境变量
Render https://render.com/deploy?repo=https://github.com/Justintunsday/chelaile-api-server 读取 render.yaml;免费套餐需银行卡验证
Railway New Project → Deploy from GitHub repo 自动读取 railway.json
VPS npm ci && npm run build && npm start 可用 systemd/pm2 守护

详细步骤见 Deployment

常见调用示例

查询城市 ID

curl "https://ts-api.tundrey.com/v1/cities?hot_only=false"

搜索线路 / 站点 / POI

curl "https://ts-api.tundrey.com/v1/search?city_id=034&keyword=陆家嘴"

附近站点 + 实时到站

curl "https://ts-api.tundrey.com/v1/stops/nearby?city_id=034&lat=31.2304&lng=121.4737&limit=3"

线路详情(首末班、票价、全部站点、在线车辆)

curl "https://ts-api.tundrey.com/v1/lines/detail?city_id=034&line_id=21283603183"

换乘规划(GCJ-02 坐标)

curl "https://ts-api.tundrey.com/v1/transit/plan?city_id=034&origin_name=人民广场&origin_lat=31.233021&origin_lng=121.49073&dest_name=虹桥火车站&dest_lat=31.197&dest_lng=121.327&strategy=0"

下一篇:API-Reference(全部端点与参数)

Clone this wiki locally