Shravan Yadav
Shravan Yadav

Reputation: 1317

Unable to get youtube channel statistics using youtube data api v3

I have created the google project and using the youtube data api v3 key in below url but not getting channel statistics.

https://www.googleapis.com/youtube/v3/channels?parts=statistics&id=UCQ_jR_iUmDsR50GX33qWvog&key=AIzaSyBDEjJeaI2QEzNuFNrjPAsFHl1Jin9JWsw

Output is below

  "kind": "youtube#channelListResponse",
  "etag": "5PVGuDob8dxpfgpaJGWruEW8hV8",
  "pageInfo": {
    "resultsPerPage": 1
  },
  "items": [
    {
      "kind": "youtube#channel",
      "etag": "Z0A5YSAnQtcEnTTvtERboPwQAk0",
      "id": "UCQ_jR_iUmDsR50GX33qWvog"
    }
  ]
}

Upvotes: 1

Views: 538

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 117271

Assuming you are working with channel.list I think you should check your code I just tested this with your same request and it works fine from here. tryme

Request:

curl \
  'https://www.googleapis.com/youtube/v3/channels?part=statistics&id=UCQ_jR_iUmDsR50GX33qWvog&key=[YOUR_API_KEY]' \ 
  --header 'Accept: application/json' \
  --compressed

Response

{
  "kind": "youtube#channelListResponse",
  "etag": "1a3o4gpa3kaJyNIWXi2yvRgmk4s",
  "pageInfo": {
    "resultsPerPage": 1
  },
  "items": [
    {
      "kind": "youtube#channel",
      "etag": "S7lD_zHbbGaTaOHU3iEyjECpr0c",
      "id": "UCQ_jR_iUmDsR50GX33qWvog",
      "statistics": {
        "viewCount": "488",
        "commentCount": "0",
        "subscriberCount": "2",
        "hiddenSubscriberCount": false,
        "videoCount": "13"
      }
    }
  ]
}

anwsers from comment questions

How your project is able to access my youtube channel?

You are using an API key that grants access to public data. Which is what i am doing as well. Stats on your channel is public data.

Like you testing it on browser it is working but I copy the same python code to my local machine and try to run it is promoting for key.

You didn't post your code i cant help you with that. What you have shown shows a hard coded public key= paramater.

how to bypass or get rid of prompt?

I am using a public api key there is no prompt as its requesting public data.

Upvotes: 2

Related Questions