How to get subscriber count and videos count for a given YouTube channel? -
until i've been using url retrieve subscriber count channel:
http://gdata.youtube.com/feeds/api/users/<channel_id>?v=2&alt=json and url channel videos count:
https://gdata.youtube.com/feeds/api/users/<channel_id>/uploads?v=2&alt=jsonc&max-results=0 but day google discontinued using it's v2 api , can't find replacement options data.
you're going want use channels/list endpoint pass in statistics part parameter.
request:
http 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 comma-separated list of channel ids id parameter. because passed in 1 id, first object of items array have values need. object subscribercount , videocount values in statistics dictionary data want.
Comments
Post a Comment