SerpApi Official icon

SerpApi Official

Get live Google Search data and more from SerpApi's official node

Overview

This node performs a YouTube search using SerpApi's official API. It allows users to query YouTube for videos, channels, or playlists based on a search term and various optional parameters such as country, language, filters, and output format. This node is useful for automating the retrieval of YouTube search results within workflows, enabling scenarios like content discovery, monitoring trends, or gathering video metadata for further processing.

Practical examples:

  • Searching for the latest coffee brewing tutorials by setting the search query to "Coffee".
  • Filtering YouTube search results by country or language to get region-specific content.
  • Retrieving raw HTML output for custom parsing or scraping needs.
  • Using pagination tokens to fetch multiple pages of search results.

Properties

Name Meaning
Search Query (search_query) The main search term or phrase to query on YouTube. Can be any string you would normally use in a YouTube search (e.g., "Coffee").
Additional Fields A collection of optional parameters to refine the search:
- Country (gl) Defines the country code to tailor the search results geographically (e.g., "us" for United States, "de" for Germany).
- Language (hl) Defines the language code for the search interface and results (e.g., "en" for English, "fr" for French).
- Filter (sp) Used for pagination or filtering results. For pagination, use the next_page_token from previous results. For filters, copy the sp parameter from YouTube URL after applying filters manually.
- Disable Caching (no_cache) Boolean flag to force fetching fresh results instead of cached ones. Cached results are free and expire after 1 hour. Default is false (allow cache).
- Async (async) Boolean flag to perform the search asynchronously. If true, the search is submitted and results must be retrieved later via a separate API call. Cannot be used with no_cache enabled. Default is false (synchronous).
- ZeroTrace Mode (zero_trace) Enterprise-only boolean flag to disable storing search parameters and metadata on SerpApi servers for privacy. Default is false.
- Output (output) Defines the output format: "json" for structured JSON data (default), or "html" for raw HTML response.
- JSON Restrictor (json_restrictor) Allows restricting the JSON response fields to specific parts, e.g., limiting to certain result items or fields for smaller payloads.

Output

The node outputs a JSON object containing the YouTube search results as returned by SerpApi. This includes metadata about the search, organic results (videos, channels, playlists), pagination tokens, and other relevant information depending on the query parameters.

If the output format is set to "html", the node returns the raw HTML content of the YouTube search page.

No binary data output is produced by this node.

Dependencies

  • Requires an active SerpApi account with a valid API key credential configured in n8n.
  • Internet access to reach SerpApi's endpoint at https://serpapi.com/search.json.
  • Proper configuration of the API key credential in n8n to authenticate requests.

Troubleshooting

  • Common issues:

    • Invalid or missing API key credential will cause authentication errors.
    • Using incompatible combinations of parameters, such as enabling both async and no_cache, will result in errors.
    • Incorrect country or language codes may yield unexpected or empty results.
    • Pagination tokens (sp) must be correctly copied from previous responses or URLs; otherwise, pagination will fail.
  • Error messages:

    • Authentication failures typically indicate invalid or missing API keys. Verify your API key credential setup.
    • Parameter validation errors occur if unsupported values are provided for options like country or language.
    • Rate limit exceeded errors mean you've hit your SerpApi usage quota; consider upgrading your plan or reducing request frequency.

Links and References

Discussion