เรากำลังอัปเดต Data API ให้สอดคล้องกับวิธีที่ YouTube นับยอดดูสำหรับ Shorts
ดูข้อมูลเพิ่มเติม
การใช้งาน: คำขอการค้นหา
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ตัวอย่างต่อไปนี้สาธิตวิธีส่งคำขอการค้นหาประเภทต่างๆ ใน v3 API
วิดีโอ
เพลย์ลิสต์
ช่อง
ผลการค้นหาที่เกี่ยวข้องกับภาษาหนึ่งๆ
วิดีโอที่อัปโหลดผ่านแอปหรือเว็บไซต์ของนักพัฒนาแอป
ตัวอย่างนี้แสดงวิธีใช้พารามิเตอร์ forDeveloper
เพื่อจำกัดการค้นหาให้แสดงเฉพาะวิดีโอที่อัปโหลดผ่านแอปพลิเคชันหรือเว็บไซต์ของนักพัฒนาแอป พารามิเตอร์นี้สามารถใช้ร่วมกับพารามิเตอร์การค้นหาที่ไม่บังคับ เช่น พารามิเตอร์ q
หมายเหตุ: การค้นหานี้จะไม่แสดงผลลัพธ์ในโปรแกรมสำรวจ API เนื่องจากโปรแกรมสำรวจ API ไม่รองรับการอัปโหลดวิดีโอ คุณสามารถเรียกใช้การค้นหานี้สําหรับแอปพลิเคชันของคุณเองนอกโปรแกรมสํารวจ API ได้ แต่จะดูผลลัพธ์สําหรับแอปพลิเคชันของคุณโดยใช้โปรแกรมสํารวจ API ไม่ได้
วิดีโอที่อัปโหลดแต่ละรายการจะได้รับแท็กหมายเลขโปรเจ็กต์ที่เชื่อมโยงกับแอปพลิเคชันของนักพัฒนาแอปใน คอนโซล Google API โดยอัตโนมัติ
เมื่อคำขอค้นหาตั้งค่าพารามิเตอร์ forDeveloper
เป็น true ในภายหลัง บริการ API จะใช้ข้อมูลเข้าสู่ระบบการให้สิทธิ์ของคำขอเพื่อระบุนักพัฒนาแอป ดังนั้น นักพัฒนาแอปจึงจำกัดผลการค้นหาให้แสดงเฉพาะวิดีโอที่อัปโหลดผ่านแอปหรือเว็บไซต์ของตนเองได้ แต่จะจำกัดให้แสดงเฉพาะวิดีโอที่อัปโหลดผ่านแอปหรือเว็บไซต์อื่นๆ ไม่ได้
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?
part=snippet
&q=fun
&forDeveloper=true
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-11-23 UTC
[null,null,["อัปเดตล่าสุด 2024-11-23 UTC"],[[["\u003cp\u003eThis content demonstrates various search requests using the v3 API's \u003ccode\u003esearch.list\u003c/code\u003e method for finding different types of content.\u003c/p\u003e\n"],["\u003cp\u003eYou can filter search results to include only videos, playlists, or channels by specifying the \u003ccode\u003etype\u003c/code\u003e parameter in the API request.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eorder\u003c/code\u003e, \u003ccode\u003eq\u003c/code\u003e, and \u003ccode\u003evideoDefinition\u003c/code\u003e parameters are used to refine video searches, as seen with the "skateboarding dog" example, allowing specification of search order, search query, and video definition.\u003c/p\u003e\n"],["\u003cp\u003eSearch results can be tailored to specific languages using the \u003ccode\u003erelevanceLanguage\u003c/code\u003e parameter, enabling targeted content discovery.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eforDeveloper\u003c/code\u003e parameter allows searching for videos uploaded through the developer's app, utilizing the developer's project number, but not within the API's Explorer.\u003c/p\u003e\n"]]],["The v3 API's `search.list` method performs various searches. It finds HD videos related to a query by setting parameters like `order`, `q`, and `videoDefinition`. It locates playlists or channels by specifying `type` as 'playlist' or 'channel'. Results relevant to a language are found using `relevanceLanguage`. Developers can find videos uploaded via their app with `forDeveloper`, using their credentials and project number tagged to each upload.\n"],null,["# Implementation: Search requests\n\nThe following examples demonstrate how to complete several different types of search requests in the v3 API.\n\nVideos\n------\n\nThis example calls the [search.list](/youtube/v3/docs/search/list) method to find the most viewed, high-definition (HD) videos associated with the query \"skateboarding dog.\" The query sets the `order`, `part`, `q`, `type`, and `videoDefinition` parameters. \n\n```\nhttps://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?\n part=snippet\n &order=viewCount\n &q=skateboarding+dog\n &type=video\n &videoDefinition=high\n```\n\nSee the [search.list](/youtube/v3/docs/search/list#usage) method's documentation for code samples.\n\nPlaylists\n---------\n\nThis example shows how to find playlists matching the query term \"GoogleDevelopers.\" It calls the [search.list](/youtube/v3/docs/search/list) method and sets the [type](/youtube/v3/docs/search/list#type) parameter's value to `playlist` so that the result set only includes playlists. \n\n```\nhttps://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?\n part=snippet\n &q=GoogleDevelopers\n &type=playlist\n```\n\nChannels\n--------\n\nThis example shows how to find channels matching the query term \"travel.\" It calls the [search.list](/youtube/v3/docs/search/list) method and sets the [type](/youtube/v3/docs/search/list#type) parameter's value to `channel` so that the result set only includes channels. \n\n```\nhttps://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?\n part=snippet\n &q=travel\n &type=channel\n```\n\nResults relevant to a specific language\n---------------------------------------\n\nThis example calls the [search.list](/youtube/v3/docs/search/list) method to find search results that are most relevant to a specific language. The example shows that the query term is **marine** (`q=marine`) and that the API response should contain results most relevant to the French language (`relevanceLanguage=fr`). \n\n```\nhttps://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?\n part=snippet\n &q=marine\n &relevanceLanguage=fr\n```\n\nNote that the request does not set a value for the `type` parameter, which means each search result could reference a video, playlist, or channel.\n\nVideos uploaded via the developer's app or website\n--------------------------------------------------\n\nThis example shows how to use the [forDeveloper](/youtube/v3/docs/search/list#forDeveloper) parameter to restrict a search to only retrieve videos uploaded via the developer's application or website. This parameter can be used in conjunction with optional search parameters, like the `q` parameter.\n\n**Note:** This query does not actually return results in the APIs Explorer because the APIs Explorer doesn't support video uploads. You can run this query for your own application outside of the APIs Explorer, but you can't get results for *your* application using the APIs Explorer.\n\nEach uploaded video is automatically tagged with the project number that is associated with the developer's application in the [Google API Console](https://console.developers.google.com/).\n\nWhen a search request subsequently sets the `forDeveloper` parameter to true, the API service uses the request's authorization credentials to identify the developer. Thus, a developer can restrict results to videos uploaded through the developer's own app or website but not to videos uploaded through other apps or sites. \n\n```\nhttps://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?\n part=snippet\n &q=fun\n &forDeveloper=true\n```"]]