平台智能 API
YouTube API
YouTube 每月有超过 20 亿的登录用户,涵盖视频、短视频、直播和播客,对于搜索可见性、教育、品牌叙事和创作者主导的需求至关重要。
API 参考 版本: 1.0.0 3 终端 身份验证
基本网址
https://api.pressmonitor.com/youtube/v1 身份验证
所有请求使用 Bearer 令牌身份验证。每个调用都添加授权头。
Authorization: Bearer YOUR_TOKEN GET
/search 搜索 YouTube 视频
Search
参数
| 名称 | 类型 | 位置 | 必填 | 描述 |
|---|---|---|---|---|
| query_text | string | query | 是 | 搜索查询文本 |
| num | integer | query | 不 | 最大结果数 |
| order | string | query | 不 | 排序顺序 |
| event-type | string | query | 不 | 直播事件类型过滤器 |
| token | string | query | 不 | 分页令牌 |
| country_code | string | query | 不 | 区域代码 |
| lang_code | string | query | 不 | 相关语言代码 |
代码示例
curl --request GET \ --url 'https://api.pressmonitor.com/youtube/v1/search?query_text=SOME_STRING_VALUE&num=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&event-type=SOME_STRING_VALUE&token=SOME_STRING_VALUE&country_code=SOME_STRING_VALUE&lang_code=SOME_STRING_VALUE' const http = require("https"); const options = { "method": "GET", "hostname": "api.pressmonitor.com", "port": null, "path": "/youtube/v1/search?query_text=SOME_STRING_VALUE&num=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&event-type=SOME_STRING_VALUE&token=SOME_STRING_VALUE&country_code=SOME_STRING_VALUE&lang_code=SOME_STRING_VALUE", "headers": {} }; const req = http.request(options, function (res) { const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); import requests url = "https://api.pressmonitor.com/youtube/v1/search" querystring = {"query_text":"SOME_STRING_VALUE","num":"SOME_INTEGER_VALUE","order":"SOME_STRING_VALUE","event-type":"SOME_STRING_VALUE","token":"SOME_STRING_VALUE","country_code":"SOME_STRING_VALUE","lang_code":"SOME_STRING_VALUE"} response = requests.request("GET", url, params=querystring) print(response.text) <?php $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => "https://api.pressmonitor.com/youtube/v1/search?query_text=SOME_STRING_VALUE&num=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&event-type=SOME_STRING_VALUE&token=SOME_STRING_VALUE&country_code=SOME_STRING_VALUE&lang_code=SOME_STRING_VALUE", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("https://api.pressmonitor.com/youtube/v1/search?query_text=SOME_STRING_VALUE&num=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&event-type=SOME_STRING_VALUE&token=SOME_STRING_VALUE&country_code=SOME_STRING_VALUE&lang_code=SOME_STRING_VALUE") .get() .build(); Response response = client.newCall(request).execute(); 响应
200 成功
GET
/call 通用 YouTube 数据 API 调用
Call
参数
| 名称 | 类型 | 位置 | 必填 | 描述 |
|---|---|---|---|---|
| path | string | query | 不 | /youtube/v3 下的 API 路径 |
| endpoint | string | query | 不 | 如果未使用 path,则使用的替代 API 路径 |
| method | string | query | 不 | HTTP 方法,默认为 GET |
代码示例
curl --request GET \ --url 'https://api.pressmonitor.com/youtube/v1/call?path=SOME_STRING_VALUE&endpoint=SOME_STRING_VALUE&method=SOME_STRING_VALUE' const http = require("https"); const options = { "method": "GET", "hostname": "api.pressmonitor.com", "port": null, "path": "/youtube/v1/call?path=SOME_STRING_VALUE&endpoint=SOME_STRING_VALUE&method=SOME_STRING_VALUE", "headers": {} }; const req = http.request(options, function (res) { const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); import requests url = "https://api.pressmonitor.com/youtube/v1/call" querystring = {"path":"SOME_STRING_VALUE","endpoint":"SOME_STRING_VALUE","method":"SOME_STRING_VALUE"} response = requests.request("GET", url, params=querystring) print(response.text) <?php $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => "https://api.pressmonitor.com/youtube/v1/call?path=SOME_STRING_VALUE&endpoint=SOME_STRING_VALUE&method=SOME_STRING_VALUE", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("https://api.pressmonitor.com/youtube/v1/call?path=SOME_STRING_VALUE&endpoint=SOME_STRING_VALUE&method=SOME_STRING_VALUE") .get() .build(); Response response = client.newCall(request).execute(); 响应
200 成功
GET
/video-details 获取视频详情
Get Video Details
参数
| 名称 | 类型 | 位置 | 必填 | 描述 |
|---|---|---|---|---|
| video_ids | string | query | 是 | 逗号分隔的 YouTube 视频 ID |
代码示例
curl --request GET \ --url 'https://api.pressmonitor.com/youtube/v1/video-details?video_ids=SOME_STRING_VALUE' const http = require("https"); const options = { "method": "GET", "hostname": "api.pressmonitor.com", "port": null, "path": "/youtube/v1/video-details?video_ids=SOME_STRING_VALUE", "headers": {} }; const req = http.request(options, function (res) { const chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { const body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); import requests url = "https://api.pressmonitor.com/youtube/v1/video-details" querystring = {"video_ids":"SOME_STRING_VALUE"} response = requests.request("GET", url, params=querystring) print(response.text) <?php $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => "https://api.pressmonitor.com/youtube/v1/video-details?video_ids=SOME_STRING_VALUE", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() .url("https://api.pressmonitor.com/youtube/v1/video-details?video_ids=SOME_STRING_VALUE") .get() .build(); Response response = client.newCall(request).execute(); 响应
200 成功