cURL
# GET:只给型号
curl "https://tool.0cai.net/openapi/v1/zlljs/calc?wire=LGJ-400/50&thetaA=40&thetaB=70&V=0.5" \
-H "Authorization: Bearer $TOOL_API_KEY"
# POST:JSON body
curl -X POST "https://tool.0cai.net/openapi/v1/zlljs/calc" \
-H "Authorization: Bearer $TOOL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"wire":"LGJ-400/50","thetaA":40,"thetaB":70,"V":0.5}'
# 张力弧垂:型号 + 气象工况 + 档距
curl -X POST "https://tool.0cai.net/openapi/v1/huchui/calc" \
-H "Authorization: Bearer $TOOL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"specId":"new1","wire":"JL/G1A-400/50",
"conds":[{"name":"最高气温","T":40,"V":0,"b":0},
{"name":"最大风速","T":-5,"V":25,"b":0},
{"name":"最大覆冰","T":-5,"V":10,"b":5}],
"L":400}'
# 坐标:CGCS2000 投影坐标 → 经纬度
curl -X POST "https://tool.0cai.net/openapi/v1/cptool/cgcs2wgs" \
-H "Authorization: Bearer $TOOL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"coords":[[500000,38500000],[600000,38500000]],"zone":38}'
# 坐标 → DXF(二进制文件,直接落盘)
curl -X POST "https://tool.0cai.net/openapi/v1/cptool/coord2dxf" \
-H "Authorization: Bearer $TOOL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"sets":[{"points":[{"label":"1","x":500000,"y":38500000},
{"label":"2","x":500100,"y":38500100}]}],
"genkai":6}' -o towers.dxf
Python
import os, requests
KEY = os.environ["TOOL_API_KEY"] # 不要硬编码在代码里
BASE = "https://tool.0cai.net/openapi/v1"
H = {"Authorization": f"Bearer {KEY}"}
# 载流量:只给型号
r = requests.get(f"{BASE}/zlljs/calc", headers=H,
params={"wire": "LGJ-400/50", "thetaA": 40, "thetaB": 70, "V": 0.5},
timeout=15)
r.raise_for_status()
d = r.json()
print(d["wire"]["name"], "载流量 =", round(d["I"], 2), "A")
# 导线库模糊搜索
w = requests.get(f"{BASE}/tldb/wire", headers=H, params={"q": "400/50"}).json()
print("命中", w["total"], "条")
# 读取配额余量(不用额外请求,看响应头)
print("剩余额度", r.headers.get("X-RateLimit-Remaining"))
JavaScript / Node
const BASE = "https://tool.0cai.net/openapi/v1";
const H = { Authorization: `Bearer ${process.env.TOOL_API_KEY}` };
const calc = async (p) => {
const url = new URL(`${BASE}/zlljs/calc`);
Object.entries(p).forEach(([k, v]) => url.searchParams.set(k, v));
const r = await fetch(url, { headers: H });
if (!r.ok) throw new Error(`${r.status} ${(await r.json()).message}`);
return r.json();
};
calc({ wire: "LGJ-400/50", thetaA: 40, thetaB: 70, V: 0.5 })
.then(d => console.log(d.wire.name, d.I.toFixed(2), "A"));
PHP
$res = file_get_contents(
"https://tool.0cai.net/openapi/v1/zlljs/calc?" . http_build_query([
"wire" => "LGJ-400/50", "thetaA" => 40, "thetaB" => 70, "V" => 0.5,
]),
false,
stream_context_create(["http" => [
"header" => "Authorization: Bearer " . getenv("TOOL_API_KEY") . "\r\n",
"timeout" => 15,
]])
);
$d = json_decode($res, true);
echo $d["wire"]["name"] . " 载流量 = " . round($d["I"], 2) . " A";