API 参考
通过编程方式访问 Architecto 的开发者文档
Architecto API 让你能够基于平台构建自定义应用、集成和工作流。
身份验证
所有 API 请求均须使用 API 密钥进行身份验证:
Authorization: Bearer YOUR_API_KEY创建 API 密钥
- 前往 设置 → 开发者 → API 密钥
- 点击 创建新密钥
- 输入名称并设置有效期(永不过期、30 天、90 天或 1 年)
- 选择权限范围(读取、写入、管理)
- 复制密钥(仅显示一次)
切勿公开分享 API 密钥。 请像保护密码一样保护它。
撤销 API 密钥
- 前往 设置 → 开发者 → API 密钥
- 点击密钥旁的 撤销
- 密钥立即失效
基础 URL
所有 API 端点均位于:
https://api.architecto.dev/v1常用端点
身份验证
POST /auth/login # Login and get session
POST /auth/logout # End session
POST /auth/refresh # Refresh access token架构
GET /architectures # List your architectures
POST /architectures # Create new architecture
GET /architectures/{id} # Get architecture details
PUT /architectures/{id} # Update architecture
DELETE /architectures/{id} # Delete architecture
GET /architectures/{id}/versions # Get version history分析
POST /architectures/{id}/analyze/cost # Run cost analysis
POST /architectures/{id}/analyze/scalability # Run scalability analysis
POST /architectures/{id}/analyze/threats # Run threat modeling文档
POST /architectures/{id}/documents/rfc # Generate RFC
POST /architectures/{id}/documents/adr # Generate ADR
POST /architectures/{id}/documents/runbook # Generate runbook分享
POST /architectures/{id}/shares # Create share link
GET /shares/{token} # Get shared architecture
POST /shares/{token}/comments # Add comment to shared arch团队
GET /organizations # List your organizations
POST /organizations # Create organization
GET /organizations/{id}/members # List team members
POST /organizations/{id}/invites # Invite team member错误处理
API 错误返回标准 HTTP 状态码:
{
"error": {
"code": "RESOURCE_NOT_FOUND",
"message": "Architecture with id 'arch_123' not found",
"details": {
"resource_type": "architecture",
"resource_id": "arch_123"
}
}
}常用状态码
| 状态码 | 含义 |
|---|---|
| 200 | 成功 |
| 400 | 请求有误(参数无效) |
| 401 | 未通过身份验证(API 密钥无效) |
| 403 | 禁止访问(权限不足) |
| 404 | 未找到 |
| 429 | 请求频率超限 |
| 500 | 服务器错误 |
速率限制
API 请求有以下速率限制:
- Free 套餐: 100 次请求/小时
- Pro 套餐: 1,000 次请求/小时
- Ultimate 套餐: 10,000 次请求/小时
速率限制信息位于响应头中:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1640995200示例:创建并分析架构
# 1. Create architecture
curl -X POST https://api.architecto.dev/v1/architectures \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"title": "E-commerce Platform",
"description": "Multi-region e-commerce with real-time inventory",
"cloud_provider": "aws"
}'
# Response:
# {
# "id": "arch_abc123",
# "title": "E-commerce Platform",
# "created_at": "2024-01-15T10:30:00Z"
# }
# 2. Run cost analysis
curl -X POST https://api.architecto.dev/v1/architectures/arch_abc123/analyze/cost \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"scale_points": [1000, 10000, 100000],
"region": "us-east-1"
}'
# Response:
# {
# "analysis_id": "analysis_xyz789",
# "estimates": [
# {
# "users": 1000,
# "monthly_cost": 150,
# "breakdown": { "compute": 80, "storage": 40, "data_transfer": 30 }
# },
# ...
# ]
# }Webhook(即将推出)
订阅架构事件:
POST /webhooks
{
"url": "https://your-app.com/webhook",
"events": ["architecture.created", "architecture.updated", "analysis.completed"]
}SDK
即将推出以下语言的官方 SDK:
- Python
- Node.js / TypeScript
- Go
- Ruby
- Java
交互式 API 文档
无需编写代码即可试用 API:
支持
- API 问题: 请提交至 GitHub Issues
- 使用疑问: 请在 Discord 社区提问
- 企业咨询: 请联系 sales@architecto.dev
后续步骤:
- 集成指南
- Webhook 设置 (即将推出)