So I am using the smiirl counter and was hoping to not have to try and scrub data after the fact instead just use google api directly... i got as far as this example below but it looks like it wont work for me if items and statistics are included, no attributes are identified for me to use in the smiirl interface...i literally can only have 1 line with subscribercount on it...is there a direct way to dig that deep?
currently getting
{
"items": [
{
"statistics": {
"subscriberCount": "3"
}
}
]
}
what i need
{
"subscriberCount": "3"
}
You appear to be using the Channels: list method.
The response returned by this method is
{
"kind": "youtube#channelListResponse",
"etag": etag,
"nextPageToken": string,
"prevPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
channel Resource
]
}
You can use the fields optional parameter to reduce the fields returned. which i suspect you are already doing something like this.
FieldMask used for response filtering. If empty, all fields should be returned unless documented otherwise.
fields = items(statistics(subscriberCount))
That is the best your going to be able to get. You can not change the format of a response from an api endpoint.
May i suggest creating a method on your end that when the data is returned reformat it locally
Related
Using the youtube API, I get no results for either channels list, search, ... for a channel where there is some content.
There is no error returned, just an empty set. No channels, no video, nothing either in the API explorer or through my code.
Everything was working correctly up until a few days/weeks (hard to tell when since I had no errors)
curl -v 'https://www.googleapis.com/youtube/v3/search?key=[api_key]&channelId=UCKTgGP9lrL5Yjs4f8WuI1Vw&part=snippet,id&order=date&maxResults=20'
is the query I used but I tried to get the uploads channel id as some answers here advised but the channels/list endpoint is empty too. I checked the documentation and I couldn't find anything wrong with my query.
This is the answer I currently get:
{
"kind": "youtube#searchListResponse",
"etag": "\"ksCrgYQhtFrXgbHAhi9Fo5t0C2I/nrqzXB-_ht29Bt6u-f7_lLyFcCw\"",
"regionCode": "BE",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 20
},
"items": []
}
and you can see here https://www.youtube.com/channel/UCKTgGP9lrL5Yjs4f8WuI1Vw/videos that it's not empty.
Try to add type=video as param, it seems working :)
Overall Goal: To report possible subscribers who are not active on my YouTube channel.
I'm reading through the YouTube Data API (v3) trying to understand how to retrieve the actual ids who watched a specific video. I know you can get the number of views, but I don't see any call/response that shows you the subscriber ids. Has anyone done this?
So far what I gathered from the docs and Google searching is that this was possible using the Watch History of a subscriber, but that's been deprecated.
Thanks in advance!
So I do not believe it's possible to get IDs of users who have watched certain videos but I have a workaround for my use case; reporting inactive subscribers. This is not the best but it'll get me somewhere.
YouTube's API is very limiting now, but by calling the Subscriptions API
https://www.googleapis.com/youtube/v3/subscriptions?part=snippet%2CcontentDetails&mySubscribers=true&key=[YOUR_API_KEY]
I am able to get all subscribers with their channel IDs. Then after saving their IDs, I can check each one's statistics by making this call:
https://www.googleapis.com/youtube/v3/channels?part=statistics&id=[SUB_ID]&key=[YOUR_API_KEY]
which I receive a response like this:
{
"kind": "youtube#channelListResponse",
"etag": "\"j6xRRd8dTPVVptg711_CSPADRfg/AZpZT_vQrY3UTi57ia_QqrKdc8c\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"something\"",
"id": "[SUB_ID]",
"statistics": {
"viewCount": "0",
"commentCount": "0",
"subscriberCount": "1",
"hiddenSubscriberCount": false,
"videoCount": "0"
}
}
]
}
Using this response (see "statistics"), I am making a generalization that if the subscriber has no comments AND no videos, then it's a safe bet that they are not active.
I'm new to basically all forms of programming, so forgive me if there's an obvious answer, but I was just trying to make a random video chooser by randomly adding characters to the Youtube API's search function under list, but when I run the API with either just id or id and snippet on, it shows this:
{
"kind": "youtube#searchListResponse",
"etag": "\"i don't know if I can post my etag"",
"regionCode": "CA",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 50
},
"items": [
]
}
.
Its hard to know exactly what you have searched on but by the looks of the result there is just no results for your request. YOu might want to try playing with the api here search.list
When you run it click Execute without OAuth not the authorize and execute button. It will return a random list of videos.
You can use the q parameter to do a text search on videos for example that like toys.
How do you query multiple channels to see if they are streaming at that moment?
I tried to add multiple channelIds in this query:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={channels_seperated_by_comma_and_http_query}&eventType=live&type=video&key={my_key}
That only gives the result of the first key
You can use Channels:list, which returns a collection of more than one channel.
HTTP request
GET https://www.googleapis.com/youtube/v3/channels
From the parameter part, it will give you contentDetails part=contentDetails
Response
If successful, this method returns a response body with the following structure:
{
"kind": "youtube#channelListResponse",
"etag": etag,
"nextPageToken": string,
"prevPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
channel Resource
]
}
Based from Ibrahim Ulukaya, you can not add comma separated channels here. Either you can leave it blank to search all channels, or you can have a request per each channel and merge results. There is no multichannel search API.
I do this YouTube API call to retrieve the user videos list.
https://www.googleapis.com/youtube/v3/search?access_token=secret&part=id,snippet&type=video&forMine=true&maxResults=50&order=date
It works great except that it won't return the prevPageToken param.
I know this param is not return on the first page, but my problem here is that it is NEVER returned.
The nextPageToken param works as expected and is always returned.
I tried to remove the order/maxResults params but it did not change anything.
Am I missing something here ?
According to the documentation it should be there. Maybe file it as a bug here: https://code.google.com/p/gdata-issues/issues/list?q=label%3aAPI-YouTube. Check first that it has not been filed already.
I just tried. I do get a prevPageToken for:
GET https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=5&pageToken=CAUQAA&q=cover&type=video&key={YOUR_API_KEY}
See Response:
{
"kind": "youtube#searchListResponse",
"etag": "\"bvxF-DWHx1toJotsdJBeCm43SLs/j02ylGuod7b8YA4wvEAk8TsyYjU\"",
"nextPageToken": "CAoQAA",
"prevPageToken": "CAUQAQ",
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 5
},
"items": [.....
}
And using the value for prevPageToken as pageToken is also working: getting the previous page.
Make sure setFields parameter has prevPageToken set
search.setFields("items(id/kind,id/videoId),nextPageToken,prevPageToken");