健康检查
curl --request GET \
--url https://api.dev.akria.net/api/v1/healthimport requests
url = "https://api.dev.akria.net/api/v1/health"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.dev.akria.net/api/v1/health', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dev.akria.net/api/v1/health",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.dev.akria.net/api/v1/health"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.dev.akria.net/api/v1/health")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dev.akria.net/api/v1/health")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"status": "healthy",
"database": "connected",
"timestamp": "2026-02-02T10:00:00.000000"
}
Core API V1
GET 健康检查
检查 API 服务和数据库连接状态
GET
/
api
/
v1
/
health
健康检查
curl --request GET \
--url https://api.dev.akria.net/api/v1/healthimport requests
url = "https://api.dev.akria.net/api/v1/health"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.dev.akria.net/api/v1/health', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.dev.akria.net/api/v1/health",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.dev.akria.net/api/v1/health"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.dev.akria.net/api/v1/health")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.dev.akria.net/api/v1/health")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"status": "healthy",
"database": "connected",
"timestamp": "2026-02-02T10:00:00.000000"
}
检查 API 服务和数据库连接状态。
核心特性
无需认证
可以直接访问,无需 API Key
快速响应
用于监控和负载均衡健康检查
数据库状态
检查数据库连接状态
认证
此端点不需要 API Key 认证,可以直接访问。
请求参数
无参数。响应
成功响应(200 OK)
{
"status": "healthy",
"database": "connected",
"timestamp": "2026-02-02T10:00:00.000000"
}
字段说明
字段说明
status: 服务状态(healthy表示正常,unhealthy表示异常)database: 数据库连接状态(connected表示已连接,disconnected表示未连接)timestamp: 响应时间戳
数据库连接失败(503 Service Unavailable)
{
"status": "unhealthy",
"database": "disconnected",
"timestamp": "2026-02-02T10:00:00.000000"
}
如果数据库连接失败,
status 会变为 unhealthy,database 会变为 disconnected。此时 API 可能无法正常工作。使用示例
curl https://api.dev.akria.net/api/v1/health
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")
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();
使用场景
监控系统
定期检查服务健康状态,及时发现异常
负载均衡
作为健康检查端点,自动剔除不健康的实例
CI/CD 部署
部署后验证服务是否正常启动
故障排查
快速判断服务是否正常运行
相关文档
团队使用手册
手把手教程,适合团队使用
Core API 介绍
Core API V1 完整介绍