跳至主要內容

今日頭條文章詳情 API (V1) ​

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

通過文章ID獲取今日頭條文章的詳情。用於查找已知文章以進行內容審查、歸檔或相關媒體分析。

請求參數 ​

參數名 位置 類型 必填 預設值 說明
token query string 是 - 訪問API所需的鑑權令牌。
id query string 是 - 頭條文章的唯一標識符。

程式碼範例 ​

bash
curl --max-time 120 -X GET 'https://api.justoneapi.com/api/toutiao/get-article-detail/v1?token=YOUR_API_KEY&id=VALUE'
text
我想使用 JustOneAPI 提供的“文章詳情 (V1)”接口。
接入地址: https://api.justoneapi.com。
接口路徑: /api/toutiao/get-article-detail/v1?token=YOUR_API_KEY&id=VALUE
接口地址: BASE_URL + /api/toutiao/get-article-detail/v1?token=YOUR_API_KEY&id=VALUE
HTTP 方法: GET
身份驗證: 在 URL 中傳入 token 查詢參數。
OpenAPI 定義: https://docs.justoneapi.com/openapi/toutiao/article-details-v1-zh-hant.json

請求參數說明:
- token (query): 訪問API所需的鑑權令牌。 (必填)
- id (query): 頭條文章的唯一標識符。 (必填)

返回格式: 請根據實際 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/toutiao/get-article-detail/v1?token=YOUR_API_KEY&id=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/toutiao/get-article-detail/v1?token=YOUR_API_KEY&id=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/toutiao/get-article-detail/v1?token=YOUR_API_KEY&id=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/toutiao/get-article-detail/v1?token=YOUR_API_KEY&id=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/toutiao/get-article-detail/v1?token=YOUR_API_KEY&id=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)的主要返回欄位。

正文和發佈信息21 個欄位

data.data

文章正文、發佈信息和媒體變體。

欄位 類型 說明
content string 以 HTML 文本返回的文章正文。
group_id integer 文章組 ID 的原始整數。JavaScript 中可使用 h5_extra.str_group_id 保留全部數字。
item_id integer 文章條目 ID 的原始整數。JavaScript 中可使用 h5_extra.str_item_id 保留全部數字。
media_user_id integer 以整數返回的發佈者用戶 ID。
video_count integer 平台返回的文章視頻數量。
audio_id string 文章隨附的字符串音頻 ID。
h5_extra object 文章、發佈者和互動資料的公開信息。
h5_extra.title string 接口返回的文章標題。
h5_extra.name string 文章隨附的發佈者展示名稱。
h5_extra.source string 隨文章展示的發佈來源文字。
h5_extra.src_link string 有提供時表示隨文章返回的來源連結。
h5_extra.avatar string 文章隨附的發佈者頭像連結。
h5_extra.publish_stamp string 文章發佈時間,以字符串返回秒級 Unix 時間戳。
h5_extra.publish_time string 文章發佈時間的展示文本,有時省略年份。覈對結果與 UTC+8 一致。
h5_extra.str_group_id string 以字符串返回的文章組 ID。可用該欄位完整保留 ID 的所有數字。
h5_extra.str_item_id string 以字符串返回的文章條目 ID。可用該欄位完整保留 ID 的所有數字。
h5_extra.media_user_id string 以字符串返回的發佈者用戶 ID。
h5_extra.is_original boolean 文章是否帶有原創標記。
h5_extra.video_count integer 文章展示信息中的視頻數量。
h5_extra.diversity object 隨文章返回的展示歸屬信息。
h5_extra.diversity.publish_loc_info string 用於展示的發佈地區文字。
發佈者資料19 個欄位

data.data.h5_extra

欄位 類型 說明
media object 文章隨附的公開發布者媒體資料。
media.id integer 平台返回的發佈者媒體資料數字 ID。
media.creator_id integer 媒體資料隨附的創作者數字 ID。
media.name string 平台返回的媒體資料展示名稱。
media.description string 發佈者的公開資料簡介。
media.avatar_url string 媒體資料隨附的頭像圖連結。
media.auth_info string 媒體資料公開展示的認證說明。
media.user_verified boolean 媒體資料是否帶有認證標記。
media.v boolean 平台返回的媒體資料認證徽章標記。
media.can_be_praised boolean 平台是否標記發佈者可接收讚賞。
itemCell.userInfo object 文章卡片隨附的公開發布者資料,可能缺省。
itemCell.userInfo.userID integer 該公開資料隨附的用戶數字 ID。
itemCell.userInfo.mediaID integer 該公開資料隨附的媒體數字 ID。
itemCell.userInfo.mediaType integer 平台返回的公開媒體資料類型碼。
itemCell.userInfo.name string 平台返回的公開用戶資料展示名稱。
itemCell.userInfo.description string 公開用戶資料的簡介文本。
itemCell.userInfo.avatarURL string 公開用戶資料隨附的頭像圖片連結。
itemCell.userInfo.userVerified integer 平台返回的用戶資料認證標記整數值。
itemCell.userInfo.verifiedContent string 該用戶資料公開展示的認證說明。
互動資料8 個欄位

data.data.h5_extra.itemCell.itemCounter

平台返回的互動和展現計數。

欄位 類型 說明
readCount integer 文章的閱讀數。
showCount integer 平台返回的文章展現數。
commentCount integer 文章的評論數。
diggCount integer 平台返回的文章點贊數。
repinCount integer 平台返回的文章收藏數。
forwardCount integer 平台返回的文章轉發數。
shareCount integer 平台返回的文章分享數。
videoWatchCount integer 文章信息隨附的視頻觀看數。
文章圖片24 個欄位

data.data

欄位 類型 說明
image_detail array 文章隨附的圖片詳情。
image_detail[].uri string 今日頭條返回的圖片資源標識。
image_detail[].url string 該圖片變體的主要連結。
image_detail[].width integer 平台返回的該圖片變體寬度。
image_detail[].height integer 平台返回的該圖片變體高度。
image_detail[].image_type integer 平台返回的該圖片變體類型碼。
image_detail[].url_list array 該圖片變體隨附的連結列表,可能包含主要連結。
image_detail[].url_list[].url string 平台返回的該圖片變體的一個連結。
main_image_list array 文章隨附的主要圖片變體。
main_image_list[].uri string 今日頭條返回的圖片資源標識。
main_image_list[].url string 該圖片變體的主要連結。
main_image_list[].width integer 平台返回的該圖片變體寬度。
main_image_list[].height integer 平台返回的該圖片變體高度。
main_image_list[].image_type integer 平台返回的該圖片變體類型碼。
main_image_list[].url_list array 該圖片變體隨附的連結列表,可能包含主要連結。
main_image_list[].url_list[].url string 平台返回的該圖片變體的一個連結。
origin_image_list array 平台返回的文章原圖變體。
origin_image_list[].uri string 今日頭條返回的圖片資源標識。
origin_image_list[].url string 該圖片變體的主要連結。
origin_image_list[].width integer 平台返回的該圖片變體寬度。
origin_image_list[].height integer 平台返回的該圖片變體高度。
origin_image_list[].image_type integer 平台返回的該圖片變體類型碼。
origin_image_list[].url_list array 該圖片變體隨附的連結列表,可能包含主要連結。
origin_image_list[].url_list[].url string 平台返回的該圖片變體的一個連結。
縮略圖和標題圖27 個欄位

data.data

欄位 類型 說明
thumb_image array 文章隨附的縮略圖變體。
thumb_image[].uri string 今日頭條返回的圖片資源標識。
thumb_image[].url string 該圖片變體的主要連結。
thumb_image[].width integer 平台返回的該圖片變體寬度。
thumb_image[].height integer 平台返回的該圖片變體高度。
thumb_image[].image_type integer 平台返回的該圖片變體類型碼。
thumb_image[].url_list array 該圖片變體隨附的連結列表,可能包含主要連結。
thumb_image[].url_list[].url string 平台返回的該圖片變體的一個連結。
webp_image_detail array WebP 變體列表中的文章圖片詳情。
webp_image_detail[].uri string 今日頭條返回的圖片資源標識。
webp_image_detail[].url string 該圖片變體的主要連結。
webp_image_detail[].width integer 平台返回的該圖片變體寬度。
webp_image_detail[].height integer 平台返回的該圖片變體高度。
webp_image_detail[].image_type integer 平台返回的該圖片變體類型碼。
webp_image_detail[].url_list array 該圖片變體隨附的連結列表,可能包含主要連結。
webp_image_detail[].url_list[].url string 平台返回的該圖片變體的一個連結。
webp_thumb_image array WebP 變體列表中的文章縮略圖。
webp_thumb_image[].uri string 今日頭條返回的圖片資源標識。
webp_thumb_image[].url string 該圖片變體的主要連結。
webp_thumb_image[].width integer 平台返回的該圖片變體寬度。
webp_thumb_image[].height integer 平台返回的該圖片變體高度。
webp_thumb_image[].image_type integer 平台返回的該圖片變體類型碼。
webp_thumb_image[].url_list array 該圖片變體隨附的連結列表,可能包含主要連結。
webp_thumb_image[].url_list[].url string 平台返回的該圖片變體的一個連結。
title_image object 文章標題圖變體,可能缺省。
title_image.title_image_url string 預設展示方式的文章標題圖連結。
title_image.title_image_night_url string 深色展示方式的文章標題圖連結。
音頻5 個欄位

data.data.h5_extra.audio_info

文章隨附的音頻信息,可能缺省。

欄位 類型 說明
audioID integer 音頻信息隨附的數字音頻 ID。
audioGroupID string 以字符串返回的音頻組 ID。
audioDuration integer 平台返回的音頻時長數值,時間單位尚未確認。
audioWatchCount integer 平台返回的音頻收聽數。
audioWatchCountShowText string 音頻收聽數的展示文字。
卡片分類和分享10 個欄位

data.data.h5_extra.itemCell

文章卡片資料和平台返回的互動信息。

欄位 類型 說明
articleBase object 文章的公開標識及版本信息。
articleBase.gidStr string 以字符串返回的文章組 ID。
articleBase.articleVersion integer 平台返回的文章版本號。
articleBase.itemStatus integer 今日頭條返回的文章狀態碼。
articleClassification object 今日頭條返回的公開文章分類信息。
articleClassification.articleType integer 平台返回的文章內容類型碼。
articleClassification.articleSubType integer 平台返回的文章內容子類型碼。
articleClassification.isOriginal boolean 文章分類信息中的原創標記。
shareInfo object 文章的公開分享信息。
shareInfo.shareURL string 今日頭條返回的文章分享連結。
平台狀態1 個欄位

data

今日頭條文章詳情和平台返回的狀態。

欄位 類型 說明
message string 今日頭條文章結果隨附的狀態消息。

回應示例 ​

正在載入回應範例…