快速开始
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 并通知系统管理员。 |