List channel messages $top parameter causes unexpected results - microsoft-graph-api

Trying to limit the number of results returned by the List channel messages Graph API. However, when setting $top to e.g. 10, then only 3 messages are returned. When setting it to 30, then 19 messages are returned. Does $top count deleted messages that aren't returned or something like that? Is this a bug?
How do I reliably get the last 10 messages? Do I really have to ask for e.g. 30 and then filter out the rest?

When fetching all users in organization in the C# SDK, I ran into something similar. Running .Distinct() on the result set reduced the number of records to the expected amount.
BaseUrl for client appears to be https://graph.microsoft.com/v1.0

Related

YouTube v3 no longer returning paginated results past 100 records

When calling https://www.googleapis.com/youtube/v3/search?, I can get the first 50 results and subsequent 50 using the nextPageToken; however, when I try to get results past 100, the api returns a 200, gives me total request figure and returns a list - but the list is empty - "items": [].
I have been using these calls in a query for more than 18 months. Has there been a recent change to the API that I've missed in the documentation? Last change I see today doesn't address this issue and the next one from the API reference is from Nov 2017.
I ran into this exact issue when trying to get all the live broadcasts on YouTube Gaming. Everything I read resulted in some complicated explanation of how Google's search engine returns the count and why they limit some queries to 500 or so, but I have absolutely seen some companies tracking the data beyond the first 100. Nothing answered the issue you and I both ran into, but if I find something I'll report back.
It seems the "500 results" limit has been silently reduced to 100-150, by design, or by bug.
Either use date ranges, or sub-divide your queries (a and b1, a and b2, a and b3, ....) to keep each result set below 50

Microsoft Graph filter vs $filter

I am testing filtering using Microsoft Graph Explorer. I noticed odd behavior that I cannot figure out.
Using endpoint https://graph.microsoft.com/v1.0/me/events?filter=start/dateTime%20ge%20%272018-04-01%27 I get properly filtered data back.
However, using documented $ prefix, https://graph.microsoft.com/v1.0/me/events?$filter=start/dateTime%20ge%20%272018-04-01%27, I get nothing. There is no error, just no data coming back.
How do I query the data using the $filter?
You're not actually getting the results you think you are. When Microsoft Graph sees a query parameter it doesn't expect, it simply ignores it.
When you call /events?filter=start/dateTime ge '2018-04-01' it is simply ignoring the unknown filter parameter and returning you an unfiltered result.
When you call /events?filter=start/dateTime ge '2018-04-01', it is filtering out anything prior to April 1, 2018. If there are no events with a start after this date, you will get an empty array as a result.
I assume you're using the default dataset included with Graph Explorer? The default Graph Explorer data set's most recent event is 2017-11-16T08:00:00.0000000.
The reason you see results from the /calendarView endpoint but not the /events endpoint is that /events only returns single instance meetings and series masters while /celandarView shows everything within a date range. In order to avoid having to maintain a dataset with updated events, the demo data relies on a handful of recurring event entries.
Since events does not return individual occurrences of a meeting, you don't see any results from your query.
If you try this query, you'll see actual results:
https://graph.microsoft.com/v1.0/me/events?$filter=start/dateTime ge '2017-04-01'

Max Subscribers Returned (and duplicates) | YouTube API

[Problem 1]
I am using https://developers.google.com/youtube/v3/docs/subscriptions/list for a large channel (1 million subscribers) but after 100 successful pages of results (50 subscribers per page), the API always returns 0 subscribers.
Is there a hard limit of 100 pages or 5,000 subscribers that can be returned?
[Problem 2]
Of the 5,000 Subscribers returned, only 3,577 are unique. The API seems to be returning duplicates in some cases which I know is a long standing issue with getting channel subscribers. Hoping to learn if this will be fixed?
I ran into the second problem today and it seems like the duplicates happens because the default order of the API list is SUBSCRIPTION_ORDER_RELEVANCE
Acceptable values are:
alphabetical – Sort alphabetically.
relevance – Sort by relevance.
unread – Sort by order of activity.
So setting order to be alphabetical solves the problem entirely.

How can get all results from Youtube API (search API) response

Like the title.
I do a request like this :
https://www.googleapis.com/youtube/v3/search?key=AIzaSyDuxczhyyvHWfxKuF3ygW9p0GWmKlvWLYc&part=id,snippet&publishedAfter=2014-12-09T00:00:00Z&publishedBefore=2014-12-11T00:00:00Z&videoCategoryId=GCSG93LXRvICYgRElZ&type=video&maxResults=50&pageToken=
Total result is 1000000. But I just can get 500 results maximum (10 page, 50 results/page).
At 10th page, I don't see nextPageToken property to go to the next page. ???
I don't know why.
How can I get all of result.
YouTube imposes a soft limit of about 500. There is no direct way to get more than that through the API.
Full details: https://code.google.com/p/gdata-issues/issues/detail?id=4282
Relevant Excerpt:
"We can't provide more than ~500 search results for any arbitrary YouTube query via the API without the quality of the search results severely degrading (duplicates, etc.).
The v1/v2 GData API was updated back in November to limit the number of search results returned to 500. If you specify a start-index of 500 or more, you won't get back any results.
This was supposed to have also gone into effect for the v3 API (which uses a different method of paging through results) but it apparently was not pushed out, so it is still possible to retrieve up to 1000 search results in v3β€”the last 500 of which are usually of bad quality.
The change to limit v3 to 500 search results will be pushed out sometime in the near future. There will no longer be nextPageTokens returned once you hit 500 results.
I understand that the totalResults that are returned is much higher than 500 in all of these cases, but that is not the same thing as saying that we can effectively return all X million possible results. It's meant as an estimate of the total size of the set of videos that match a query and normally isn't very useful."
Updated - How to get around the 500 result max soft limit
Use the filters 'publishedAfter' and 'publishedBefore' to break up your query into loops of queries by day/week/month until no more results are returned. Each periodic query should return less than 500 results each, but you'll get them all.
There's documentation for channelId (still not for videoCategoryId) by the way
https://developers.google.com/youtube/v3/docs/search/list#channelId
Note: Search results are constrained to a maximum of 500 videos if your request specifies a value
for the channelId parameter and sets the type parameter value to video, ...

Why limited number of next page tokens?

Through a script I can collect a sequence of videos that search list returns. The maxresults variable was set to 50. The total number items are big in number but the number of next page tokens are not enough to retrieve all the desired results. Is there any way to take all the returned items or it is YouTube restricted?
Thank you.
No, retrieving the results of a search is limited in size.
The total results that you are allowed to retrieve seems to have been reduced to 500 (in the past it was limited to 1000). The api does not allow you to retrieve more from a query. To try to get more, try using a number of queries with different parameters, like: publishedAfter, publishedBefore, order, type, videoCategoryId, or vary the query tags and keep track of getting different video id's returned.
See for a reference:
https://code.google.com/p/gdata-issues/issues/detail?id=4282
BTW. "totalResults" is an estimation and its value can change on the next page call.
See: YouTube API v3 totalResults field is returning 1 000 000 when it shoudn't

Resources