快速開始
1. 取得 API Key會計資料 API 使用
X-Api-Key 保護,請由系統管理員核發並存放於伺服器端密鑰管理。2. 呼叫健康檢查先確認網路、TLS、Host 與 Header 設定都正確。
3. 串接業務資料依租戶
firmId 與 companyId 讀取需要的會計資料。curl -sS "https://accounting.sun-bd.com/api/v1/accounting/health" \
-H "X-Api-Key: YOUR_API_KEY"
集中會員整合
本專案已移除本地會員系統。網頁版登入會透過同源路徑 /api/central-member/login 轉送至集中會員 API;後端會以 JWKS 驗證 RS256 JWT,並由集中會員 API 取得有效權限。
會員登入、登出、refresh、權限與 JWKS 的完整規格請看 集中會員 API 教學頁。
統一回應格式
{
"success": true,
"data": { "...": "..." },
"error": null,
"timestamp": "2026-05-30T00:00:00Z",
"traceId": "0H..."
}
失敗時請以 error.code 與 HTTP status 做程式判斷,不要依錯誤文字判斷。
主要端點
| 功能 | Method | Path |
|---|---|---|
| 健康檢查 | GET | /api/v1/accounting/health |
| 會計摘要 | GET | /api/v1/accounting/firms/{firmId}/companies/{companyId}/summary |
| 科目表 | GET | /api/v1/accounting/firms/{firmId}/companies/{companyId}/chart-of-accounts |
| 傳票列表 | GET | /api/v1/accounting/firms/{firmId}/companies/{companyId}/vouchers |
| 日記帳 | GET | /api/v1/accounting/firms/{firmId}/companies/{companyId}/journal |
| 分類帳 | GET | /api/v1/accounting/firms/{firmId}/companies/{companyId}/ledger |
| 試算表 | GET | /api/v1/accounting/firms/{firmId}/companies/{companyId}/trial-balance |
| 資產負債表 | GET | /api/v1/accounting/firms/{firmId}/companies/{companyId}/reports/balance-sheet |
| 損益表 | GET | /api/v1/accounting/firms/{firmId}/companies/{companyId}/reports/income-statement |
查詢範例
會計摘要
curl -sS "https://accounting.sun-bd.com/api/v1/accounting/firms/FIRM001/companies/COMP001/summary?dateFrom=2026-01-01&dateTo=2026-12-31" \
-H "X-Api-Key: YOUR_API_KEY"
Node.js
const response = await fetch(
"https://accounting.sun-bd.com/api/v1/accounting/firms/FIRM001/companies/COMP001/trial-balance",
{ headers: { "X-Api-Key": process.env.WEMS_ACCOUNTING_API_KEY } }
);
const payload = await response.json();
.NET
using var client = new HttpClient { BaseAddress = new Uri("https://accounting.sun-bd.com") };
client.DefaultRequestHeaders.Add("X-Api-Key", apiKeyFromSecretStore);
var payload = await client.GetFromJsonAsync<object>(
"/api/v1/accounting/firms/FIRM001/companies/COMP001/chart-of-accounts");
錯誤處理
| HTTP | 常見原因 | 處理方式 |
|---|---|---|
| 401 | 缺少或錯誤的 API Key、會員 token 無效 | 確認 Header,必要時重新登入集中會員系統。 |
| 400 | 日期、分頁或參數格式錯誤 | 修正查詢參數後重試。 |
| 404 | 資源或租戶資料不存在 | 確認 firmId/companyId 與資料權限。 |
| 503 | 服務或設定未完成 | 保留 traceId 並通知系統管理員。 |