Vadakkumpadath
Vadakkumpadath

Reputation: 1485

What is the maximum HTTP GET request length for a YouTube API?

I want to use youtube video:list api to get details of multiple videos in single request. As per the api documentation, I can send comma separated videoId list as id parameter. But what is the maximum length possible?

I know the GET request limit is dependent on both the server and the client. In my case I am making the request from server-side and not from browser. Hence the maximum length could be configured on my end. But what is the maximum length acceptable for youtube?

UPDATE: Though official documentation couldn't find, current limit is 50 ids from the tests performed as explained by Tempus. I am adding a code below with 51 different video ids (1 is commented) for those who want to check this in future.

var key = prompt("Please enter your key here");
if (!key) {
	alert("No key entered");
} else {
	var videoIds = ["RgKAFK5djSk",
		"fRh_vgS2dFE",
		"OPf0YbXqDm0",
		"KYniUCGPGLs",
		"e-ORhEE9VVg",
		"nfWlot6h_JM",
		"NUsoVlDFqZg",
		"YqeW9_5kURI",
		"YQHsXMglC9A",
		"CevxZvSJLk8",
		"09R8_2nJtjg",
		"HP-MbfHFUqs",
		"7PCkvCPvDXk",
		"0KSOMA3QBU0",
		"hT_nvWreIhg",
		"kffacxfA7G4",
		"DK_0jXPuIr0",
		"2vjPBrBU-TM",
		"lp-EO5I60KA",
		"5GL9JoH4Sws",
		"kOkQ4T5WO9E",
		"AJtDXIazrMo",
		"RBumgq5yVrA",
		"pRpeEdMmmQ0",
		"YBHQbu5rbdQ",
		"PT2_F-1esPk",
		"uelHwf8o7_U",
		"KQ6zr6kCPj8",
		"IcrbM1l_BoI",
		"vjW8wmF5VWc",
		"PIh2xe4jnpk",
		"QFs3PIZb3js",
		"TapXs54Ah3E",
		"uxpDa-c-4Mc",
		"oyEuk8j8imI",
		"ebXbLfLACGM",
		"kHSFpGBFGHY",
		"CGyEd0aKWZE",
		"rYEDA3JcQqw",
		"fLexgOxsZu0",
		"450p7goxZqg",
		"ASO_zypdnsQ",
		"t4H_Zoh7G5A",
		"QK8mJJJvaes",
		"QcIy9NiNbmo",
		"yzTuBuRdAyA",
		"L0MK7qz13bU",
		"uO59tfQ2TbA",
		"kkx-7fsiWgg",
		"EgqUJOudrcM",
	//	"60ItHLz5WEA" // 51st VideoID. Uncomment it to see error
	];
	var url = "https://www.googleapis.com/youtube/v3/videos?part=statistics&key=" + key + "&id=" + videoIds.join(",");
	var xmlHttp = new XMLHttpRequest();
	xmlHttp.onreadystatechange = function() {
		(xmlHttp.readyState == 4) && alert("HTTP Status code: " + xmlHttp.status);
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send(null);
}

Upvotes: 0

Views: 561

Answers (1)

Tempus
Tempus

Reputation: 785

The answer is 50. Reason being, is that is all you will get back.

As some calls can have quite a few results depending on search criteria and available results, they have capped the "maxResults" at 50. Acception to this is the CommentThreads which are up to 100.

This is (as you can work out) to speed page loads and call times.

EDIT:
This can be tested out HERE in the "Try api" part.
You will need to put 50 videoID's into the "id" field separated by coma's.
Then ad one more ID to get 51 and test again. You should receive a "400" response.

P.S. they do not need to be unique ID's. So have a few and then copy and paste as many times as needed ;-)

Upvotes: 2

Related Questions