Youtube API: Can I skip pages? (playlistItems) - youtube

Is it possible to skip pages with the Youtube API v3?
If I call this: https://www.googleapis.com/youtube/v3/playlistItems (which returns the items from a certain playlist), I get a nextPageToken and previousPageToken for navigation...
How can I skip pages?
If I'm standing on page 1, and there are 30 pages (maxResults: 50, totalResults: 1500), ... how can I go directly to page 28? am I forced to do 28 HTTP requests?

They do limit the API to returning 500 results and I've only tested this through about 200 playlist items, but in case it's of some use, I shared the algorithm that I'm using to generate page tokens here:
Youtube Data API v3 pageToken for arbitrary page

Related

https://www.googleapis.com/youtube/v3/search api returning empty response

I am trying to search videos through https://www.googleapis.com/youtube/v3/ api.
When I call the api for the first time without pageToken, i am getting pageInfo - totalResults as 1000000.
After loading more than 500 in my recyclerview, loadafter not getting called because search API returning empty items.
YouTube Search call has a soft limit of 500 results returned, regardless of total found.
See this answer how to get all: How can get all results from Youtube API (search API) response

knime youtube api search result next page

I am using the example server provided by knime to get youtube search result. But I am only able to get maximum 50 results. how do I get access to more results?
https://www.knime.com/nodeguide/data-access/rest-web-services/access-youtube-rest-api
Since it's using Youtube API, you'll be using nextPageToken to access the next results. So in your case that would be 51-100. The prevPageToken does the opposite.
pageToken
The pageToken parameter identifies a specific page in the result set
that should be returned. In an API response, the nextPageToken and
prevPageToken properties identify other pages that could be retrieved.
You can try here in Google API
Explorer.
Authorize and Execute. If there's more than 50 result, you'll notice a nextPageToken in the JSON response. Place that in the "pageToken" property and execute again. You'll be given the 51-100 results. The same thing happens with 101-150 and so forth.

Paginating in youtube API V3

I am new at youtube API V3 now I can get the videos of some user and display them at my site but now when the result is more than 50 video I want to make a paging for them lets say that my result is 240 so I have 5 pages now how I make the request for page number 4 with out go through links 1 , 2 or 3
Here is my list request:-
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUdxi8d8qRsRyUi2ERYjYb-w&key={myKey}
there are a page token that allow me to go through the links but that mean that I must to use next and prev requests
so is there any way to load page 4 direct ?
There is no way to load a specific page directly you need to call the API with the nextPageToken for each page (so 4 times in your example).
I do not recommend this approach but include it for completleness as it provides a direct solution to the question whereas the other answer provides alternatives.
Youtube seems to use the same pageTokens regardless of playlist or date of access. E.g., the pageToken for the 2nd page is always CDIQAA, for the 3rd page CGQQAA, etc.
These aren't guranteed to always remain the same, but based on stackoverflow posts from as early as 2014, it hasn't changed in a long time, so it's a reasonable assumption.
So you could make the request for the first five pages as you normally do, then persist the page tokens (e.g. in a local cache). Then whenever you need e.g. the 240th item in the future, simply look up the 5th page token (which happens to be CMgBEAA) and access that page directly.
Here are the 1st 9 page tokens:
1 <blank>
2 CDIQAA
3 CGQQAA
4 CJYBEAA
5 CMgBEAA
6 CPoBEAA
7 CKwCEAA
8 CN4CEAA
9 CJADEAA

Youtube iframe api v3 restrictions

Is there way to filter search results for videos that can be played from a certain country in youtube iframe api v3?
This call is not working:
search.setRegionCode("TR");
There is not a filter for it as of now, but from the videos in the response,
1) Do a videos.list call with id = comma separated list of all videoIds returned in your first call.
2) You can filter them by contentDetails.regionRestriction

How to get all comments on a YouTube video?

Since Google has deprecated the YouTube v2 API, I cannot find a way to get all the comments from a video.
Is it possible to use a single, non-deprecated API (Google+, YT v3) to do that?
I am not concerned about maintaining threading.
Believe me it works
https://www.googleapis.com/youtube/v3/commentThreads?key=******************&textFormat=plainText&part=snippet&videoId=kffacxfA7G4&maxResults=50
Key will be provided by the google developer console and 50 denotes 50 comments in form of a json, video id is the id of the video. For any type of queries comment below.
You can get only 100 at most at a time with the comments API. But you get a nextPageToken from the comment api response. Pass &pageToken={nextPageToken} to next api call, until the nextPageToken is undefined. Then you can get all comments if you like.
https://www.googleapis.com/youtube/v3/commentThreads?key={your_api_key}&textFormat=plainText&part=snippet&videoId={video_id}&maxResults=100&pageToken={nextPageToken}
Apparently it is now possible to fetch comment threads.
(old answer)
Currently that's impossible with a first-party tool.
Source:
While v3 offers the majority of v2 functionality, there are currently
a couple of tasks that can only be done with the older API.
Specifically, applications that manage captions or that work with
video comments still need to use the v2 API until modern equivalents
are available. Our goal is to provide similar functionality well
before the April 2015 shut-off date—please subscribe to this blog, the
YouTube Data API v3 revision history page, or follow +YouTubeDev on
Google+ to keep up-to-date. -
http://apiblog.youtube.com/2014/03/committing-to-youtube-data-api-v3.html
TubeKit (YouTube crawling toolkit) might be of help to some.
You can fetch all the comments using https://www.googleapis.com/youtube/v3/commentThreads
The Youtube API v3.0 allows you the following parameters.
textFormat - This parameter indicates whether the API should return comments formatted as HTML or as plain text. The default value is html.
videoId - The Youtube Video ID you want to fetch comments for ( if you dont know your Youtube Video ID, you can get one from Youtube Video ID Finder )
maxResults - The maxResults parameter specifies the maximum number of items that should be returned in the result set.
pageToken - The pageToken parameter identifies a specific page in the result set that should be returned. In an API response, the nextPageToken property identifies the next page of the result that can be retrieved.
$.ajax({
dataType: "jsonp",
type: 'GET',
url: "https://www.googleapis.com/youtube/v3/commentThreads?key=PUT-YOUR-KEYXXXXXXX&textFormat=plainText&part=snippet&videoId=PUT-YOUR-VIDEO-ID",
success: function(result){
data = result;
$('.data').text(data);
console.log(data);
}});
To find PUT-YOUR-KEY(API key) ---> https://console.developers.google.com/apis/credentials then click on blue color button select API key option you can get

Resources