💻 Ví dụ gọi API
Port mặc định 8765. Gọi thẳng URL — không header auth. Trên Windows, nếu curl.exe -d '{...}' bị lỗi JSON, dùng Invoke-RestMethod hoặc file tạm.
curl
# Health
curl -s http://127.0.0.1:8765/api/v1/health
# List scripts
curl -s http://127.0.0.1:8765/api/v1/scripts
# Status
curl -s http://127.0.0.1:8765/api/v1/scripts/DemoFlow/status
# Start
curl -s -X POST -H "Content-Type: application/json" \
-d "{\"variables\":{\"mode\":\"test\"}}" \
http://127.0.0.1:8765/api/v1/scripts/DemoFlow/start
# Stop all
curl -s -X POST http://127.0.0.1:8765/api/v1/run/stopPython
import requests
BASE = "http://127.0.0.1:8765/api/v1"
scripts = requests.get(f"{BASE}/scripts", timeout=5).json()["scripts"]
print(scripts)
if scripts:
name = scripts[0]["name"]
requests.post(f"{BASE}/scripts/{name}/start", json={}, timeout=5)
st = requests.get(f"{BASE}/scripts/{name}/status", timeout=5).json()
print(st["running"], st["engine"])PowerShell
$Base = "http://127.0.0.1:8765/api/v1"
(Invoke-RestMethod -Uri "$Base/scripts").scripts
Invoke-RestMethod -Method Post -Uri "$Base/scripts/MyScript/start"
Invoke-RestMethod -Uri "$Base/scripts/MyScript/status"
Invoke-RestMethod -Method Post -Uri "$Base/run/stop"