获取所有消息 GET
获取你账户中的所有消息列表。
端点
GET https://api.pocketalert.app/v1/messages身份验证
请求
请求头
| 请求头 | 必填 | 说明 |
|---|---|---|
Token | ✅ | 你的 API 密钥 |
Authorization | ✅ | Bearer <jwt-token> |
查询参数
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
sort | string | desc | 按创建时间排序(asc 或 desc) |
limit | integer | 50 | 返回消息的最大数量 |
请求示例
bash
curl -X GET "https://api.pocketalert.app/v1/messages?sort=desc&limit=10" \
-H "Token: your-api-key"javascript
const response = await fetch('https://api.pocketalert.app/v1/messages?sort=desc&limit=10', {
headers: { 'Token': 'your-api-key' }
});
const messages = await response.json();python
import requests
response = requests.get(
'https://api.pocketalert.app/v1/messages',
headers={'Token': 'your-api-key'},
params={'sort': 'desc', 'limit': 10}
)
print(response.json())php
$response = Http::withHeaders([
'Token' => 'your-api-key',
])->get('https://api.pocketalert.app/v1/messages', [
'sort' => 'desc',
'limit' => 10,
]);
return $response->json();响应
成功响应
200 OK
返回消息对象数组
| 字段 | 类型 | 说明 |
|---|---|---|
tid | string | 消息的唯一标识符 |
title | string | 消息标题 |
message | string | 消息正文 |
application | string | 应用名称 |
device | string | 目标设备 |
is_read | boolean | 消息是否已读 |
created_at | string | 创建时间戳 |
json
[
{
"tid": "jb4xw9elz24c5",
"title": "Server Alert",
"message": "CPU usage exceeded 90%",
"application": "Monitoring",
"device": "iPhone",
"is_read": true,
"created_at": "18.09.2023 17:35:35"
},
{
"tid": "d4u21qej1hld",
"title": "Deploy Complete",
"message": "Version 2.1.0 deployed",
"application": "CI/CD",
"device": "iPhone",
"is_read": false,
"created_at": "18.09.2023 17:35:23"
}
]错误响应
| 状态码 | 说明 |
|---|---|
401 | 未授权 — 令牌无效或缺失 |