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"
}
]
}
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.
Related
We are integrating social signup with google in our project, so we have to get the phone number from the users google account. we were able to fetch the phone number from people API(by using phoneNumber scope), but its not returning any country code info. please help us to get the country or country code info along with phone number.
The scope we used is: https://www.googleapis.com/auth/user.phonenumbers.read
and we used this API to fetch phoneNumbers:
https://people.googleapis.com/v1/people/me?personFields=phoneNumbers
we got the response as
{
"resourceName": "people/11454441970xxxxxx",
"etag": "%EgUBCy43PxoEAQIFByIMaXF6QTFjxxxx",
"phoneNumbers": [
{
"metadata": {
"primary": true,
"source": {
"type": "DOMAIN_PROFILE",
"id": "11454441970xxxxxx"
}
},
"value": "95xxxxxxxx",
"type": "work",
"formattedType": "Work"
}
]
}
The field you are looking for is called canonicalForm which is the The canonicalized ITU-T E.164 form of the phone number.
The people api is very picky with what information the user has summited. If the user you are looking at did not add the country code then its not going to appear
As you can see with my settings on my google profile I have set my country code with my phone number
.
So when i make a request to the api.
curl \
'https://people.googleapis.com/v1/people/me?personFields=phoneNumbers&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
My phone number is returned in the id field and country code and number in the canonicalForm fields.
"phoneNumbers": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "3fab08baa4be"
}
},
"value": "xxxxxxxxx",
"canonicalForm": "+45xxxxxxxxx",
"type": "mobile",
"formattedType": "Mobile"
},
I would check the data that the user has inserted into their google profile and ensure that they have set the country code.
I am using
https://www.googleapis.com/calendar/v3/calendars/en.australian%23holiday%40group.v.calendar.google.com/events?key=YourApiKey
to get australian public holidays, but I am receiving empty items array
{
"kind": "calendar#events",
"etag": "\"p32kslj59m6eeu0g\"",
"summary": "Holidays in Australia",
"updated": "2021-03-05T08:30:05.375Z",
"timeZone": "UTC",
"accessRole": "reader",
"defaultReminders": [],
"nextPageToken": "CjASLgojMjAyMTA0MDVfNjBvMzBjaGk2b28zMGMxZzYwbzMwZHI1NmsYkN324_Pw7gIaDwgAEgAYmKz8oN6Y7wIgASIHCAIQzunfEQ==",
"items": []
}
any idea how to get australian holidays?
Google Calendar API is returning the correct results, but it is returning them across several pages. You can get the next page with:
https://www.googleapis.com/calendar/v3/calendars/en.australian%23holiday%40group.v.calendar.google.com/events?key=YourApiKey&pageToken=CjASLgojMjAyMTA0MDVfNjBvMzBjaGk2b28zMGMxZzYwbzMwZHI1NmsYkN324_Pw7gIaDwgAEgAYmKz8oN6Y7wIgASIHCAIQzunfEQ==
See more about pagination here: https://developers.google.com/calendar/v3/pagination
The client libraries make it easy to deal with these multi-paged responses.
The page size defaults to 250 events, but this also includes deleted events, which you are not requesting. The first 250 events on this particular calendar have been marked as deleted, so you see an empty page.
See details at: https://developers.google.com/calendar/v3/reference/events/list
maxResults (integer)
Maximum number of events returned on one result page. The number of events in the resulting page may be less than this value, or none at all, even if there are more events matching the query. Incomplete pages can be detected by a non-empty nextPageToken field in the response. By default the value is 250 events. The page size can never be larger than 2500 events. Optional.
I was able to force everything onto a single page using the following, but this really isn't a good answer. If total event count is larger than 2500, you still might end up with an incomplete list:
https://www.googleapis.com/calendar/v3/calendars/en.australian%23holiday%40group.v.calendar.google.com/events?maxResults=2500&key=[YOUR_API_KEY]'
There seems to be an error in that the initial response returns no events however there is a page token This is not how the system is intended to function. I have submitted an issue report
try me
Request;
curl \
'https://www.googleapis.com/calendar/v3/calendars/en.australian%23holiday%40group.v.calendar.google.com/events?key=[YOUR_API_KEY]' \
--header 'Accept: application/json' \
--compressed
Returns
{
"kind": "calendar#events",
"etag": "\"p33kpjmcjvaeuu0g\"",
"summary": "Holidays in Australia",
"updated": "2021-03-06T07:14:02.000Z",
"timeZone": "UTC",
"accessRole": "reader",
"defaultReminders": [],
"nextPageToken": "CjASLgojMjAyMTA0MDVfNjBvMzBjaGk2b28zMGMxZzYwbzMwZHI1NmsYkN324_Pw7gIaDwgAEgAYgMXbj4-b7wIgASIHCAIQ5I7jEQ==",
"items": []
}
Where it should return events
If i then add the next pagetoken
Request
curl 'https://www.googleapis.com/calendar/v3/calendars/en.australian%23holiday%40group.v.calendar.google.com/events?pageToken=CjASLgojMjAyMTA0MDVfNjBvMzBjaGk2b28zMGMxZzYwbzMwZHI1NmsYkN324_Pw7gIaDwgAEgAYgMXbj4-b7wIgASIHCAIQ5I7jEQ%3D%3D&key=[YOUR_API_KEY]'
--header 'Accept: application/json'
--compressed
response
{
"kind": "calendar#events",
"etag": "\"p32e9tk5uvaeuu0g\"",
"summary": "Holidays in Australia",
"updated": "2021-03-06T07:14:02.000Z",
"timeZone": "UTC",
"accessRole": "reader",
"defaultReminders": [],
"nextPageToken": "CjASLgojMjAyMjEyMjZfNjBvMzBjaGk2NG8zNGMxZzYwbzMwZHI1Nm8YsM-liJbz7gIaDwgAEgAYgMXbj4-b7wIgASIHCAIQvo_jEQ==",
"items": [
{
"kind": "calendar#event",
"etag": "\"3227284619238000\"",
"id": "20200425_60o30chi6so3gc1g60o30dr56g",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=MjAyMDA0MjVfNjBvMzBjaGk2c28zZ2MxZzYwbzMwZHI1NmcgZW4uYXVzdHJhbGlhbiNob2xpZGF5QHY",
"created": "2021-02-18T09:58:29.000Z",
"updated": "2021-02-18T09:58:29.619Z",
"summary": "ANZAC Day Observed (Victoria)",
"description": "Holiday or observance in: Victoria",
The response is returned corectly.
I am creating a networking app for musicians. I was wanting to use the Youtube Data API to let users connect their Youtube channel to their profile within my app. I got everything in place and working via making requests to URLs similar to https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&forUsername=PewDiePie&key=[YOUR_API_KEY]. This works great and returns this JSON:
{ "kind": "youtube#channelListResponse", "etag": "\"p4VTdlkQv3HQeTEaXgvLePAydmU/bj_rirVFbrVoTIOa6lCGdaXaG5M\"", "pageInfo": { "totalResults": 1, "resultsPerPage": 5 }, "items": [ { "kind": "youtube#channel", "etag": "\"p4VTdlkQv3HQeTEaXgvLePAydmU/Blp06js4r7j93y1EfKve84oXWpo\"", "id": "UC-lHJZR3Gqxm24_Vd_AJ5Yw", "snippet": { "title": "PewDiePie", "description": "I make videos.", "publishedAt": "2010-04-29T10:54:00.000Z", "thumbnails": { "default": { "url": "https://yt3.ggpht.com/a/AGF-l79FVckie4j9WT-4cEW6iu3gPd4GivQf_XNSWg=s88-c-k-c0xffffffff-no-rj-mo", "width": 88, "height": 88 }, "medium": { "url": "https://yt3.ggpht.com/a/AGF-l79FVckie4j9WT-4cEW6iu3gPd4GivQf_XNSWg=s240-c-k-c0xffffffff-no-rj-mo", "width": 240, "height": 240 }, "high": { "url": "https://yt3.ggpht.com/a/AGF-l79FVckie4j9WT-4cEW6iu3gPd4GivQf_XNSWg=s800-c-k-c0xffffffff-no-rj-mo", "width": 800, "height": 800 } }, "localized": { "title": "PewDiePie", "description": "I make videos." }, "country": "US" }, "statistics": { "viewCount": "24334379402", "commentCount": "0", "subscriberCount": "102000000", "hiddenSubscriberCount": false, "videoCount": "4054" } } ] }
Most of my app's users will be smaller musicians, likely with less than 10k youtube subscribers. Take my sister for example, this is a link to her youtube channel: https://www.youtube.com/channel/UCe4Eogv2uGaKUe4x3VNrwsg.
Whenever trying to search for her Youtube channel with the API via https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&forUsername=Audrey_Chopin&key=[YOUR_API_KEY] (and variations such as replacing Audrey_Chopin with Audrey%20Chopin or Audrey+Chopin) yield no results: { "kind": "youtube#channelListResponse", "etag": "\"p4VTdlkQv3HQeTEaXgvLePAydmU/zJL80hJ0IwMo5wddECFapC8I6Q4\"", "pageInfo": { "totalResults": 0, "resultsPerPage": 5 }, "items": [] }.
Are smaller users not supposed to be returned from this endpoint? If so, is there any way I can implement users to search for their profile without forcing the user to do the OAuth process, i.e. signing into their Youtube account?
It seems that using the /search endpoint works better for smaller channels, though there is less information available in this endpoint (I am unable to get subscriber count and video count, which was included in the "statistics" part of the /channel endpoint).
So updating
https://www.googleapis.com/youtube/v3/channels?part=snippet,statistics&forUsername=Audrey_Chopin&key=[YOUR_API_KEY]
to
https://www.googleapis.com/youtube/v3/search?part=snippet&channelType=any&maxResults=50&order=relevance&q=Audrey%20Chopin&type=channel&key=[YOUR_API_KEY]
yielded smaller channels, though without as much data as when using the /channel endpoint.
Still curious, if anybody knows, why the /channel endpoint does not return smaller channels.
Since you know the user's channel id, simply issue a query to the Channels endpoint on the URL:
https://www.googleapis.com/youtube/v3/channels?part=...&id=$CHANNEL_ID&key=$APP_KEY,
and you'll obtain all public (i.e. non-private) info attached to the referenced channel -- without needing any further authentication. Of course you can specify the part parameter as you see fit.
On the other hand, please note that querying the Search.List endpoint for snippet part is much more costly than querying the Channels.List endpoint for both snippet and statistics parts: 100 vs. 5 quota points.
I am using the gmail API to get recent hangouts messages/threads. But I can't find a way to view the recipient address. The only field in payload.headers is 'From'
code:
curl -H 'Authorization: Bearer **accessToken**' 'https://www.googleapis.com/gmail/v1/users/me/threads/**threadId**?q=is%3Achat'
response:
{
"id": "xxx",
"historyId": "1008967",
"messages": [{
"id": "xxx",
"threadId": "xxx",
"labelIds": [
"CHAT"
],
"snippet": "+Harry Howard",
"historyId": "1008953",
"internalDate": "1481641738948",
"payload": {
"partId": "",
"mimeType": "text/html",
"filename": "",
"headers": [{
"name": "From",
"value": "xxx"
}],
"body": {
"size": 13,
"data": "K0hhcnJ5IEhvd2FyZA=="
}
},
"sizeEstimate": 100
}]
}
In the case of emails, there is a 'To' field ( and sometimes cc etc).
FYI: I am using node-gmail-api npm module but just testing this with curl
Use Users.threads:list to find all users within a thread. See an example here.
HTTP request
GET https://www.googleapis.com/gmail/v1/users/userId/threads
This request requires authorization with at least one of the following scopes
https://mail.google.com/
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.readonly
https://www.googleapis.com/auth/gmail.metadata
Response
If successful, this method returns a response body with the following structure:
{
"threads": [
users.threads Resource
],
"nextPageToken": string,
"resultSizeEstimate": unsigned integer
}
I am using the Google + API to fetch a users' public activities, using the appropriate endpoint.
However, Google returns the activities in no particular order - Here is a snippet:
{
"kind": "plus#activity",
"published": "2014-07-31T13:40:41.017Z"
},
{
"kind": "plus#activity",
"published": "2014-08-27T01:51:25.378Z"
},
{
"kind": "plus#activity",
"published": "2014-09-05T02:52:33.654Z"
},
{
"kind": "plus#activity",
"published": "2014-08-12T18:00:59.920Z"
},
{
"kind": "plus#activity",
"published": "2014-08-14T18:52:00.420Z"
},
{
"kind": "plus#activity",
"published": "2014-08-01T13:41:10.034Z"
},
//[...]
So what do I have to pass into the request to get Google to send me the response in order from most recent to oldest? -- or is this something I have to do, myself?
Based on the documentation and on this issue, I'd say this is not possible at the moment with the list method, only with search.