跳至主要內容

TikTok用戶發佈帖子 API (V1) ​

GET
API 端點健康狀態
健康 可用 少量可用 基本不可用 暫無資料
正在載入健康狀態…

獲取由 secUid 標識的 TikTok 用戶發佈的帖子,提供游標分頁和最新或最熱門排序。使用該接口瀏覽創作者的發佈歷史或繼續瀏覽其公開帖子流。

請求參數 ​

參數名 位置 類型 必填 預設值 說明
token query string 是 - 用於API訪問的安全令牌。
secUid query string 是 - 為 TikTok 用戶返回的不透明安全標識符。
cursor query string 否 0 分頁游標。第一頁使用 '0',然後使用上一個回應中返回的 max_cursor 值。
sort query string 否 LATEST 用戶帖子的排序條件。


可用值:

- LATEST:最新的帖子優先(預設)

- MOST_POPULAR:最熱門的帖子優先

程式碼範例 ​

bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/tiktok/get-user-post/v1?token=YOUR_API_KEY&secUid=VALUE'
text
我想使用 JustOneAPI 提供的“用戶發佈帖子 (V1)”接口。
接入地址: https://api.justoneapi.com。
接口路徑: /api/tiktok/get-user-post/v1?token=YOUR_API_KEY&secUid=VALUE
接口地址: BASE_URL + /api/tiktok/get-user-post/v1?token=YOUR_API_KEY&secUid=VALUE
HTTP 方法: GET
身份驗證: 在 URL 中傳入 token 查詢參數。
OpenAPI 定義: https://docs.justoneapi.com/openapi/tiktok/user-published-posts-v1-zh-hant.json

請求參數說明:
- token (query): 用於API訪問的安全令牌。 (必填)
- secUid (query): 為 TikTok 用戶返回的不透明安全標識符。 (必填)
- cursor (query): 分頁游標。第一頁使用 '0',然後使用上一個回應中返回的 max_cursor 值。
- sort (query): 用戶帖子的排序條件。

可用值:
- `LATEST`:最新的帖子優先(預設)
- `MOST_POPULAR`:最熱門的帖子優先

返回格式: 請根據實際 Content-Type 安全處理 JSON 或文本回應。

回應處理與錯誤代碼:
1. 需通過返回體中的 "code" 欄位判斷業務結果(code 為 0 表示成功)。
2. 逾時建議:建議將請求逾時時間設置為 120 秒;如果 120 秒偏長,請至少設置為 60 秒,但可能會有少量請求因逾時而未接收到結果。
3. 業務碼說明:
   - 0: 成功
   - 100: Token 無效或已失效
   - 301: 採集失敗,請重試
   - 302: 超出速率限制
   - 303: 超出每日配額
   - 400: 參數錯誤
   - 500: 內部伺服器錯誤
   - 600: 權限不足
   - 601: 帳戶餘額不足
   - 602: TOKEN 限額超限
4. code 601 表示帳戶共享餘額不足。code 602 表示當前 API TOKEN 自身的累計消費上限已達到。TOKEN 限額不是資金劃撥,多個 TOKEN 仍共享同一個帳戶餘額。

請幫我用我擅長的編程語言寫一個腳本來呼叫這個接口,並處理返回結果。
python
import requests

BASE_URL = "https://api.justoneapi.com"  # 由 OpenAPI servers 提供

url = BASE_URL + "/api/tiktok/get-user-post/v1?token=YOUR_API_KEY&secUid=VALUE"
response = requests.get(url, timeout=120)
print(response.status_code)
if response.content:
    content_type = response.headers.get("content-type", "").lower()
    if "json" in content_type:
        try:
            print(response.json())
        except ValueError:
            print(response.text)
    elif content_type.startswith("text/") or "xml" in content_type or content_type.split(";", 1)[0].strip() in {"application/javascript", "application/x-www-form-urlencoded", "application/graphql"}:
        print(response.text)
    else:
        with open("response.bin", "wb") as output:
            output.write(response.content)
        print(f"Saved {len(response.content)} bytes to response.bin")
js
const BASE_URL = "https://api.justoneapi.com"; // 由 OpenAPI servers 提供
const url = BASE_URL + "/api/tiktok/get-user-post/v1?token=YOUR_API_KEY&secUid=VALUE";

const response = await fetch(url, {
  method: "GET",
  signal: AbortSignal.timeout(120000)
});
console.log(response.status);
const responseBytes = await response.arrayBuffer();
if (responseBytes.byteLength) {
  const contentType = (response.headers.get("content-type") || "").toLowerCase();
  const mediaType = contentType.split(";", 1)[0].trim();
  const textual = contentType.startsWith("text/") || contentType.includes("json") || contentType.includes("xml") || ["application/javascript", "application/x-www-form-urlencoded", "application/graphql"].includes(mediaType);
  if (textual) {
    const responseText = new TextDecoder().decode(responseBytes);
    let data = responseText;
    if (contentType.includes("json")) {
      try { data = JSON.parse(responseText); } catch { /* Keep the raw body. */ }
    }
    console.log(data);
  } else {
    console.log(`Received ${responseBytes.byteLength} binary bytes`);
  }
}
java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
    public static void main(String[] args) throws Exception {
        final String BASE_URL = "https://api.justoneapi.com"; // 由 OpenAPI servers 提供
        final String url = BASE_URL + "/api/tiktok/get-user-post/v1?token=YOUR_API_KEY&secUid=VALUE";

        HttpClient client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(120)).build();
        HttpRequest.Builder builder = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .timeout(Duration.ofSeconds(120))
            .method("GET", HttpRequest.BodyPublishers.noBody());

        HttpRequest request = builder.build();

        HttpResponse<byte[]> response = client.send(request, HttpResponse.BodyHandlers.ofByteArray());
        System.out.println(response.statusCode());
        String contentType = response.headers().firstValue("content-type").orElse("").toLowerCase();
        String mediaType = contentType.split(";", 2)[0].trim();
        if (contentType.startsWith("text/") || contentType.contains("json") || contentType.contains("xml") || mediaType.equals("application/javascript") || mediaType.equals("application/x-www-form-urlencoded") || mediaType.equals("application/graphql")) {
            System.out.println(new String(response.body(), StandardCharsets.UTF_8));
        } else {
            Files.write(Path.of("response.bin"), response.body());
            System.out.println("Saved " + response.body().length + " bytes to response.bin");
        }
    }
}
go
package main

import (
	"fmt"
	"io"
	"os"
	"strings"
	"net/http"
	"time"
)

const BASE_URL = "https://api.justoneapi.com" // 由 OpenAPI servers 提供

func main() {
	client := &http.Client{Timeout: 120 * time.Second}
	url := BASE_URL + "/api/tiktok/get-user-post/v1?token=YOUR_API_KEY&secUid=VALUE"
	req, _ := http.NewRequest("GET", url, nil)
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	fmt.Println(resp.StatusCode)
	bodyBytes, _ := io.ReadAll(resp.Body)
	contentType := strings.ToLower(resp.Header.Get("Content-Type"))
	mediaType := strings.TrimSpace(strings.SplitN(contentType, ";", 2)[0])
	if strings.HasPrefix(contentType, "text/") || strings.Contains(contentType, "json") || strings.Contains(contentType, "xml") || mediaType == "application/javascript" || mediaType == "application/x-www-form-urlencoded" || mediaType == "application/graphql" {
		fmt.Println(string(bodyBytes))
	} else {
		os.WriteFile("response.bin", bodyBytes, 0600)
		fmt.Printf("Saved %d bytes to response.bin\n", len(bodyBytes))
	}
}
php
<?php
$BASE_URL = 'https://api.justoneapi.com'; // 由 OpenAPI servers 提供
$url = $BASE_URL . '/api/tiktok/get-user-post/v1?token=YOUR_API_KEY&secUid=VALUE';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$contentType = strtolower((string) curl_getinfo($ch, CURLINFO_CONTENT_TYPE));
curl_close($ch);
echo $status . PHP_EOL;
$mediaType = trim(explode(';', $contentType, 2)[0]);
if (str_starts_with($contentType, 'text/') || str_contains($contentType, 'json') || str_contains($contentType, 'xml') || in_array($mediaType, ['application/javascript', 'application/x-www-form-urlencoded', 'application/graphql'], true)) {
    echo $response;
} else {
    file_put_contents('response.bin', $response);
    echo 'Saved ' . strlen($response) . ' bytes to response.bin' . PHP_EOL;
}

返回欄位 ​

業務成功時(code = 0)的主要返回欄位。

作品基礎信息7 個欄位

data.aweme_list[]

當前頁返回的作品。LATEST 和 MOST_POPULAR 可能返回相同作品。

欄位 類型 說明
aweme_id string TikTok 作品 ID,以字符串返回。
desc string 作品的文案。
create_time integer 作品創建時間,使用 Unix 秒級時間戳。
desc_language string TikTok 返回的作品文案語言標籤。
aweme_type integer TikTok 返回的作品類型編碼。
is_top integer 作品置頂標記,以整數返回,1 表示置頂。
is_ads boolean TikTok 是否將作品標記為廣告。
作者與協作者18 個欄位

data.aweme_list[]

欄位 類型 說明
author_user_id integer 作者 ID,以整數返回,可能超出 JavaScript 安全整數範圍。需要精確保留 ID 時使用 author.uid。
author object 作品作者的公開資料摘要。
author.uid string TikTok 作者 ID 字符串。JavaScript 中可使用此欄位保留 ID 的精度。
author.nickname string 作品作者的資料顯示名稱。
author.unique_id string 作品作者的 TikTok 公開用戶名。
author.follower_count integer TikTok 報告的作者粉絲數。
author.following_count integer TikTok 報告的作者關注帳號數。
author.aweme_count integer TikTok 報告的作者作品數。
author.total_favorited integer 作者資料摘要報告的累計獲贊數。
author.custom_verify string 可用時返回作者資料的認證文字。
author.enterprise_verify_reason string 可用時返回作者資料的企業認證文字。
collab_info object 可用時返回合作創作信息。
collab_info.collaborators array 作品列出的協作者資料。
collab_info.collaborators[] object 一條協作者記錄。
collab_info.collaborators[].user_info object 此協作者的公開資料摘要。
collab_info.collaborators[].user_info.uid string TikTok 協作者 ID 字符串。
collab_info.collaborators[].user_info.nickname string 協作者的展示名稱。
collab_info.collaborators[].user_info.unique_id string 協作者的 TikTok 公開用戶名。
互動與可用狀態16 個欄位

data.aweme_list[]

欄位 類型 說明
prevent_download boolean TikTok 是否標記此作品限制下載。
statistics object TikTok 返回的該作品互動資料。
statistics.aweme_id string 此統計對象所對應的作品 ID。
statistics.play_count integer TikTok 報告的作品播放量。
statistics.digg_count integer 平台返回的作品點贊數。
statistics.comment_count integer 平台返回的帖子評論數。
statistics.share_count integer 平台返回的作品分享數。
statistics.collect_count integer TikTok 報告的作品收藏數。
statistics.download_count integer TikTok 報告的作品下載數。
statistics.repost_count integer TikTok 報告的作品轉發數。
statistics.whatsapp_share_count integer TikTok 報告的 WhatsApp 分享數。
status object TikTok 返回的該作品可用狀態。
status.aweme_id string 此狀態對象所對應的作品 ID。
status.allow_share boolean 作品狀態是否顯示允許分享。
status.allow_comment boolean 作品狀態是否顯示允許評論。
status.is_delete boolean TikTok 是否將該作品標記為已刪除。
視頻15 個欄位

data.aweme_list[]

欄位 類型 說明
video object 視頻元資料。圖文作品也可能帶有此對象。
video.duration integer 視頻時長,單位為毫秒。圖文作品可能帶有時長為 0 的視頻佔位資料。
video.width integer 視頻寬度,單位為像素。
video.height integer 視頻高度,單位為像素。
video.ratio string TikTok 返回的視頻分辨率標籤。
video.play_addr object 播放資源的元資料。
video.play_addr.data_size integer 播放資源的大小,單位為字節。
video.bit_rate array 可用的視頻編碼版本,數組可以為空。
video.bit_rate[] object 一個視頻編碼版本。
video.bit_rate[].gear_name string TikTok 返回的視頻編碼版本標籤。
video.bit_rate[].quality_type integer 此編碼版本的畫質編碼。
video.bit_rate[].bit_rate integer 此編碼版本的碼率,單位為比特每秒。
video.bit_rate[].fps integer 此編碼版本的幀率,單位為幀每秒。
video.bit_rate[].play_addr object 播放資源的元資料。
video.bit_rate[].play_addr.data_size integer 播放資源的大小,單位為字節。
圖文相冊29 個欄位

data.aweme_list[]

欄位 類型 說明
image_post_info object 可用時返回圖文作品元資料。當 images 包含圖片時,該作品為圖文作品。
image_post_info.title string 圖文作品標題。
image_post_info.images array 圖文作品相冊中的圖片。
image_post_info.images[] object 相冊中的一張圖片。
image_post_info.images[].display_image object 展示版圖片的尺寸。
image_post_info.images[].display_image.width integer 圖片寬度,單位為像素。
image_post_info.images[].display_image.height integer 圖片高度,單位為像素。
image_post_info.images[].thumbnail object 縮略圖的尺寸。
image_post_info.images[].thumbnail.width integer 圖片寬度,單位為像素。
image_post_info.images[].thumbnail.height integer 圖片高度,單位為像素。
image_post_info.images[].owner_watermark_image object 帶作者水印版本的圖片尺寸。
image_post_info.images[].owner_watermark_image.width integer 圖片寬度,單位為像素。
image_post_info.images[].owner_watermark_image.height integer 圖片高度,單位為像素。
image_post_info.images[].user_watermark_image object 帶用戶水印版本的圖片尺寸。
image_post_info.images[].user_watermark_image.width integer 圖片寬度,單位為像素。
image_post_info.images[].user_watermark_image.height integer 圖片高度,單位為像素。
image_post_info.image_post_cover object 圖文作品的封面及各版本尺寸。
image_post_info.image_post_cover.display_image object 展示版圖片的尺寸。
image_post_info.image_post_cover.display_image.width integer 圖片寬度,單位為像素。
image_post_info.image_post_cover.display_image.height integer 圖片高度,單位為像素。
image_post_info.image_post_cover.thumbnail object 縮略圖的尺寸。
image_post_info.image_post_cover.thumbnail.width integer 圖片寬度,單位為像素。
image_post_info.image_post_cover.thumbnail.height integer 圖片高度,單位為像素。
image_post_info.image_post_cover.owner_watermark_image object 帶作者水印版本的圖片尺寸。
image_post_info.image_post_cover.owner_watermark_image.width integer 圖片寬度,單位為像素。
image_post_info.image_post_cover.owner_watermark_image.height integer 圖片高度,單位為像素。
image_post_info.image_post_cover.user_watermark_image object 帶用戶水印版本的圖片尺寸。
image_post_info.image_post_cover.user_watermark_image.width integer 圖片寬度,單位為像素。
image_post_info.image_post_cover.user_watermark_image.height integer 圖片高度,單位為像素。
音頻10 個欄位

data.aweme_list[]

欄位 類型 說明
music object 作品含有音頻元資料時返回的音頻信息。
music.id_str string TikTok 音頻 ID 字符串。
music.title string 作品所附音頻的名稱。
music.author string 音頻顯示的藝人或創作者署名。
music.album string 可用時返回音頻顯示的專輯名稱。
music.duration integer TikTok 返回的該音頻時長數值。
music.is_original_sound boolean TikTok 是否將該音頻標註為原聲。
music.is_commerce_music boolean TikTok 返回的該音頻商用音樂標記。
music_begin_time_in_ms integer TikTok 返回的作品音頻的起始偏移,單位為毫秒。
music_end_time_in_ms integer TikTok 返回的作品音頻的結束偏移,單位為毫秒。
話題與文案標註14 個欄位

data.aweme_list[]

欄位 類型 說明
cha_list array | null 可用時返回作品關聯的話題或挑戰,欄位值可以為 null。
cha_list[] object TikTok 返回的一個話題或挑戰。
cha_list[].cid string TikTok 話題或挑戰 ID。
cha_list[].cha_name string 話題或挑戰的展示名稱。
cha_list[].desc string TikTok 返回的話題或挑戰說明。
cha_list[].view_count integer TikTok 報告的話題或挑戰瀏覽量。
cha_list[].use_count integer TikTok 報告的話題或挑戰使用量。
text_extra array 作品文案中的附加標註。
text_extra[] object 一條文案標註。
text_extra[].start integer TikTok 返回的文案標註起始位置。樣本中的話題位置按 UTF-16 代碼單元計算。
text_extra[].end integer TikTok 返回的文案標註結束位置。樣本中的話題位置按 UTF-16 代碼單元計算。
text_extra[].type integer TikTok 返回的文案標註類型編碼。
text_extra[].hashtag_name string 此標註為話題時返回的話題名稱。
text_extra[].hashtag_id string 此標註為話題時返回的話題 ID。
分頁與狀態碼5 個欄位

data

欄位 類型 說明
status_code integer 此結果的 TikTok 狀態碼。外層 code 是 JustOneAPI 的業務狀態碼。
status_msg string TikTok 返回的狀態消息。
min_cursor integer TikTok 返回的另一分頁邊界游標。
max_cursor integer 續頁游標。has_more 為 1 時,將此值原樣轉換為十進制字符串,用於同一用戶和排序的下一頁 cursor 參數。
has_more integer TikTok 返回的分頁標記。1 表示還有下一頁,0 表示已到末頁。

回應示例 ​

正在載入回應範例…