---
title: "回放已存储的事件"
canonical_url: "https://tweetstream.io/zh-cn/docs/api/get-history"
last_updated: 2026-11-05
---

# 回放已存储的事件

按从新到旧返回已存储的事件。可以重复 handle 参数，或使用逗号分隔的值。

Canonical URL: https://tweetstream.io/zh-cn/docs/api/get-history

## `GET /api/history`

`https://api.tweetstream.io/api/history`

## 授权

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `Authorization` | `string`, 必填 | 使用 TweetStream API 密钥进行 Bearer 认证：`Bearer <key>`。 |

## 查询参数

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `handle` | `string` | 监控的 handle。可重复传入，或使用逗号分隔的列表。 |
| `handles` | `string` | handle 的别名。可重复传入，或使用逗号分隔的列表。 |
| `handle[]` | `string[]` | handle 的数组形式别名。 |
| `handles[]` | `string[]` | handles 的数组形式别名。 |
| `cursor` | `string` | 上一页 History 返回的稳定 cursor。 |
| `startDate` | `string` |  |
| `endDate` | `string` |  |
| `limit` | `integer` |  |
| `type` | `enum<string>` |  |

## 响应字段

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `data` | `object[]`, 必填 |  |
| `data.body` | `string`, 必填 |  |
| `data.content` | `object`, 必填 |  |
| `data.link` | `string`, 必填 |  |
| `data.messageType` | `enum<string>`, 必填 |  |
| `data.meta` | `object` |  |
| `data.receivedTime` | `string`, 必填 |  |
| `data.time` | `string`, 必填 |  |
| `data.tweetId` | `string`, 必填 |  |
| `data.twitterHandle` | `string \| null`, 必填 |  |
| `data.twitterId` | `string`, 必填 |  |
| `metadata` | `object`, 必填 |  |
| `metadata.count` | `integer`, 必填 |  |
| `metadata.endDate` | `string` |  |
| `metadata.handle` | `string` |  |
| `metadata.handles` | `string[]` |  |
| `metadata.nextCursor` | `string \| null`, 必填 |  |
| `metadata.startDate` | `string` |  |
| `metadata.type` | `enum<string>` |  |

## 响应

| 状态 | 说明 | 请求头 |
| --- | --- | --- |
| `200` | 成功 |  |
| `400` | 请求无效 |  |
| `401` | API key 缺失或无效 |  |
| `403` | 已认证的账号无法使用此功能 |  |
| `429` | 已达到速率限制 |  |
| `500` | 请求未能完成 |  |

### 200

```json
{
  "data": [
    {
      "tweetId": "account:affiliate:aff_01JQ8YQ5K8B8QKH6M0P8A1V2WX",
      "twitterId": "123",
      "twitterHandle": "organization",
      "body": "Added New Member (@newmember) to affiliate list",
      "time": "2025-04-09T00:00:00.123Z",
      "receivedTime": "2025-04-09T00:00:00.123Z",
      "link": "https://x.com/newmember",
      "messageType": "AFFILIATE",
      "content": {
        "action": "added",
        "eventId": "aff_01JQ8YQ5K8B8QKH6M0P8A1V2WX",
        "observedAt": 1744156800123,
        "receivedAt": 1744156800123,
        "organization": {
          "id": "123",
          "handle": "@organization",
          "name": "Organization",
          "verifiedType": "business"
        },
        "member": {
          "id": "456",
          "handle": "@newmember",
          "name": "New Member",
          "profileImage": "https://pbs.twimg.com/profile_images/newmember_normal.jpg"
        }
      }
    }
  ],
  "metadata": {
    "count": 1,
    "nextCursor": null,
    "type": "AFFILIATE"
  }
}
```

### 400

```json
{
  "error": "<string>"
}
```

### 401

```json
{
  "error": "<string>"
}
```

### 403

```json
{
  "error": "<string>"
}
```

### 429

```json
{
  "error": "<string>",
  "retryAfterSeconds": 0
}
```

### 500

```json
{
  "error": "<string>"
}
```

## 代码示例

### cURL

```bash
curl --request GET \
  --url https://api.tweetstream.io/api/history \
  --header "Authorization: Bearer $TWEETSTREAM_API_KEY"
```

### JavaScript

```javascript
const response = await fetch("https://api.tweetstream.io/api/history", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.TWEETSTREAM_API_KEY}`,
  },
});

console.log(response.status, await response.json());
```

### Python

```python
import os
import requests

response = requests.get(
    "https://api.tweetstream.io/api/history",
    headers={"Authorization": f"Bearer {os.environ['TWEETSTREAM_API_KEY']}"},
)

print(response.status_code, response.json())
```
