Reference: https://developers.google.com/youtube/2.0/developers_guide_protocol_contacts#Retrieve_contacts
Note that the API returns a maximum of 100 contacts for any given contact feed request even if more contacts match the request parameters.
Question: How / Where do we define the request parameters to narrow down a long list of contacts (100+) to a short list (<=100) ?
I would expect something like an authenticated request to:
https://gdata.youtube.com/feeds/api/users/default/contacts?v=2&q=wildcard+querystring+wildcard
or
/feeds/api/users/default/contacts?v=2&fields=entry[yt:username: * da *]
and what is the wildcard (does asterics work)?
Given that the response includes the pagination info:
<openSearch:totalResults>4</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>25</openSearch:itemsPerPage>
You could page through the results. See Paging through results in the docs.
Related
I call YT.Channel API with a list of Ids and I get an error:
GoogleJsonResponseException: API call to youtube.channels.list failed with error: Request contains an invalid argument.
YouTube.Channels.list('id, snippet, statistics', {
id: resultsParentChannelIdsPerPage.join()
}).getItems()
id = UC5JU3rLOMvB7ZIXI2oi1ubg,UC4mKtxAtWQgmkFC6S6siNVg,UC-4hR9ralZoAW15tAwSbJ_A,UCvdwiASqQrIIozQcVAXvRXw,UCUIKx2bIjRcBWyIa3AQGSCg,UClkJAMCknefAzrYfpk1_0Nw,UCsDm3gAWuDRDLMjZLoUxOuA,UC-OkSUXpLrS2eBpztAJ78wg,UCb6RivygioXGs0icq4McBdg,UCmAf6BdYS-5QmXxBuJZgNpQ,UC6rDrJjome8e_iBQI1MLeZg,UCJ0lYZCucWTPc_IfE2vZNTg,UCVy5saLw3psF5laPWhahGHA,UCXskq-my9ltmT6SpdL7b_cw,UCpctmQs9AEwiIZgTcWSV0mg,UCv4ZlVO5-z-uVIm1Y6ol-DA,UCPtQnd-8OBSzvqnQVKaA_8g,UC_uQYR3lHS36jkBRqdvQIFw,UCoJuf64ajKTOZ6mX30zulKg,UCM-GJfgjXFajHll_uGeZPBQ,UC2ojGYd_fg8oU71beXUMW9g,UCT_dVMJ2eSGKugeXnMZcbfQ,UC6PHRps6wOfBJKoDxEI37Ew,UC2Ra3RK4FW38skAoYEtXJbQ,UC2u7_TuItL4on_9SuwJhO_A,UCt-gKqNg_k2bb-bSe7y3z4g,UC2UotqDGeOMUl-gQG3t9sKw,UCdbVBcrKBtu8oUcp4JuLpvw,UCKHpDyswx5VskURci4FPqUA,UCiNHdTU2jYRbUf1cbMCxdaQ,UC3osMa_MdseDVrXlbZFSZDw,UCbnwaC-Tbi1duuDbjfV-Thg,UCBOrTOryVc2JKsNOu7_wO6g,UCM8UoJ4z4NMvp5pwYQjx8uQ,UCnU2sysDk58MuMQHxqgDd7w,UCuldUFBFddgeVN6HJ-yIBjA,UCsEgNI5S2Vdy3Q7LizK2OSA,UClN9w3sTTs6lpntoeHyYvSA,UCgZlOI3AqanZW0tjCSJCKfA,UCqS9WhAUJ-6PiC-8mZ0rDSQ,UCBH5Es0HeCBBlHvWG9c2ipA,UCpPgyVE8TKJr-MnpB44Au4w,UCJxgQl6TU8FGmMzG24xxYFg,UCpe9hHSEkTs5BD6Ufi0-XuA,UCrk1G4da0dsnLsPjsov5fTA,UCtF629dMzswzAupMUEO-bPw,UCsRcjJkUmU_Ny5D9pn5ZGDw,UC5Wm0eXXRAA6Pcjlq8-EaLw,UCOakkksW_nWRDkPl43VzAQA,UC4JhVBsy-Yfr3dQy7G1EYuQ,UCfS8vOYmleKZU8zNjzsZ6qg,UCPWsJzhhZSPlfQ7DOjSA4Fg,UCPKKa8RgdfoMRBkyt8BhIqA,UCa3bfoq50eqErBDgq0p2cQA,UCyH05wKVW-96Lz2mqhGnzVw,UCiXjl5HwqmuCjr5ZmW00csQ,UCA9tlIHeg-k8z3PUpozkUmA,UC_Bc8M2p5fpYqlfWvbVmw2g,UCnD86huZnRWKDMZISbQx6kg,UCtRn5U4Uz2vbREF0qD0TLuA
I didn't get this in previous similar runs. What has changed?
API explorer
Nothing has changed, as far as I know. Fact is that -- with the exception of CommentThreads.list, Comments.list and Members.list endpoints -- all YouTube Data API endpoints that are providing result sets would not return result sets of more than 50 items.
Therefore, when using the Channels.list endpoint's request parameter id, you'll have to limit yourself to pass to it a comma-separated list of channel IDs of at most 50 elements.
We got to build our own reporting database for our Youtube channel to measure the channel and video performance.
To support this, we implemented an ETL job to extract using Youtube Analytics API and used below python code to get the data.
def GetAnalyticsData(extractDate,accessToken, channelId):
channelId = 'channel%3D%3D{0}'.format(channelId)
headers = {'Authorization': 'Bearer {}'.format(accessToken),
'accept': 'application/json'}
url = 'https://youtubeanalytics.googleapis.com/v2/reports?dimensions={dimensions}&endDate={enddate}&ids={ids}&maxResults={maxresults}&metrics={metrics}&startDate={startdate}&alt={alt}&sort={sort}'.format(
dimensions='video',
ids=channelId,
enddate= extractDate,
startdate=extractDate,
metrics = 'views%2Ccomments%2Clikes%2Cdislikes%2Cshares%2CestimatedMinutesWatched%2CsubscribersGained%2CsubscribersLost%2CannotationClicks%2CannotationClickThroughRate%2CaverageViewDuration%2CaverageViewPercentage%2CannotationCloseRate%2CannotationImpressions%2CannotationClickableImpressions%2CannotationClosableImpressions%2CannotationCloses',
maxresults = 200,
alt ='json',
sort='-views'
)
return requests.get(url,headers=headers)
We hit this API everyday and get all the video metric and sorted by views in descending order.
This solved our need partially and it returns only 200 videos, if we specify maxResults more than 200, its return 400 error code.
The challenge is, how to get all videos for the given date and given channel?
Thanks in advance.
Regards,
Guna
I am not keen on YouTube analytics API, but it seems that you are looking for startIndex.
startIndex
integer
The 1-based index of the first entity to retrieve. (The default value is 1.) Use this parameter as a pagination mechanism along with the max-results parameter.
So this is sort of weird. For every 1 request sent from my website using our YouTube API key, the developer console shows 102 queries actually being made. Here is the query format (using Python) -
search_q = '<query-string-here>'
service = build('youtube', 'v3', developerKey='<api-key>')
results = service.search().list(
part='snippet',
channelId='<specific-channel-id-to-search-through>',
type='video',
q=search_q,
).execute()
My logs show only one request being sent using this but my query count on the quotas page increases by 102.
Is there something I'm doing wrong? Or is this a bug on Google's end?
You can use the Quota Calculator to approximate the quota costs your request is using. Sure enough the search API request quota is on 100 range:
I am using Zend's gdata library for the Google Apps provisioning API. Since Zend doesn't yet support fetching org users (no retrieve function provided by the library for this feed), I am making a custom gdata query to the url (as suggested in the documentation developers.google.com/google-apps/provisioning/#retrieving_organization_users_experimental):
apps-apis.google.com/a/feeds/orguser/2.0/'.$customerId.'?get=all
This works well for <= 100 users.
Now, I have created a domain with 125 users across 5 OUs. When I fetch the above URI, I get the 1st 100 users (as documented and expected). However, I could not find the pagination link mentioned here: developers.google.com/google-apps/provisioning/reference#Results_Pagination
Here's the start of my orguser feed:
<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:apps='http://schemas.google.com/apps/2006'><id>https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx</id><updated>2013-01-06T08:17:43.520Z</updated><**link rel='next' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx?get=all&startKey=RASS03jtnz0s2orxmbn.**'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxx'/>
I tried the https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx?get=all&startKey=RASS03jtnz0s2orxmbn. link but it gives me the exact same 100 users that the https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxxx?get=all link gives. This is the only occurrence of the word "next" in my feed and so there is not other URI I can try to fetch the next 25 users.
So I have only been able to get 100 users from this API call. How do I go about fetching the next 25 users? Examples/code would be really appreciated. Or what am I doing wrong?
Please help - this is blocking an urgent delivery.
Thanks!,
Vinay.
Your 2nd request should look like:
https://apps-apis.google.com/a/feeds/orguser/2.0/C00xxxxxx?startKey=RASS03jtnz0s2orxmbn&get=all
startKey should be set to the value of the next parameter and get should continue to be all for each page request.
Also, make sure the URL is decoded, if & is encoded as & in the request, then Google's servers will see all of all&startKey=RASS03jtnz0s2orxmbn as the value of get and it won't see a startKey parameter at all.
Is it possible to get tweets which contain photos? I am currently using twitter search api and getting all the tweets having entity details by setting include_entities=true. I see picture details under media object but is there anyway to filter and get tweets objects which just have these media items. Or is there anyway in Twitter4j to do this query?
There is no specific way to specify that I need only photos or videos but you can filter the results based on filter:links or filter:images or filter:videos in your query along with include_entities=true.
For Example: To get the tweets that contain links since 2012-01-31, you query should have include_entities parameter as well as filter:links as shown as follows:
https://search.twitter.com/search.json?q=from%3Agoogle%20since%3A2012-01-31%20filter%3Alinks&include_entities=true"
As your need is to filter your tweets based on images/photos, I think you should use filter:images.
An example of your case would look like:
https://search.twitter.com/search.json?q=from%3Agoogle%20since%3A2012-01-31%20filter%3Aimages&include_entities=true"
Hope this helps.
With Latest twitter API I couldn't get filters work and I couldn't find either any explanation in their docs. Althought you can get all the tweets and then parse only the media ones. You can fire this if inside your parsing script:
if(this.entities.media != null){
//Parse the tweet
}
This is not the best solution but the worst part comes to twitter who's giving you more information and using more of its own resources.
In the lastest twitter API you can do it in the ConfigurationBuilder instance, before creating the Twitter instance:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(false);
cb.setOAuthConsumerKey(API_KEY);
cb.setOAuthConsumerSecret(API_SECRET);
cb.setOAuthAccessToken(ACCESS_TOKEN);
cb.setOAuthAccessTokenSecret(SECRET_KEY);
// enabling include_entities parameters
cb.setIncludeEntitiesEnabled(true);
Twitter twitterInstance = new TwitterFactory(cb.build()).getInstance();
Also, after enabling the entities, in the search string you have to had the condition "filter:images".
List<String> keywords = new ArrayList<String>();
keywords.add("#pet");
keywords.add("cat");
// String.join for Java 8
String twitterSearchString = "((" + String.join(" OR ", keywords) + ")";
// adding the filter condition
twitterSearchString += " AND filter:images)";
Query q = new Query(twitterSearchString);
And you will get just results with images (tested with twitter4j-core 4.0.4).
For filter in twitter API you can check official document for latest version as on date Apr 02 2019
https://developer.twitter.com/en/docs/tweets/search/guides/standard-operators.html