हम Data API को अपडेट कर रहे हैं, ताकि यह Shorts पर मिले व्यू की गिनती करने के तरीके से मेल खा सके.
ज़्यादा जानें
लागू करने का तरीका: रेटिंग
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
यहां दिए गए उदाहरणों में, वीडियो रेटिंग से जुड़े फ़ंक्शन करने के लिए, YouTube Data API (v3) का इस्तेमाल करने का तरीका बताया गया है.
वीडियो का मूल्यांकन करें
किसी वीडियो के लिए उपयोगकर्ता की रेटिंग सबमिट करने के लिए, videos.rate
तरीके को कॉल करें. इस अनुरोध को OAuth 2.0 का इस्तेमाल करके अनुमति दी जानी चाहिए.
अपने अनुरोध में ये दो पैरामीटर सेट करें:
id
पैरामीटर, उस वीडियो का YouTube वीडियो आईडी बताता है जिसे रेटिंग दी जा रही है या जिसकी रेटिंग हटाई जा रही है.
rating
पैरामीटर से उस रेटिंग की जानकारी मिलती है जिसे अनुरोध की अनुमति देने वाला उपयोगकर्ता रिकॉर्ड करना चाहता है. पैरामीटर की मान्य वैल्यू like
, dislike
, और none
हैं. पहली दो वैल्यू, रेटिंग सेट करती हैं और तीसरी वैल्यू, उपयोगकर्ता के लिए पहले से मौजूद रेटिंग को हटा देती है.
नीचे दिए गए अनुरोध के सैंपल में, 2014 Google I/O कॉन्फ़्रेंस के मुख्य भाषण के वीडियो को अच्छी (पसंद) रेटिंग दी गई है:
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.rate?
id=wtLJPvx7-ys
&rating=like
किसी वीडियो के लिए, मौजूदा उपयोगकर्ता की रेटिंग पाना
videos.getRating
तरीके की मदद से, पुष्टि किए गए मौजूदा उपयोगकर्ता की ओर से एक या एक से ज़्यादा वीडियो को दी गई रेटिंग को वापस पाया जा सकता है. अपने अनुरोध में, id
पैरामीटर की वैल्यू को कॉमा लगाकर अलग किए गए YouTube वीडियो आईडी की सूची में सेट करें. यह सूची, उन संसाधनों के लिए होनी चाहिए जिनकी रेटिंग का डेटा आपको चाहिए. ध्यान दें कि इस अनुरोध को OAuth 2.0 का इस्तेमाल करके अनुमति दी जानी चाहिए.
यहां दिए गए सैंपल अनुरोध में, 2014 Google I/O कॉन्फ़्रेंस के मुख्य भाषण के वीडियो की रेटिंग का पता चलता है. (अगर आपने API Explorer में पिछले उदाहरण को लागू किया है, तो एपीआई के जवाब से पता चलना चाहिए कि रेटिंग like
है.
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.getRating?
id=wtLJPvx7-ys
मौजूदा उपयोगकर्ता ने जिन वीडियो को रेटिंग दी है उन्हें वापस पाना
videos.list
तरीके के myRating
पैरामीटर की मदद से, उन वीडियो की सूची देखी जा सकती है जिन्हें एपीआई अनुरोध को अनुमति देने वाले उपयोगकर्ता ने रेटिंग दी है. पैरामीटर की वैल्यू से पता चलता है कि आपको पसंद किए गए या नापसंद किए गए वीडियो चाहिए या नहीं.
यहां दिए गए सैंपल अनुरोध में, उन वीडियो की सूची मिलती है जिन्हें मौजूदा उपयोगकर्ता ने like
रेटिंग दी है. अनुरोध को OAuth 2.0 का इस्तेमाल करके अनुमति दी जानी चाहिए.
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.list?
part=snippet
&myRating=like
ध्यान दें: चैनल के पसंदीदा वीडियो वापस पाने के लिए दिया गया तरीका अपनाकर, उपयोगकर्ता के पसंदीदा वीडियो की सूची भी देखी जा सकती है. हालांकि, नापसंद किए गए वीडियो की सूची नहीं देखी जा सकती. उस प्रोसेस के पहले चरण में, चैनल के पसंदीदा वीडियो की प्लेलिस्ट का आईडी वापस पाने के बजाय, चैनल के पसंद किए गए वीडियो की प्लेलिस्ट का आईडी वापस पाएं.
contentDetails.relatedPlaylists.likes
प्रॉपर्टी में वैल्यू होती है.
इसलिए, एपीआई की मदद से उन वीडियो की सूची वापस पाई जा सकती है जिन्हें उपयोगकर्ता ने
videos.list
या
playlistItems.list
तरीके का इस्तेमाल करके पसंद किया है.
video
रिसॉर्स में
playlistItem
रिसॉर्स से अलग जानकारी दिखती है. इसलिए, अपनी ज़रूरत के हिसाब से कोई एक तरीका चुना जा सकता है.
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2024-11-23 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2024-11-23 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThe YouTube Data API (v3) allows users to rate videos using the \u003ccode\u003evideos.rate\u003c/code\u003e method, with options to \u003ccode\u003elike\u003c/code\u003e, \u003ccode\u003edislike\u003c/code\u003e, or remove a rating (\u003ccode\u003enone\u003c/code\u003e), requiring OAuth 2.0 authorization.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve the currently authenticated user's rating for specific videos by using the \u003ccode\u003evideos.getRating\u003c/code\u003e method and providing a comma-separated list of video IDs, also requiring OAuth 2.0.\u003c/p\u003e\n"],["\u003cp\u003eThe API enables the retrieval of a list of videos rated by the current user, either liked or disliked, through the \u003ccode\u003evideos.list\u003c/code\u003e method and its \u003ccode\u003emyRating\u003c/code\u003e parameter, which also requires OAuth 2.0.\u003c/p\u003e\n"],["\u003cp\u003eAlternatively, users can retrieve a list of their liked videos by using the \u003ccode\u003eplaylistItems.list\u003c/code\u003e method and accessing the \u003ccode\u003econtentDetails.relatedPlaylists.likes\u003c/code\u003e property, which offers an alternative to the \u003ccode\u003evideos.list\u003c/code\u003e method.\u003c/p\u003e\n"]]],["The YouTube Data API (v3) facilitates video rating management. Using `videos.rate`, users can set or remove ratings (`like`, `dislike`, `none`) for specific videos via the `id` and `rating` parameters. `videos.getRating` retrieves a user's rating for videos, referencing video IDs. The `videos.list` method, with the `myRating` parameter, fetches videos the user has rated as \"like\", and similar functionality is available via the `playlistItems.list` method. All requests require OAuth 2.0 authorization.\n"],null,["# Implementation: Ratings\n\nThe following examples show how to use the YouTube Data API (v3) to perform functions related to video ratings.\n\nRate a video\n------------\n\nCall the [videos.rate](/youtube/v3/docs/videos/rate) method to submit a user's rating for a video. This request must be authorized using OAuth 2.0.\n\nSet the following two parameters in your request:\n\n\u003cbr /\u003e\n\n- The [id](/youtube/v3/docs/videos/rate#id) parameter specifies the YouTube video ID of the video that is being rated (or having its rating removed).\n- The [rating](/youtube/v3/docs/videos/rate#rating) parameter specifies the rating that the user authorizing the request wishes to record. Valid parameter values are `like`, `dislike`, and `none`. The first two values set a rating, and the third removes any rating that previously existed for the user.\n\n\u003cbr /\u003e\n\nThe sample request below gives a positive (like) rating to the video of the keynote speech at the 2014 Google I/O conference: \n\n```\nhttps://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.rate?\n id=wtLJPvx7-ys\n &rating=like\n```\n\nRetrieve the current user's rating of a video\n---------------------------------------------\n\nThe [videos.getRating](/youtube/v3/docs/videos/getRating) method lets you retrieve the currently authenticated user's rating of one or more videos. In your request, set the [id](/youtube/v3/docs/videos/rate#id) parameter's value to a comma-separated list of YouTube video IDs for the resources for which you are retrieving rating data. Note that this request must be authorized using OAuth 2.0.\n\nThe sample request below retrieves the current user's rating of the video of the keynote speech at the 2014 Google I/O conference. (If you executed the previous example in the APIs Explorer, the API response should indicate that the rating is `like`. \n\n```\nhttps://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.getRating?\nid=wtLJPvx7-ys\n```\n\nRetrieve videos rated by the current user\n-----------------------------------------\n\nThe `videos.list` method's [myRating](/youtube/v3/docs/videos/list#myRating) parameter lets you retrieve a list of videos rated by the user authorizing the API request. The parameter value indicates whether you want to retrieve liked or disliked videos.\n\nThe sample request below retrieves a list of videos to which the current user gave a `like` rating. The request must be authorized using OAuth 2.0. \n\n```\nhttps://developers.google.com/apis-explorer/#p/youtube/v3/youtube.videos.list?\npart=snippet\n&myRating=like\n``` \n**Note:** You can also retrieve a list of the user's liked videos (but not disliked videos) by following the flow for [retrieving a channel's favorite videos](#favorites). In step 1 of that process, instead of retrieving the playlist ID for the channel's favorite videos, retrieve the playlist ID for the channel's liked videos. The `contentDetails.relatedPlaylists.likes` property contains the value. \n\nThus, the API allows you to retrieve a list of videos that the user liked using either the `videos.list` method or the `playlistItems.list` method. Since different information is returned in a `video` resource than a `playlistItem` resource, you can choose the method that best suits your needs."]]