此端点可以帮助您
响应包含匹配的搜索、公开上下文,以及在有更多结果时的分页数据。
何时使用
当不知道确切的对象 ID、需要先找到相关候选项时,请使用“按国家获取频道”。
先查看结果和常见工作流,然后再了解参数和可运行的请求示例。
响应包含匹配的搜索、公开上下文,以及在有更多结果时的分页数据。
当不知道确切的对象 ID、需要先找到相关候选项时,请使用“按国家获取频道”。
在面向客户的界面和内部界面中加入 YouTube 数据搜索。
按查询查找候选项,并保存相关对象以供后续补全。
收集结果集,用于主题、创作者和竞品分析。
两个版本完成相同的任务,接受相同的参数。使用切换按钮比较响应结构,并选择您的客户端所需的版本。
在本页面切换版本,即可在同一文档 URL 下比较响应结构。
V1 和 V2 的身份验证、必填参数和请求结构均相同。实际上,您只需在构建端点路径和解析响应时选择版本。
主要区别在于响应结构。新集成请使用 V2;仅在需要兼容现有客户端契约时保留 V1。
两个版本使用相同的 API 密钥请求头和相同的查询参数。本文档先展示共享的参数集合,然后展示各版本特定的端点路径和代码片段。
| 参数 | 必填 | 类型 | 示例 | 说明 |
|---|---|---|---|---|
country_code |
是 | str |
US |
Two-letter ISO 3166-1 alpha-2 country code used for YouTube localization. Example: US. |
query |
是 | str |
technology review |
用户输入的搜索关键词。 |
cursor |
否 | str | None |
cursor-next-page |
上一次响应返回的下一页游标。获取第一页时请省略。 |
sort_by |
否 | relevance | uploadDate | viewCount | rating |
relevance |
YouTube search sort order. Examples: relevance, uploadDate, viewCount, rating. |
复制确切的端点路径、示例 URL 和代码片段时请选择版本。上方的参数列表保持不变。
GET /api/v2/youtube.com/search/channels-by-countrycurl --request GET \
--url "https://www.scrapestorm.net/api/v2/youtube.com/search/channels-by-country" \
--header "X-API-Key: 00000000-0000-4000-8000-000000000000" \
--get --data-urlencode 'country_code=US' \
--get --data-urlencode 'query=technology review' \
# Optional parameters:
# --data-urlencode 'cursor=cursor-next-page'
# --data-urlencode 'sort_by=relevance'
from urllib.parse import urljoin
import requests
BASE_URL = "https://www.scrapestorm.net"
ENDPOINT = "/api/v2/youtube.com/search/channels-by-country"
HEADERS = {"Accept": "application/json", "X-API-Key": "00000000-0000-4000-8000-000000000000"}
params = {
"country_code": "US",
"query": "technology review",
}
# Optional parameters
# params["cursor"] = "cursor-next-page"
# params["sort_by"] = "relevance"
with requests.Session() as session:
response = session.request(
method="GET",
url=urljoin(BASE_URL, ENDPOINT),
headers=HEADERS,
params=params,
timeout=30,
)
response.raise_for_status()
payload = response.json()
print(payload)
const BASE_URL = "https://www.scrapestorm.net";
const endpoint = "/api/v2/youtube.com/search/channels-by-country";
const params = new URLSearchParams({
country_code: "US",
query: "technology review",
});
// Optional parameters
// params.set("cursor", "cursor-next-page");
// params.set("sort_by", "relevance");
const response = await fetch(`${BASE_URL}${endpoint}?${params.toString()}`, {
method: "GET",
headers: {
Accept: "application/json",
"X-API-Key": "00000000-0000-4000-8000-000000000000",
},
});
if (!response.ok) {
throw new Error(`Request failed: ${response.status} ${response.statusText}`);
}
const payload = await response.json();
console.log(payload);
import axios from "axios";
const client = axios.create({
baseURL: "https://www.scrapestorm.net",
timeout: 30000,
headers: {
Accept: "application/json",
"X-API-Key": "00000000-0000-4000-8000-000000000000",
},
});
const params = {
country_code: "US",
query: "technology review",
};
// Optional parameters
// params.cursor = "cursor-next-page";
// params.sort_by = "relevance";
const { data: payload } = await client.request({
method: "GET",
url: endpoint,
params,
});
console.log(payload);
<?php
declare(strict_types=1);
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
$client = new Client([
'base_uri' => "https://www.scrapestorm.net",
'timeout' => 30.0,
'headers' => [
'Accept' => 'application/json',
'X-API-Key' => "00000000-0000-4000-8000-000000000000",
],
]);
$query = [
"country_code" => "US",
"query" => "technology review",
];
// Optional parameters
// $query["cursor"] = "cursor-next-page";
// $query["sort_by"] = "relevance";
try {
$response = $client->request("GET", "/api/v2/youtube.com/search/channels-by-country", [
'query' => $query,
]);
$payload = json_decode(
(string) $response->getBody(),
true,
512,
JSON_THROW_ON_ERROR
);
var_dump($payload);
} catch (GuzzleException $e) {
throw $e;
}
package main
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
)
func main() {
baseURL := "https://www.scrapestorm.net"
endpoint := "/api/v2/youtube.com/search/channels-by-country"
params := url.Values{}
params.Set("country_code", "US")
params.Set("query", "technology review")
// Optional parameters
// params.Set("sort_by", "relevance")
req, err := http.NewRequest(
"GET",
fmt.Sprintf("%s%s?%s", baseURL, endpoint, params.Encode()),
nil,
)
if err != nil {
panic(err)
}
req.Header.Set("Accept", "application/json")
req.Header.Set("X-API-Key", "00000000-0000-4000-8000-000000000000")
client := &http.Client{Timeout: 30 * time.Second}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var payload any
if err := json.NewDecoder(resp.Body).Decode(&payload); err != nil {
panic(err)
}
fmt.Printf("%+v\n", payload)
}
复制确切的端点路径、示例 URL 和代码片段时请选择版本。上方的参数列表保持不变。
GET /api/v1/youtube.com/search/channels-by-countrycurl --request GET \
--url "https://www.scrapestorm.net/api/v1/youtube.com/search/channels-by-country" \
--header "X-API-Key: 00000000-0000-4000-8000-000000000000" \
--get --data-urlencode 'country_code=US' \
--get --data-urlencode 'query=technology review' \
# Optional parameters:
# --data-urlencode 'cursor=cursor-next-page'
# --data-urlencode 'sort_by=relevance'
from urllib.parse import urljoin
import requests
BASE_URL = "https://www.scrapestorm.net"
ENDPOINT = "/api/v1/youtube.com/search/channels-by-country"
HEADERS = {"Accept": "application/json", "X-API-Key": "00000000-0000-4000-8000-000000000000"}
params = {
"country_code": "US",
"query": "technology review",
}
# Optional parameters
# params["cursor"] = "cursor-next-page"
# params["sort_by"] = "relevance"
with requests.Session() as session:
response = session.request(
method="GET",
url=urljoin(BASE_URL, ENDPOINT),
headers=HEADERS,
params=params,
timeout=30,
)
response.raise_for_status()
payload = response.json()
print(payload)
const BASE_URL = "https://www.scrapestorm.net";
const endpoint = "/api/v1/youtube.com/search/channels-by-country";
const params = new URLSearchParams({
country_code: "US",
query: "technology review",
});
// Optional parameters
// params.set("cursor", "cursor-next-page");
// params.set("sort_by", "relevance");
const response = await fetch(`${BASE_URL}${endpoint}?${params.toString()}`, {
method: "GET",
headers: {
Accept: "application/json",
"X-API-Key": "00000000-0000-4000-8000-000000000000",
},
});
if (!response.ok) {
throw new Error(`Request failed: ${response.status} ${response.statusText}`);
}
const payload = await response.json();
console.log(payload);
import axios from "axios";
const client = axios.create({
baseURL: "https://www.scrapestorm.net",
timeout: 30000,
headers: {
Accept: "application/json",
"X-API-Key": "00000000-0000-4000-8000-000000000000",
},
});
const params = {
country_code: "US",
query: "technology review",
};
// Optional parameters
// params.cursor = "cursor-next-page";
// params.sort_by = "relevance";
const { data: payload } = await client.request({
method: "GET",
url: endpoint,
params,
});
console.log(payload);
<?php
declare(strict_types=1);
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
$client = new Client([
'base_uri' => "https://www.scrapestorm.net",
'timeout' => 30.0,
'headers' => [
'Accept' => 'application/json',
'X-API-Key' => "00000000-0000-4000-8000-000000000000",
],
]);
$query = [
"country_code" => "US",
"query" => "technology review",
];
// Optional parameters
// $query["cursor"] = "cursor-next-page";
// $query["sort_by"] = "relevance";
try {
$response = $client->request("GET", "/api/v1/youtube.com/search/channels-by-country", [
'query' => $query,
]);
$payload = json_decode(
(string) $response->getBody(),
true,
512,
JSON_THROW_ON_ERROR
);
var_dump($payload);
} catch (GuzzleException $e) {
throw $e;
}
package main
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
)
func main() {
baseURL := "https://www.scrapestorm.net"
endpoint := "/api/v1/youtube.com/search/channels-by-country"
params := url.Values{}
params.Set("country_code", "US")
params.Set("query", "technology review")
// Optional parameters
// params.Set("sort_by", "relevance")
req, err := http.NewRequest(
"GET",
fmt.Sprintf("%s%s?%s", baseURL, endpoint, params.Encode()),
nil,
)
if err != nil {
panic(err)
}
req.Header.Set("Accept", "application/json")
req.Header.Set("X-API-Key", "00000000-0000-4000-8000-000000000000")
client := &http.Client{Timeout: 30 * time.Second}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var payload any
if err := json.NewDecoder(resp.Body).Decode(&payload); err != nil {
panic(err)
}
fmt.Printf("%+v\n", payload)
}
预览保留了关键字段和集合中的前几项,便于您快速浏览响应结构。切换版本会改变 JSON 格式。
此简明 JSON 示例来自 V2 最近一次成功的验证运行。
{
"success": true,
"status": "ok",
"pagination": {
"cursor": "QVFB...",
"has_more": true
},
"search_context": {
"sort_by": "relevance",
"query": "technology review",
"country_code": "US"
},
"data": {
"channels": {
"count": 20,
"items": [
{
"url": "https://www.youtube.com/@technologyreview",
"channel_id": "UCgy4Mf_tlZGqesYNqPNxjPw",
"username": "technologyreview",
"display_name": "MIT Technology Review",
"verified": null,
"snippet": "Our in-depth reporting reveals what's going on now to prepare you for what's coming next. Founded at the Massachusetts Institute ...",
"subscriber_count": 102000,
"badges": null,
"avatar_url": "https://example.com/image.jpg",
"avatar_urls": "https://example.com/image.jpg"
},
{
"url": "https://www.youtube.com/@ConsumerTechReview",
"channel_id": "UCzqlzMvlYyWVxFcNMZYzE0g",
"username": "ConsumerTechReview",
"display_name": "Consumer Tech Review",
"verified": true,
"snippet": "Hey guys! My name is Los and I run this channel, ConsumerTech Review. I have a passion for keyboards, setups, and TECH and ...",
"subscriber_count": 233000,
"badges": [
"Verified"
],
"avatar_url": "https://example.com/image.jpg",
"avatar_urls": "https://example.com/image.jpg"
},
{
"_more_items": 18
}
]
}
}
}
此简明 JSON 示例来自 V1 最近一次成功的验证运行。
{
"success": true,
"status": "ok",
"pagination": {
"cursor": "QVFB...",
"has_more": true
},
"search_context": {
"sort_by": "relevance",
"query": "technology review",
"country_code": "US"
},
"data": {
"responseContext": {
"serviceTrackingParams": [
{
"service": "GUIDED_HELP",
"params": [
{
"key": "context",
"value": "yt_web_search"
},
{
"key": "logged_in",
"value": "0"
}
]
},
{
"service": "GFEEDBACK",
"params": [
{
"key": "has_unlimited_entitlement",
"value": "False"
},
{
"key": "has_premium_lite_entitlement",
"value": "False"
},
{
"_more_items": 2
}
]
},
{
"_more_items": 2
}
],
"mainAppWebResponseContext": {
"loggedOut": true,
"trackingParam": "k5_fmPxhoXZR7wr_xi5ivZETdueeR9BTVd5j-N6bNAIwc5FrrUOcxMX0TzRMkuMESLBwOcCw59TLtslLKPQGSS"
},
"responseId": "IhMI18XelNXflQMVREIrAx391ztL",
"webResponseContextExtensionData": {
"webResponseContextPreloadData": {
"preloadMessageNames": [
"twoColumnSearchResultsRenderer",
"sectionListRenderer",
{
"_more_items": 26
}
]
},
"hasDecorated": true
}
},
"estimatedResults": "307183",
"contents": {
"twoColumnSearchResultsRenderer": {
"primaryContents": {
"sectionListRenderer": {
"contents": [
"…",
"…"
],
"trackingParams": "CDwQui8iEwjXxd6U1d-VAxVEQisDHf3XO0s=",
"subMenu": {
"searchSubMenuRenderer": "…"
},
"hideBottomSeparator": true,
"targetId": "search-feed"
}
}
}
},
"trackingParams": "CAAQvGkiEwjXxd6U1d-VAxVEQisDHf3XO0vKAQRetfVv",
"header": {
"searchHeaderRenderer": {
"chipBar": {
"chipCloudRenderer": {
"chips": [
"…",
"…",
{
"_more_items": 5
}
],
"trackingParams": "CDIQkVoiEwjXxd6U1d-VAxVEQisDHf3XO0s=",
"nextButton": {
"buttonRenderer": "…"
},
"previousButton": {
"buttonRenderer": "…"
}
}
},
"searchFilterButton": {
"buttonRenderer": {
"style": "STYLE_TEXT",
"size": "SIZE_DEFAULT",
"isDisabled": false,
"text": {
"runs": "…"
},
"icon": {
"iconType": "TUNE"
},
"tooltip": "Search filters",
"trackingParams": "CBMQ8FsiEwjXxd6U1d-VAxVEQisDHf3XO0s=",
"accessibilityData": {
"accessibilityData": "…"
},
"command": {
"clickTrackingParams": "CBMQ8FsiEwjXxd6U1d-VAxVEQisDHf3XO0vKAQRetfVv",
"openPopupAction": "…"
},
"iconPosition": "BUTTON_ICON_POSITION_TYPE_RIGHT_OF_TEXT"
}
},
"trackingParams": "CBIQiOoKIhMI18XelNXflQMVREIrAx391ztL"
}
},
"topbar": {
"desktopTopbarRenderer": {
"logo": {
"topbarLogoRenderer": {
"iconImage": {
"iconType": "YOUTUBE_LOGO"
},
"tooltipText": {
"runs": "…"
},
"endpoint": {
"clickTrackingParams": "CBEQsV4iEwjXxd6U1d-VAxVEQisDHf3XO0vKAQRetfVv",
"commandMetadata": "…",
"browseEndpoint": "…"
},
"trackingParams": "CBEQsV4iEwjXxd6U1d-VAxVEQisDHf3XO0s=",
"overrideEntityKey": "EgZ0b3BiYXIg9QEoAQ%3D%3D"
}
},
"searchbox": {
"fusionSearchboxRenderer": {
"icon": {
"iconType": "SEARCH"
},
"placeholderText": {
"runs": "…"
},
"config": {
"webSearchboxConfig": "…"
},
"trackingParams": "CA0Q7VAiEwjXxd6U1d-VAxVEQisDHf3XO0s=",
"searchEndpoint": {
"clickTrackingParams": "CA0Q7VAiEwjXxd6U1d-VAxVEQisDHf3XO0vKAQRetfVv",
"commandMetadata": "…",
"searchEndpoint": "…"
},
"clearButton": {
"buttonRenderer": "…"
},
"showImageSourceDialog": {
"clickTrackingParams": "CA0Q7VAiEwjXxd6U1d-VAxVEQisDHf3XO0vKAQRetfVv",
"showDialogCommand": "…"
},
"disableAiAppearance": true
}
},
"trackingParams": "CAEQq6wBIhMI18XelNXflQMVREIrAx391ztL",
"topbarButtons": [
{
"topbarMenuButtonRenderer": {
"icon": "…",
"menuRequest": "…",
"trackingParams": "CAsQ_qsBGAAiEwjXxd6U1d-VAxVEQisDHf3XO0s=",
"accessibility": "…",
"tooltip": "Settings",
"style": "STYLE_DEFAULT"
}
},
{
"buttonRenderer": {
"style": "STYLE_SUGGESTIVE",
"size": "SIZE_SMALL",
"text": "…",
"icon": "…",
"navigationEndpoint": "…",
"trackingParams": "CAoQ1IAEGAEiEwjXxd6U1d-VAxVEQisDHf3XO0s=",
"targetId": "topbar-signin"
}
}
],
"hotkeyDialog": {
"hotkeyDialogRenderer": {
"title": {
"runs": "…"
},
"sections": [
"…",
"…",
{
"_more_items": 2
}
],
"dismissButton": {
"buttonRenderer": "…"
},
"trackingParams": "CAgQteYDIhMI18XelNXflQMVREIrAx391ztL"
}
},
"backButton": {
"buttonRenderer": {
"trackingParams": "CAcQvIYDIhMI18XelNXflQMVREIrAx391ztL",
"command": {
"clickTrackingParams": "CAcQvIYDIhMI18XelNXflQMVREIrAx391ztLygEEXrX1bw==",
"commandMetadata": "…",
"signalServiceEndpoint": "…"
}
}
},
"forwardButton": {
"buttonRenderer": {
"trackingParams": "CAYQvYYDIhMI18XelNXflQMVREIrAx391ztL",
"command": {
"clickTrackingParams": "CAYQvYYDIhMI18XelNXflQMVREIrAx391ztLygEEXrX1bw==",
"commandMetadata": "…",
"signalServiceEndpoint": "…"
}
}
},
"a11ySkipNavigationButton": {
"buttonRenderer": {
"style": "STYLE_DEFAULT",
"size": "SIZE_DEFAULT",
"isDisabled": false,
"text": {
"runs": "…"
},
"trackingParams": "CAUQ8FsiEwjXxd6U1d-VAxVEQisDHf3XO0s=",
"command": {
"clickTrackingParams": "CAUQ8FsiEwjXxd6U1d-VAxVEQisDHf3XO0vKAQRetfVv",
"commandMetadata": "…",
"signalServiceEndpoint": "…"
}
}
},
"voiceSearchButton": {
"buttonRenderer": {
"style": "STYLE_DEFAULT",
"size": "SIZE_DEFAULT",
"isDisabled": false,
"serviceEndpoint": {
"clickTrackingParams": "CAIQ7a8FIhMI18XelNXflQMVREIrAx391ztLygEEXrX1bw==",
"commandMetadata": "…",
"signalServiceEndpoint": "…"
},
"icon": {
"iconType": "MICROPHONE_ON"
},
"tooltip": "Search with your voice",
"trackingParams": "CAIQ7a8FIhMI18XelNXflQMVREIrAx391ztL",
"accessibilityData": {
"accessibilityData": "…"
}
}
}
}
},
"targetId": "search-page"
}
}
将本文档作为第一个决策点,然后在将端点接入常规使用之前,继续了解价格、平台覆盖范围和集成规则。
借助这些解答,判断此 API 方法是否适合您的工作流、版本选择和上线计划。
该方法针对搜索执行“按国家获取频道”操作。下方的简明响应示例展示了确切的字段结构。
新集成请选择 V2,因为它提供规范化的结构。仅在兼容已使用平台原生格式的客户端时使用 V1。
创建 API 密钥,在请求头中发送它,并提供表格中的必填参数。代码示例中已包含正确的路径和请求结构。