今日头条文章详情 API (V1)
接口健康状态
健康 可用 少量可用 基本不可用 暂无数据
正在加载健康状态…
通过文章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.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 | 今日头条文章结果随附的状态消息。 |
响应示例
正在加载响应示例…