API 参考
内容提取
从 URL 异步提取文本内容,支持网页文章、Twitter/X、YouTube、微信公众号等多种来源。
内容提取
从任意 URL 异步提取文本内容。提交 URL 创建任务,然后轮询获取结果。
支持的来源
X / Twitter
个人主页和单条推文 — 抓取任意公开账号的最近动态,或提取单条推文及其上下文。
YouTube
提取任意公开 YouTube 视频的字幕文本和元数据。
微信公众号
提取微信公众号文章内容(mp.weixin.qq.com)。
网页文章
任意可公开访问的网页 — 提取文章正文、元数据和引用链接。
应用场景
- 播客素材采集 -- 抓取网页文章、推文或公众号内容,作为播客生成的输入源
- 内容摘要 -- 提取长文内容并生成摘要
- 社交媒体监控 -- 批量提取关键账号的推文
- 调研聚合 -- 从多个 URL 收集和结构化内容
创建提取任务
POST /v1/content/extract
请求示例:
curl -X POST "https://api.marswave.ai/openapi/v1/content/extract" \
-H "Authorization: Bearer $LISTENHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "url",
"uri": "https://example.com/article"
}
}'const response = await fetch('https://api.marswave.ai/openapi/v1/content/extract', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.LISTENHUB_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
source: {
type: 'url',
uri: 'https://example.com/article',
},
}),
});
const data = await response.json();
const taskId = data.data.taskId;
console.log('Task ID:', taskId);import os
import requests
response = requests.post(
'https://api.marswave.ai/openapi/v1/content/extract',
headers={'Authorization': f'Bearer {os.environ["LISTENHUB_API_KEY"]}'},
json={
'source': {
'type': 'url',
'uri': 'https://example.com/article',
}
}
)
data = response.json()
task_id = data['data']['taskId']
print('Task ID:', task_id)带选项(摘要 + 最大长度):
curl -X POST "https://api.marswave.ai/openapi/v1/content/extract" \
-H "Authorization: Bearer $LISTENHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "url",
"uri": "https://example.com/long-article"
},
"options": {
"summarize": true,
"maxLength": 5000
}
}'const response = await fetch('https://api.marswave.ai/openapi/v1/content/extract', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.LISTENHUB_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
source: {
type: 'url',
uri: 'https://example.com/long-article',
},
options: {
summarize: true,
maxLength: 5000,
},
}),
});
const data = await response.json();
console.log(data);import os
import requests
response = requests.post(
'https://api.marswave.ai/openapi/v1/content/extract',
headers={'Authorization': f'Bearer {os.environ["LISTENHUB_API_KEY"]}'},
json={
'source': {
'type': 'url',
'uri': 'https://example.com/long-article',
},
'options': {
'summarize': True,
'maxLength': 5000,
},
}
)
data = response.json()
print(data)Twitter/X 个人主页 URL(指定推文数量):
# 对于 Twitter/X 个人主页 URL,使用 twitter 选项控制获取推文数量
curl -X POST "https://api.marswave.ai/openapi/v1/content/extract" \
-H "Authorization: Bearer $LISTENHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "url",
"uri": "https://x.com/elonmusk"
},
"options": {
"twitter": {
"count": 50
}
}
}'const response = await fetch('https://api.marswave.ai/openapi/v1/content/extract', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.LISTENHUB_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
source: {
type: 'url',
uri: 'https://x.com/elonmusk',
},
options: {
twitter: {
count: 50,
},
},
}),
});
const data = await response.json();
console.log(data);import os
import requests
response = requests.post(
'https://api.marswave.ai/openapi/v1/content/extract',
headers={'Authorization': f'Bearer {os.environ["LISTENHUB_API_KEY"]}'},
json={
'source': {
'type': 'url',
'uri': 'https://x.com/elonmusk',
},
'options': {
'twitter': {
'count': 50,
},
},
}
)
data = response.json()
print(data)微信公众号文章:
curl -X POST "https://api.marswave.ai/openapi/v1/content/extract" \
-H "Authorization: Bearer $LISTENHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"source": {
"type": "url",
"uri": "https://mp.weixin.qq.com/s/XXXXXXXXXXXXXXXX"
}
}'const response = await fetch('https://api.marswave.ai/openapi/v1/content/extract', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.LISTENHUB_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
source: {
type: 'url',
uri: 'https://mp.weixin.qq.com/s/XXXXXXXXXXXXXXXX',
},
}),
});
const data = await response.json();
const taskId = data.data.taskId;import os
import requests
response = requests.post(
'https://api.marswave.ai/openapi/v1/content/extract',
headers={'Authorization': f'Bearer {os.environ["LISTENHUB_API_KEY"]}'},
json={
'source': {
'type': 'url',
'uri': 'https://mp.weixin.qq.com/s/XXXXXXXXXXXXXXXX',
}
}
)
data = response.json()
task_id = data['data']['taskId']请求参数:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
source | object | 是 | 提取来源 |
source.type | string | 是 | 必须为 "url" |
source.uri | string | 是 | 要提取内容的 URL |
options | object | 否 | 提取选项 |
options.summarize | boolean | 否 | 是否生成摘要 |
options.maxLength | integer | 否 | 内容最大长度(默认 100,000 字符,最大 500,000 字符) |
options.twitter | object | 否 | Twitter/X 专用选项 |
options.twitter.count | integer | 否 | 获取推文数量(1-100,默认 20) |
响应示例:
{
"code": 0,
"message": "success",
"data": {
"taskId": "{taskId}"
}
}查询任务状态
GET /v1/content/extract/{taskId}
请求示例:
curl -X GET "https://api.marswave.ai/openapi/v1/content/extract/{taskId}" \
-H "Authorization: Bearer $LISTENHUB_API_KEY"const result = await fetch(`https://api.marswave.ai/openapi/v1/content/extract/${taskId}`, {
headers: {
'Authorization': `Bearer ${process.env.LISTENHUB_API_KEY}`,
},
});
const data = await result.json();
console.log('Status:', data.data.status);import os
import requests
result = requests.get(
f'https://api.marswave.ai/openapi/v1/content/extract/{task_id}',
headers={'Authorization': f'Bearer {os.environ["LISTENHUB_API_KEY"]}'}
)
data = result.json()
print('Status:', data['data']['status'])路径参数:
| 字段 | 类型 | 说明 |
|---|---|---|
taskId | string | 创建接口返回的 24 位十六进制字符串 |
任务完成时的响应(status: "completed"):
{
"code": 0,
"message": "success",
"data": {
"taskId": "{taskId}",
"status": "completed",
"createdAt": "2025-04-09T12:00:00Z",
"data": {
"content": "提取的文章正文内容...",
"metadata": {
"title": "文章标题",
"author": "作者名称",
"publishedAt": "2025-04-01T08:00:00Z"
},
"references": [
"https://example.com/related-article"
]
},
"credits": 5,
"failCode": null,
"message": null
}
}处理中时 status 为 "processing",data 为 null。失败时 status 为 "failed",failCode 和 message 说明错误原因。
响应字段:
| 字段 | 类型 | 说明 |
|---|---|---|
taskId | string | 任务标识符 |
status | string | processing、completed 或 failed |
createdAt | string | ISO 8601 时间戳 |
data | object | 提取的内容(完成前为 null) |
data.content | string | 提取的文本内容 |
data.metadata | object | 页面元数据(标题、作者等) |
data.references | array | 内容中发现的引用 URL |
credits | integer | 消耗的积分 |
failCode | string | 错误码(成功时为 null) |
message | string | 错误信息(成功时为 null) |
注意事项
Twitter/X 个人主页 URL:
- 当源 URL 为 Twitter/X 个人主页(如
https://x.com/username)时,API 会获取最近的推文 - 使用
options.twitter.count控制获取推文数量(1-100,默认 20) - 非 Twitter URL 会忽略此选项
微信公众号:
- 使用完整的
mp.weixin.qq.com/s/...文章链接 - 提取结果包含文章正文和元数据
任务生命周期:
| 状态 | 说明 |
|---|---|
processing | 提取进行中 |
completed | 内容提取成功 |
failed | 提取失败 -- 请检查 failCode 和 message |
轮询建议:
- 首次等待:任务创建后等待 5 秒
- 轮询间隔:5 秒
- 典型完成时间:10-30 秒,取决于 URL 复杂度