# Taisly API 接口文档 - **OpenAPI Version:** `3.1.0` - **API Version:** `1.0.0` # Taisly API 接口文档 Taisly API 通过简单的 API 密钥认证,帮助您自动向多个社交媒体平台发布和转发视频。 ## 功能特点 - 同时上传视频并发布到多个平台 - 设置自动转发,将一个平台的内容自动转发到其他平台 - 定时发布帖子 - 管理已连接的社交媒体账号 - 查看发布历史和状态 ## 使用要求 - **套餐**: STARTER、INFLUENCER 或 PRO(免费套餐不支持 API) - **API 密钥**: 在控制台 生成 - **HTTPS**: 所有 API 请求必须使用 HTTPS ## 速率限制 | 套餐 | 每小时请求数 | | ---------- | ------ | | STARTER | 50 | | INFLUENCER | 200 | | PRO | 1000 | 超过速率限制时,您将收到 429 错误,其中 `retryAfter` 字段表示需要等待的秒数。 ## 安全建议 1. 切勿将 API 密钥提交到版本控制系统 2. 将密钥存储在环境变量中 3. 如果密钥泄露,请立即重新生成 4. 仅使用 HTTPS ## 视频要求 - **格式**: MP4、MOV 或其他常见视频格式 - **大小**: 最大 500MB - **时长**: 3-90 秒 - **比例**: 9:16 竖屏 ## 快速开始 ```bash # 1. 获取已连接的平台 curl -X GET https://app.taisly.com/api/private/platform/platforms \ -H "Authorization: Bearer taisly_your_api_key_here" # 2. 上传视频 curl -X POST https://app.taisly.com/api/private/post \ -H "Authorization: Bearer taisly_your_api_key_here" \ -F "video=@/path/to/video.mp4" \ -F "platforms=[\"platform_id_1\"]" \ -F "description=来看看我的新视频!" # 3. 查看发布历史 curl -X GET https://app.taisly.com/api/private/post/history \ -H "Authorization: Bearer taisly_your_api_key_here" ``` ## Python 示例 ```python import requests API_KEY = 'taisly_your_api_key_here' BASE_URL = 'https://app.taisly.com/api/private' headers = { 'Authorization': f'Bearer {API_KEY}' } # 获取平台列表 response = requests.get(f'{BASE_URL}/platform/platforms', headers=headers) platforms = response.json()['data'] print(f"已连接平台: {len(platforms)}") # 上传视频 files = {'video': open('video.mp4', 'rb')} data = { 'platforms': str([platforms[0]['_id']]), 'description': '我的视频描述' } response = requests.post(f'{BASE_URL}/post', headers=headers, files=files, data=data) print(response.json()) ``` ## Servers - **URL:** `https://app.taisly.com/api/private` - **Description:** 生产服务器 ## Operations ### 获取 API 密钥信息 - **Method:** `GET` - **Path:** `/user/api-key` - **Tags:** API 密钥管理 获取当前 API 密钥的相关信息。 #### Responses ##### Status: 200 ###### Content-Type: application/json ##### Status: 403 ###### Content-Type: application/json ##### Status: 500 ###### Content-Type: application/json ### 生成 API 密钥 - **Method:** `POST` - **Path:** `/user/api-key/generate` - **Tags:** API 密钥管理 生成新的 API 密钥。如果已有密钥,则会重新生成。 **重要提示**: - 完整密钥仅显示一次,请妥善保存。 - 重新生成后,旧密钥将立即失效。 #### Responses ##### Status: 200 ###### Content-Type: application/json ##### Status: 500 ###### Content-Type: application/json ### 撤销 API 密钥 - **Method:** `POST` - **Path:** `/user/api-key/revoke` - **Tags:** API 密钥管理 立即撤销当前 API 密钥。使用该密钥的所有请求将失败。 #### Responses ##### Status: 200 ###### Content-Type: application/json ##### Status: 403 ###### Content-Type: application/json ##### Status: 500 ###### Content-Type: application/json ### 获取已连接的平台 - **Method:** `GET` - **Path:** `/platform/platforms` - **Tags:** 平台 获取已连接到您账号的所有社交媒体账号列表。 #### Responses ##### Status: 200 ###### Content-Type: application/json ##### Status: 401 ###### Content-Type: application/json ##### Status: 403 ###### Content-Type: application/json ##### Status: 500 ###### Content-Type: application/json ### 创建帖子 - **Method:** `POST` - **Path:** `/post` - **Tags:** 帖子 上传视频并发布到一个或多个已连接的平台。 **视频要求**: - 格式:MP4、MOV 或其他常见视频格式 - 大小:最大 500MB - 时长:3-90 秒 - 比例:竖屏 9:16 **定时发布**: - 传入 `scheduled` 参数(毫秒级 Unix 时间戳)可设置定时发布(不传此参数则为立即发布) #### Request Body ##### Content-Type: multipart/form-data - **`platforms` (required)** `array` — 平台 ID 列表 **Items:** `string` - **`video` (required)** `string`, format: `binary` — - **`description`** `string` - **`previewTime`** `number` — 视频预览时间戳,单位秒(默认:0) - **`scheduled`** `string` **Example:** ```json { "video": {}, "platforms": [ "" ], "description": "", "previewTime": 1, "scheduled": "" } ``` #### Responses ##### Status: 200 ###### Content-Type: application/json ##### Status: 401 ###### Content-Type: application/json ##### Status: 403 ###### Content-Type: application/json ##### Status: 500 ###### Content-Type: application/json ### 获取发布历史 - **Method:** `GET` - **Path:** `/post/history` - **Tags:** 帖子 获取发布历史记录及每个平台的发布状态。 **分页**: - 使用 `page` 参数进行分页(每页 10 条) - 或使用 `startTime` 和 `endTime` 按日期范围筛选(返回所有匹配记录) **状态说明**: - PENDING:帖子排队中 - SUCCESS:发布成功 - FAILED:发布失败(查看 message 字段了解错误码) #### Responses ##### Status: 200 ###### Content-Type: application/json ##### Status: 401 ###### Content-Type: application/json ##### Status: 500 ###### Content-Type: application/json ### 取消定时帖子 - **Method:** `GET` - **Path:** `/post/cancelSchedule` - **Tags:** 帖子 取消已定时发布的帖子。帖子将被永久删除。 #### Responses ##### Status: 200 ###### Content-Type: application/json ##### Status: 401 ###### Content-Type: application/json ##### Status: 500 ###### Content-Type: application/json ### 获取转发配置 - **Method:** `GET` - **Path:** `/reposts` - **Tags:** 转发 获取所有已配置的自动转发规则。当您向「来源」平台发布内容时,系统会自动将其转发到所有「目标」平台。 #### Responses ##### Status: 200 ###### Content-Type: application/json ##### Status: 401 ###### Content-Type: application/json ##### Status: 500 ###### Content-Type: application/json ### 添加转发配置 - **Method:** `POST` - **Path:** `/repost/add` - **Tags:** 转发 配置自动转发规则,将一个平台的内容转发到其他平台。 **工作原理**: - 当您向「来源」平台发布内容时,系统会自动将其转发到所有「目标」平台 **注意**:系统会防止循环依赖。如果 B→A 已存在,则无法创建 A→B。 #### Request Body ##### Content-Type: application/json - **`from` (required)** `string` — 平台 ID - **`to` (required)** `array` — 目标平台 ID 列表 **Items:** `string` **Example:** ```json { "from": "", "to": [ "" ] } ``` #### Responses ##### Status: 200 ###### Content-Type: application/json ##### Status: 400 ###### Content-Type: application/json ##### Status: 401 ###### Content-Type: application/json ##### Status: 500 ###### Content-Type: application/json ### 删除转发配置 - **Method:** `POST` - **Path:** `/repost/delete` - **Tags:** 转发 删除自动转发规则。删除后,向来源平台发布的内容将不再自动转发。 #### Request Body ##### Content-Type: application/json - **`id` (required)** `string` **Example:** ```json { "id": "" } ``` #### Responses ##### Status: 200 ###### Content-Type: application/json ##### Status: 401 ###### Content-Type: application/json ##### Status: 500 ###### Content-Type: application/json ### 暂停/恢复转发配置 - **Method:** `POST` - **Path:** `/repost/pause` - **Tags:** 转发 暂停或恢复自动转发功能。适用于临时停止转发但不删除配置的场景。 #### Request Body ##### Content-Type: application/json - **`id` (required)** `string` - **`isPaused` (required)** `boolean` **Example:** ```json { "id": "", "isPaused": true } ``` #### Responses ##### Status: 200 ###### Content-Type: application/json ##### Status: 401 ###### Content-Type: application/json ##### Status: 500 ###### Content-Type: application/json