using System;
using System.Net.Http;
class Program
{
static async Task Main()
{
var client = new HttpClient();
var query = System.Web.HttpUtility.ParseQueryString(string.Empty);
query["engine"] = "youtube";
query["q"] = "abc";
query["no_cache"] = "false";
query["api_key"] = "YOUR_API_KEY";
var response = await client.GetAsync(
$"https://serpapi.abcproxy.com/search?{query}"
);
Console.WriteLine(await response.Content.ReadAsStringAsync());
}
}
import java.net.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://serpapi.abcproxy.com/search" +
"?engine=youtube" +
"&q=abc" +
"&no_cache=false" +
"&api_key=YOUR_API_KEY";
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
conn.setRequestMethod("GET");
BufferedReader in = new BufferedReader(
new InputStreamReader(conn.getInputStream())
);
String response = in.lines().collect(Collectors.joining());
System.out.println(response);
}
}
API Parameters
Search Query
Name
Type
Required
Description
Example
search_query
string
Yes
Parameter defines the search query. You can use anything that you would use in a regular YouTube search.
123
Localization
Name
Type
Required
Description
Example
gl
string
No
us
hl
string
No
en
Advanced Google Play Parameters
Name
Type
Required
Description
Example
sp
string
No
-
Serpapi Parameters
Name
Type
Required
Description
Example
engine
string
Yes
Set parameter to youtube to use the YouTube API engine.
google_play
no_cache
boolean
No
Parameter will force SerpApi to fetch the YouTube results even if a cached version is already present. A cache is served only if the query and all parameters are exactly the same. Cache expires after 1h. Cached searches are free, and are not counted towards your searches per month. It can be set to false (default) to allow results from the cache, or true to disallow results from the cache.
Parameter defines the country to use for the Google search. It's a two-letter country code. (e.g., us for the United States, uk for United Kingdom, or fr for France) Head to the for a full list of supported Google countries.
Parameter defines the language to use for the Youtube search. It's a two-letter language code. (e.g., en for English, es for Spanish, or fr for French). Head to the for a full list of supported Google languages.
Parameter can be used for pagination. Youtube uses continous pagination and the next page token can be found in the SerpApi JSON responseserpapi_pagination -> next_page_token and pagination -> next_page_token fields.
Parameter can also be used to filter the search results:
by Upload date, you need to set the sp parameter to CAI%3D
by 4K, you need to set the sp parameter to EgJwAQ%3D%3D
...
It can also be used for forcing the exact search query spelling by setting the sp value to QgIIAQ%3D%3D.
If you are interested in passing other filters, you can visit the website, set filters you want and simply copy sp value from their URL to SerpApi URL.