Files
siriusscan--sirius/documentation/dev/templates/TEMPLATE.api.md
T
wehub-resource-sync 161ef94b4f
Check engine pin consistency / Dockerfile / CI pin consistency (push) Successful in 8s
Sirius CI/CD Pipeline / Detect Changes (push) Successful in 23s
Validate Docker Configuration / Validate Docker Compose Configuration (push) Successful in 47s
Sirius CI/CD Pipeline / Build API (${{ matrix.platform }}) (push) Has been cancelled
Sirius CI/CD Pipeline / Build UI (${{ matrix.platform }}) (push) Has been cancelled
Sirius CI/CD Pipeline / Merge Engine Manifest (push) Has been cancelled
Sirius CI/CD Pipeline / Merge API Manifest (push) Has been cancelled
Sirius CI/CD Pipeline / Merge UI Manifest (push) Has been cancelled
Sirius CI/CD Pipeline / Build Engine (${{ matrix.platform }}) (push) Has been cancelled
Sirius CI/CD Pipeline / Build Infra (${{ matrix.service }}, ${{ matrix.platform }}) (push) Has been cancelled
Sirius CI/CD Pipeline / Merge Infra Manifest (sirius-postgres) (push) Has been cancelled
Sirius CI/CD Pipeline / Merge Infra Manifest (sirius-rabbitmq) (push) Has been cancelled
Sirius CI/CD Pipeline / Merge Infra Manifest (sirius-valkey) (push) Has been cancelled
Sirius CI/CD Pipeline / Integration Test (push) Has been cancelled
Sirius CI/CD Pipeline / Public Stack Contract (push) Has been cancelled
Sirius CI/CD Pipeline / Dispatch Demo Deployment (sirius-demo branch) (push) Has been cancelled
Sirius CI/CD Pipeline / Dispatch Demo Canary (main branch) (push) Has been cancelled
Sirius CI/CD Pipeline / Guard Registry Namespace (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:32:25 +08:00

273 lines
6.8 KiB
Markdown

---
title: "API Documentation Template"
description: "This template defines the standard structure and conventions for API documents within the Sirius project, ensuring comprehensive API specifications and usage documentation."
template: "TEMPLATE.template"
version: "1.0.0"
last_updated: "2025-01-03"
author: "AI Assistant"
tags: ["template", "api", "endpoints", "specifications", "integration"]
categories: ["project-management", "development"]
difficulty: "intermediate"
prerequisites: ["ABOUT.documentation.md"]
related_docs:
- "ABOUT.documentation.md"
- "TEMPLATE.documentation-standard.md"
dependencies: []
llm_context: "high"
search_keywords:
["api template", "endpoints", "api documentation", "integration specs"]
---
# [API Name] API Documentation
## Purpose
This document provides comprehensive API documentation for [specific API/service] within the Sirius project. API documents serve as authoritative sources for endpoint specifications, request/response formats, authentication, and integration examples.
## When to Use
- **API Integration**: When implementing client applications
- **API Development**: When building or modifying API endpoints
- **Testing**: When writing tests for API functionality
- **Debugging**: When troubleshooting API issues
- **Code Review**: When reviewing API implementation
## How to Use
### Quick Start
1. **Check the Base URL** and authentication requirements
2. **Review the Common Patterns** for typical usage
3. **Find the specific endpoint** you need
4. **Follow the examples** for implementation
5. **Use the troubleshooting section** for common issues
### Base URL
```
http://localhost:9001/api/v1
```
### Authentication
[Description of authentication method - API key, JWT, OAuth, etc.]
```bash
# Example authentication
curl -H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
http://localhost:9001/api/v1/endpoint
```
## What It Is
### API Overview
[Description of what this API does, its purpose, and key capabilities]
### Endpoints
#### [Endpoint 1]
- **Method**: `GET|POST|PUT|DELETE`
- **Path**: `/api/v1/endpoint1`
- **Description**: [What this endpoint does]
- **Authentication**: [Required/Optional]
- **Parameters**:
- `param1` (required, string): [Description]
- `param2` (optional, integer): [Description]
- **Request Body**: [If applicable]
- **Response**: [Response format and status codes]
- **Example Request**:
```bash
curl -X GET "http://localhost:9001/api/v1/endpoint1?param1=value&param2=123" \
-H "Authorization: Bearer <token>"
```
- **Example Response**:
```json
{
"status": "success",
"data": {
"field1": "value1",
"field2": "value2"
}
}
```
#### [Endpoint 2]
- **Method**: `GET|POST|PUT|DELETE`
- **Path**: `/api/v1/endpoint2`
- **Description**: [What this endpoint does]
- **Authentication**: [Required/Optional]
- **Request Body**:
```json
{
"field1": "string",
"field2": "integer",
"field3": {
"nested_field": "string"
}
}
```
- **Response**: [Response format and status codes]
- **Example Request**:
```bash
curl -X POST "http://localhost:9001/api/v1/endpoint2" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"field1": "value1",
"field2": 123,
"field3": {
"nested_field": "nested_value"
}
}'
```
- **Example Response**:
```json
{
"status": "success",
"data": {
"id": "generated_id",
"field1": "value1",
"field2": 123
}
}
```
### Data Models
#### [Model 1]
```json
{
"id": "string",
"name": "string",
"description": "string",
"created_at": "datetime",
"updated_at": "datetime"
}
```
#### [Model 2]
```json
{
"id": "string",
"field1": "string",
"field2": "integer",
"field3": {
"nested_field": "string"
},
"field4": ["string"]
}
```
### Error Responses
#### Standard Error Format
```json
{
"status": "error",
"error": {
"code": "ERROR_CODE",
"message": "Human readable error message",
"details": "Additional error details"
}
}
```
#### Common Error Codes
| Code | HTTP Status | Description | Resolution |
| ----------------- | ----------- | ------------------------- | ---------------------------------- |
| `INVALID_REQUEST` | 400 | Request format is invalid | Check request body and parameters |
| `UNAUTHORIZED` | 401 | Authentication required | Provide valid authentication token |
| `FORBIDDEN` | 403 | Insufficient permissions | Check user permissions |
| `NOT_FOUND` | 404 | Resource not found | Verify resource ID and existence |
| `INTERNAL_ERROR` | 500 | Server error | Contact support or retry later |
### Rate Limiting
- **Limit**: [Requests per time period]
- **Headers**: [Rate limit headers returned]
- **Example**: `X-RateLimit-Limit: 1000, X-RateLimit-Remaining: 999`
### Pagination
- **Method**: [Offset-based, cursor-based, etc.]
- **Parameters**: [page, limit, offset, etc.]
- **Response Format**: [How pagination data is returned]
```json
{
"data": [...],
"pagination": {
"page": 1,
"limit": 20,
"total": 100,
"pages": 5
}
}
```
## Troubleshooting
### FAQ
**Q: [Common API question 1]**
A: [Answer with specific examples and solutions]
**Q: [Common API question 2]**
A: [Answer with specific examples and solutions]
**Q: [Common API question 3]**
A: [Answer with specific examples and solutions]
### Command Reference
| Command | Purpose | Example | Notes |
| -------------- | -------------- | ----------- | ------------------ |
| `curl -X GET` | [What it does] | `[example]` | [Additional notes] |
| `curl -X POST` | [What it does] | `[example]` | [Additional notes] |
| `curl -X PUT` | [What it does] | `[example]` | [Additional notes] |
### Common Issues
| Issue | Symptoms | Root Cause | Solution |
| --------- | ----------------- | ---------------- | ------------------ |
| [Issue 1] | [How to identify] | [Why it happens] | [Step-by-step fix] |
| [Issue 2] | [How to identify] | [Why it happens] | [Step-by-step fix] |
| [Issue 3] | [How to identify] | [Why it happens] | [Step-by-step fix] |
### Debugging Steps
1. **Check [specific thing]**: [How to check and what to look for]
2. **Verify [specific thing]**: [How to verify and expected results]
3. **Test [specific thing]**: [How to test and success criteria]
4. **Review [specific thing]**: [What to review and common patterns]
## Lessons Learned
### [Date] - [What was learned]
[Description of API lesson learned and how it improved the system]
### [Date] - [What was learned]
[Description of API lesson learned and how it improved the system]
---
_This document follows the Sirius Documentation Standard. For questions about documentation structure, see [ABOUT.documentation.md](../ABOUT.documentation.md)._