接口参考 · 社交媒体
YouTube Search
Search YouTube videos, Shorts, and creator channels with query and region parameters.
示例
BASH
curl -X POST 'https://api.serpbase.dev/youtube/search' \
-H "Content-Type: application/json" \
-H 'X-API-Key: YOUR_API_KEY' \
--max-time 60 \
-d '{"gl":"us","q":"nextjs tutorial"}'返回 · 真实返回,已缩短
{
"status": 0,
"credits_charged": 1,
"request_id": "r-4b27fe8a36d9ac303a5da7dd",
"product_id": "youtube_search",
"query": "nextjs tutorial",
"action": "search",
"pagination": {
"has_more": true,
"next_cursor": "EpkEEg9uZXh0anMgdHV0b3JpYWwaggRTQlNDQVF0NGJrOTNUMEpaWVVFemQ0SUJDMU5yYkdOZlpsRkNiV056Z2dFTFdsWnVhazlR…"
},
"source": "youtube",
"url": "https://www.youtube.com/results?gl=US&search_query=nextjs+tutorial",
"videos": [
{
"badges": [
"4K"
],
"channel": {
"id": "UC8S4rDRZn6Z_StJ-hh7ph8g",
"image_url": "https://yt3.ggpht.com/Qizn_VAgeCADuMk0RhVQ11j_9TWKrtQ1ifDGo5Yomj4Kjx29OgnHuZc6dQds5jztNlk3LAt6NA=s68…",
"link": "https://www.youtube.com/channel/UC8S4rDRZn6Z_StJ-hh7ph8g",
"title": "PedroTech",
"url": "https://www.youtube.com/channel/UC8S4rDRZn6Z_StJ-hh7ph8g",
"verified": true
},
"description": "If you know react, but don't know what NextJS is, this is the video for you. NextJS offers a variety…",
"duration": "7:35",
"id": "xnOwOBYaA3w",
"link": "https://www.youtube.com/watch?v=xnOwOBYaA3w",
"media": [
{
"type": "thumbnail",
"url": "https://i.ytimg.com/vi/xnOwOBYaA3w/hq720.jpg?sqp=-oaymwEcCNAFEJQDSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs…"
}
],
"published_at": "1y ago",
"title": "Learn NextJS in 7 Minutes",
"url": "https://www.youtube.com/watch?v=xnOwOBYaA3w",
"views_count": "301453"
},
{
"badges": [
"4K"
],
"channel": {
"id": "UCsBjURrPoezykLs9EqgamOA",
"image_url": "https://yt3.ggpht.com/3fPNbkf_xPyCleq77ZhcxyeorY97NtMHVNUbaAON_RBDH9ydL4hJkjxC8x_4mpuopkB8oI7Ct6Y=s6…",
"link": "https://www.youtube.com/channel/UCsBjURrPoezykLs9EqgamOA",
"title": "Fireship",
"url": "https://www.youtube.com/channel/UCsBjURrPoezykLs9EqgamOA",
"verified": true
},
"description": "Learn the basics of Next.js in 100 Seconds! Then build your first server-rendered react app with a f…",
"duration": "11:52",
"id": "Sklc_fQBmcs",
"link": "https://www.youtube.com/watch?v=Sklc_fQBmcs",
"media": [
{
"type": "thumbnail",
"url": "https://i.ytimg.com/vi/Sklc_fQBmcs/hq720.jpg?sqp=-oaymwEcCNAFEJQDSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs…"
}
],
"published_at": "5y ago",
"title": "Next.js in 100 Seconds // Plus Full Beginner's Tutorial",
"url": "https://www.youtube.com/watch?v=Sklc_fQBmcs",
"views_count": "1541058"
}
]
}参数
名称作用
format"json" | "markdown"
json(默认)返回解析后的结果。
更多
markdown 以 Markdown 文本(text/markdown)返回同样的结果,便于大模型直接读取:不含外层信封、重复的别名字段和内嵌图片。扣费相同;失败时仍返回 JSON 错误信封。
glstring
示例值: "us"
qstring
示例值: "nextjs tutorial"
countrystring
locale.country 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
cursorstring
pagination.cursor 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
devicestring
options.device 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
hlstring
locale.language 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
htmlboolean
include_html 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
languagestring
locale.language 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
limitinteger
pagination.limit 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
markdownboolean
include_markdown 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
mobileboolean
options.device 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
numinteger
pagination.limit 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
pageinteger
pagination.page 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
search_querystring
query 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
spstring
attributes.sp 的兼容写法。
更多
每次使用其中一种;接口会校验本产品支持的参数与取值。
示例展示请求参数用法,不代表完整契约。接口会校验已知字段,并允许额外参数。
返回字段
字段见上面的返回示例;每个接口都包含 status、credits_charged 和 request_id。
失败时
失败的请求 status 不为 0 并带有 error,不扣费。这个接口常见的有:
1000参数缺失或有误修改请求1020积分不足充值1029超过每秒请求数等待 Retry-After 秒1502 · 1504这次没能读取到目标网站重试