1
votes

I am newer in youtube api,I need help for implementing youtube api in android. I have find one youtube api for getting all channel list on associated username https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername={USERNAME}&key={YOUR_API_KEY}. I have created 3 channels in my youtube account but above api is not getting response.

This is response for above api with valid username and api key

{
 "kind": "youtube#channelListResponse",
 "etag": "\"I_8xdZu766_FSaexEaDXTIfEWc0/ewwRz0VbTYpp2EGbOkvZ5M_1mbo\"",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 5
 },
 "items": []
}
1
Have you enable YouTube Data API in API Console?Dhruv
use default youtube api provided by google developer consolesiddhesh
@ Lawrance: yesMMT
@siddhesh: I need no of channels and video id associated with that user{username}MMT

1 Answers

-1
votes

Use it like this:

https://www.googleapis.com/youtube/v3/channels?part=statistics&id=channel_id&key=your_key

You can try your API request here: https://developers.google.com/youtube/v3/docs/channels/list#try-it

Request:

HTTP GET: GET https://www.googleapis.com/youtube/v3/channels?part=statistics&id={CHANNEL_ID}&key={YOUR_API_KEY}
Response (with id=UCt7iVnJwjBsof8IPLJHCTgQ):

{
 "kind": "youtube#channelListResponse",
 "etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/WNxXCvycTyqTjTn9sLJ5toVjBRY\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {

   "kind": "youtube#channel",
   "etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/jijTuA_iWn2Kv9aRnqeAWNAcQ6I\"",
   "id": "UCt7iVnJwjBsof8IPLJHCTgQ",
   "statistics": {
    "viewCount": "796662",
    "commentCount": "20",
    "subscriberCount": "257",
    "hiddenSubscriberCount": false,
    "videoCount": "126"
   }
  }
 ]
}

You can pass in a comma-separated list of Channel IDs for the id parameter. Because I only passed in one id, the first object of the items array will have the values you need. Get the object for the subscriberCount and videoCount values in the statistics dictionary for the data you want.