> ## Documentation Index
> Fetch the complete documentation index at: https://docs.akria.net/llms.txt
> Use this file to discover all available pages before exploring further.

# GET 健康检查

> 检查 API 服务和数据库连接状态

检查 API 服务和数据库连接状态。

## 核心特性

<CardGroup cols={3}>
  <Card title="无需认证" icon="unlock">
    可以直接访问，无需 API Key
  </Card>

  <Card title="快速响应" icon="zap">
    用于监控和负载均衡健康检查
  </Card>

  <Card title="数据库状态" icon="database">
    检查数据库连接状态
  </Card>
</CardGroup>

***

## 认证

<Info>
  此端点**不需要** API Key 认证，可以直接访问。
</Info>

***

## 请求参数

无参数。

***

## 响应

### 成功响应（200 OK）

<ResponseExample>
  ```json theme={null}
  {
    "status": "healthy",
    "database": "connected",
    "timestamp": "2026-02-02T10:00:00.000000"
  }
  ```
</ResponseExample>

<AccordionGroup>
  <Accordion title="字段说明">
    * **`status`**: 服务状态（`healthy` 表示正常，`unhealthy` 表示异常）
    * **`database`**: 数据库连接状态（`connected` 表示已连接，`disconnected` 表示未连接）
    * **`timestamp`**: 响应时间戳
  </Accordion>
</AccordionGroup>

### 数据库连接失败（503 Service Unavailable）

<ResponseExample>
  ```json theme={null}
  {
    "status": "unhealthy",
    "database": "disconnected",
    "timestamp": "2026-02-02T10:00:00.000000"
  }
  ```
</ResponseExample>

<Warning>
  如果数据库连接失败，`status` 会变为 `unhealthy`，`database` 会变为 `disconnected`。此时 API 可能无法正常工作。
</Warning>

***

## 使用示例

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.dev.akria.net/api/v1/health
  ```

  ```python Python theme={null}
  import requests

  response = requests.get("https://api.dev.akria.net/api/v1/health")
  data = response.json()

  if data["status"] == "healthy" and data["database"] == "connected":
      print("✅ API is healthy")
  else:
      print("❌ API is unhealthy")
  ```

  ```javascript JavaScript theme={null}
  const axios = require('axios');

  async function checkHealth() {
    try {
      const response = await axios.get('https://api.dev.akria.net/api/v1/health');
      const data = response.data;
      
      if (data.status === 'healthy' && data.database === 'connected') {
        console.log('✅ API is healthy');
      } else {
        console.log('❌ API is unhealthy');
      }
    } catch (error) {
      console.error('Health check failed:', error.message);
    }
  }

  checkHealth();
  ```
</CodeGroup>

***

## 使用场景

<CardGroup cols={2}>
  <Card title="监控系统" icon="activity">
    定期检查服务健康状态，及时发现异常
  </Card>

  <Card title="负载均衡" icon="server">
    作为健康检查端点，自动剔除不健康的实例
  </Card>

  <Card title="CI/CD 部署" icon="rocket">
    部署后验证服务是否正常启动
  </Card>

  <Card title="故障排查" icon="bug">
    快速判断服务是否正常运行
  </Card>
</CardGroup>

***

## 相关文档

<CardGroup cols={2}>
  <Card title="团队使用手册" icon="book" href="../../../services/core-api-v1/docs/API_USAGE_GUIDE.md">
    手把手教程，适合团队使用
  </Card>

  <Card title="Core API 介绍" icon="api" href="/technical/api-reference/core-api-introduction">
    Core API V1 完整介绍
  </Card>
</CardGroup>


## OpenAPI

````yaml GET /api/v1/health
openapi: 3.1.0
info:
  title: Core API V1
  description: Core API V1 - Pull 模式核心网关服务，用于接收信号并管理 Outbox
  version: 1.0.0
servers:
  - url: https://api.dev.akria.net
    description: Dev 环境
security:
  - apiKey: []
paths:
  /api/v1/health:
    get:
      tags:
        - health
      summary: 健康检查
      description: 检查 API 和数据库连接状态。无需认证。
      responses:
        '200':
          description: 服务正常
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthResponse'
              example:
                status: healthy
                database: connected
                timestamp: '2026-02-02T10:00:00Z'
        '503':
          description: 服务异常
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HealthResponse'
              example:
                status: unhealthy
                database: disconnected
                timestamp: '2026-02-02T10:00:00Z'
      security: []
components:
  schemas:
    HealthResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - healthy
            - unhealthy
          description: 服务状态
        database:
          type: string
          enum:
            - connected
            - disconnected
          description: 数据库连接状态
        timestamp:
          type: string
          format: date-time
          description: 检查时间
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: API 认证密钥

````