添加数据请求
使用 POST 请求创建数据下载请求。
HTTP URL | https://open.tiktokapis.com/v2/user/data/add/ |
HTTP 方法 | POST |
Scopes | portability.all.single, portability.all.ongoing, portability.activity.single, portability.activity.ongoing, portability.directmessages.single, portability.directmessages.ongoing, portability.postsandprofile.single, portability.postsandprofile.ongoing, |
Request
Headers
Key | Type | 描述 | 示例 | 必需 |
Authorization | string | 承载对 TikTok 用户授权的令牌,该令牌通过 /v2/oauth/token/ 获取 | Bearer clt.example12345Example12345Example | 是 |
Content-Type | string | 资源的原始媒体类型 | application/json | 是 |
查询参数
Key | Type | 描述 | 示例 | 必需 |
fields | string | 请求的字段:
| request_id | 是 |
Body
Key | Type | 描述 | 示例 | 必需 |
data_format | string | 将返回各个数据文件的格式。有效值为:
| “text” | 是 |
category_selection_list | list<string> | 要返回的数据类型。 参见 <Data Categories>。 有效值为:
| ["profile", "activity"] | 是 |
类别所需的 Scopes
Data Categories | 所需 Scopes |
activity | portability.activity.single, portability.activity.ongoing |
video, profile | portability.postsandprofile.single, portability.postsandprofile.ongoing |
direct_message | portability.directmessages.single, portability.directmessages.ongoing |
all_data, activity, video, profile, direct_message | portability.all.single, portability.all.ongoing |
备注:
- 如果在
category_selection_list中,将“all_data”作为参数发送,它将优先于其他类别。 - 对于任何 “
portability.*.single” 作用域,添加数据请求 只能调用一次以创建新的请求。 - 对于用户已授权多个
portability.*.single作用域的情况:
示例:
如果用户已授权 portability.all.single 和 portability.activity.single,并且发起了带有 "category_selection_list" : ["activity", "video"] 的请求。
将仅消耗 portability.all.single,因为它可访问所有类别。
发出请求后,当前访问令牌将包含该作用域(scope)portability.activity.single以及新的请求类别activity在当前请求完成后可发起,而无需从用户重新授权访问令牌。
请求示例
curl --location 'https://open.tiktokapis.com/v2/user/data/add/?fields=request_id' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer act.testTemp123testtemp123.e1' \
--data '{
"data_format": "text",
"category_selection_list": ["profile","direct_message"]
}'响应
Key | Type | 示例 |
data | AddUserDataResponseData | 查看下面的响应示例 |
error | ErrorStructV2 | 查看下面的响应示例 |
AddUserDataResponseData
Key | Type | 描述 | 示例 |
request_id | int64 | 用于跟踪下载数据请求的唯一 ID。要获取请求状态、取消请求以及下载数据,这将是必需的查询参数。 | 123451234512345 |
ErrorStructV2
Key | Type | 描述 | 示例 |
code | string | 以字符串形式表示的错误类别 | ok |
message | string | 详细的错误描述 | |
log_id | string | 用于调试的、与每个请求关联的唯一 ID | 1010xyz10101asdf1010101010100a12abc24 |
响应示例
{
"data": {
"request_id": 123451234512345
},
"error": {
"code": "ok",
"message": "",
"log_id": "1010xyz10101asdf1010101010100a12abc24"
}
}