YouTube Search API

YouTube Search API uses /api/v1/search?engine=youtube API endpoint to scrape real-time search results. It parses ads, videos, shorts, search suggestions, channels, playlists, and more. It supports infinite scrolling and all the native YouTube filters.

API Parameters

Search Query

  • Name
    q
    Required
    Required
    Description

    Parameter defines the query you want to search. You can use any advanced search operators that you would use in a regular YouTube search.

Filters

  • Name
    sp
    Required
    Optional
    Description

    The parameter defines filters that can be applied to YouTube search results. For example, the CAI filter restricts the search to videos that were uploaded recently.
    This parameter is also used when fetching the next page of search results, which includes the same filters that were used in previous page.

Localization

  • Name
    gl
    Required
    Optional
    Description

    The default parameter us defines the country of the search. Check the full list of supported YouTube gl countries.

  • Name
    hl
    Required
    Optional
    Description

    The default parameter en defines the interface language of the search. Check the full list of supported YouTube hl languages.

Engine

  • Name
    engine
    Required
    Required
    Description

    Parameter defines an engine that will be used to retrieve real-time data. Current engine - youtube.

API key

  • Name
    api_key
    Required
    Required
    Description

    The api_key authenticates your requests. Use it as a query parameter (https://www.searchapi.io/api/v1/search?api_key=YOUR_API_KEY) or in the Authorization header (Bearer YOUR_API_KEY).

API Examples

Full Response - Query

Full Response - Query
GET
https://www.searchapi.io/api/v1/search?engine=youtube&q=Fortnite
Request
import requests

url = "https://www.searchapi.io/api/v1/search"
params = {
  "engine": "youtube",
  "q": "Fortnite"
}

response = requests.get(url, params = params)
print(response.text)
Response
{
  "search_metadata": {
    "id": "search_kQzy2PnvoBkZC7A83Yx0EK15",
    "status": "Success",
    "created_at": "2023-05-09T08:47:55Z",
    "processed_at": "2023-05-09T08:47:55Z",
    "request_time_taken": 1.97,
    "parsing_time_taken": 0.05,
    "total_time_taken": 2.01,
    "request_url": "https://www.youtube.com/results?search_query=Fortnite",
    "html_url": "https://www.searchapi.io/api/v1/searches/search_kQzy2PnvoBkZC7A83Yx0EK15.html",
    "json_url": "https://www.searchapi.io/api/v1/searches/search_kQzy2PnvoBkZC7A83Yx0EK15"
  },
  "search_parameters": {
    "engine": "youtube",
    "q": "Fortnite"
  },
  "results": "251993762",
  "ads": [
    {
      "position": 1,
      "id": "u3jp4wsPQXM",
      "title": "Best Zombie Mobile Game is on PC now.",
      "link": "https://www.youtube.com/watch?v=u3jp4wsPQXM",
      "description": "How long can you last in this zombie world?",
      "website": "https://www.googleadservices.com/pagead/aclk?...",
      "channel": {
        "id": "UCSqc6ppsKEfSe_ivghzfozA",
        "title": "SOS",
        "link": "https://www.youtube.com/channel/UCSqc6ppsKEfSe_ivghzfozA"
      },
      "length": "0:30",
      "extensions": ["Ad"],
      "thumbnail": "https://i2.ytimg.com/vi/u3jp4wsPQXM/0.jpg"
    }
  ],
  "videos": [
    {
      "position": 2,
      "id": "H4p6WAjiq60",
      "title": "The *FORCE* ONLY Challenge in Fortnite!",
      "link": "https://www.youtube.com/watch?v=H4p6WAjiq60",
      "description": "Fortnite Star Wars FORCE ONLY Chapter 4, Season 2 gameplay with Typical Gamer! SUBSCRIBE & CLICK THE BELL! Merch: ...",
      "views": "65,220 views",
      "extracted_views": 65220,
      "live": false,
      "channel": {
        "id": "UCqVCSWnuOSPm26orvNDTuWQ",
        "title": "TG Plays",
        "link": "https://www.youtube.com/@TGplays",
        "verified": "Verified",
        "thumbnail": "https://yt3.ggpht.com/ytc/AGIKgqNylx0sO2pv22NDr2m5bOiGSsuaDBfw8l_gJFmdjg=s68-c-k-c0x00ffffff-no-rj"
      },
      "length": "20:08",
      "published_time": "4 hours ago",
      "extensions": ["New"],
      "thumbnail": {
        "static": "https://i.ytimg.com/vi/H4p6WAjiq60/hq720.jpg?sqp=-oaymwEcCOgCEMoBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBhFqjSpc_swUk7evNZW2duyibpRw",
        "rich": "https://i.ytimg.com/vi/H4p6WAjiq60/hq720.jpg?sqp=-oaymwEcCNAFEJQDSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLDsW8XfTdvm6H7_PZ2K78xzbz4d9g"
      }
    },
    ...
  ],
  "sections": [
    {
      "section_title": "Popular today",
      "position": 8,
      "items": [
        {
          "position": 1,
          "id": "D4zFFCv40gw",
          "title": "Fortnite Kids think Fortnite created Everything",
          "link": "https://www.youtube.com/watch?v=D4zFFCv40gw",
          "description": "Use Creator Code HEW #hewmoran #comedy #gaming click these links for cool things • Discord - https://discord.gg/hewmoran ...",
          "views": "11,000,253 views",
          "extracted_views": 11000253,
          "live": false,
          "channel": {
            "id": "UC59Ied2j88dZUw7PzJa2-YA",
            "title": "Hew Moran",
            "link": "https://www.youtube.com/@HewMoran",
            "verified": "Verified",
            "thumbnail": "https://yt3.ggpht.com/_W4q2lYQtRI-ioPsRD9VnChQBSv1WRiN5zFSnSJh2qAM3NUFOP-Od4_2fTPfaDbxzFWnYxJ0FWI=s68-c-k-c0x00ffffff-no-rj"
          },
          "length": "0:24",
          "published_time": "6 days ago",
          "extensions": ["New", "4K"],
          "thumbnail": {
            "static": "https://i.ytimg.com/vi/D4zFFCv40gw/hq720_2.jpg?sqp=-oaymwE2COgCEMoBSFXyq4qpAygIARUAAIhCGABwAcABBvABAfgBtgiAAoAPigIMCAAQARhcIFcoZTAP&rs=AOn4CLBcWNXYucSAZAZN95tLM_Z2T5Nz9g",
            "rich": "https://i.ytimg.com/vi/D4zFFCv40gw/hq720_2.jpg?sqp=-oaymwE2CNAFEJQDSFXyq4qpAygIARUAAIhCGABwAcABBvABAfgBtgiAAoAPigIMCAAQARhcIFcoZTAP&rs=AOn4CLA7ZVJU6BUrNY3W33LPrWdzn5udxA"
          }
        }
      ]
    },
    {
      "section_name": "Shorts",
      "position": 11,
      "items": [
        {
          "position": 1,
          "id": "ES4bcJuMKng",
          "title": "SUS EMOTES IN FORTNITE 😳",
          "link": "https://www.youtube.com/shorts/ES4bcJuMKng",
          "duration": " 56 seconds ",
          "views": "8.8M views",
          "thumbnail": "https://i.ytimg.com/vi/ES4bcJuMKng/oar2.jpg?sqp=-oaymwEaCJUDENAFSFXyq4qpAwwIARUAAIhCcAHAAQY=&rs=AOn4CLBGLoDCjJTJox_6Pi9kLQL33JDM0A"
        },
        ...
      ]
    },
    ...
  ],
  "company": {
    "id": "UCXzGWycANrrfyBmzX6JMsvQ",
    "title": "Fortnite",
    "subtitle": "Video game • Released: 2017",
    "link": "https://www.youtube.com/channel/UCXzGWycANrrfyBmzX6JMsvQ",
    "highligted_video": {
      "id": "U82Olpfh45A",
      "title": "Find the Force - the Ultimate Star Wars Experience in Fortnite",
      "subtitle": "Epic Games • 7K views • 22 hours ago",
      "link": "https://www.youtube.com/watch?v=U82Olpfh45A",
      "length": "0:34"
    },
    "videos": [
      {
        "id": "LH0K7NkhcfM",
        "title": "Fortnite Champion Series 2023 | Major 2 | Surge Week | N. America",
        "link": "https://www.youtube.com/watch?v=LH0K7NkhcfM&pp=ygUIRm9ydG5pdGU%3D",
        "length": "3:22:45",
        "channel": {
          "id": "UClG8odDC8TS6Zpqk9CGVQiQ",
          "title": "Fortnite",
          "link": "https://www.youtube.com/@fortnite"
        },
        "thumbnail": "https://i.ytimg.com/vi/LH0K7NkhcfM/hq720.jpg?sqp=-oaymwEcCOgCEMoBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLDD7O1y5wbGf6SWaLxBxO_D2dkbgQ"
      },
      ...
    ]
  },
  "pagination": {
    "next_page_token": "SBSCAQstMk9wWVg3RGoyZ4IBC2pNU3BCUnBzdW44ggELR0FfT3c3dFJnR2OCAQtJOTVTazBQcHJ2UYIBC2FHMk1oN0FwaEZzggELaFVULXgxM3hlQnOCAQtXeE0zMHNvdWNRb4IBC290bmxVYXVoNVE0ggELOHNFZm9KXzQtWEmCAQthR0QwZlFGVTh1QYIBCzNnOVlucWJVY3BjggELTkl3Rmt4QllVQ0mCAQt5bVZnU0lxb2dNa4IBC25EcHc1U1hJMmNnggELOE5DdndvQVFJLUGCAQtSQmFCYjM0Mlh5OIIBCzR2OUQtekwydVc0ggELbVE0WllQRUN1MziCAQt3Z1FEeTZhZGd1RYIBC01OcW9SUE1YNElBsgEGCgQIHBAC6gECCAI%3D"
  }
}

Full Response - Most viewed sp filter

Full Response - Most viewed sp filter
GET
https://www.searchapi.io/api/v1/search?engine=youtube&q=Fortnite&sp=CAM%25253D
Request
import requests

url = "https://www.searchapi.io/api/v1/search"
params = {
  "engine": "youtube",
  "q": "Fortnite",
  "sp": "CAM%253D"
}

response = requests.get(url, params = params)
print(response.text)
Response
{
  "search_metadata": {
    "id": "search_Amrlde4qgnnOHQmLgL8Pvjx0",
    "status": "Success",
    "created_at": "2023-05-09T11:01:30Z",
    "processed_at": "2023-05-09T11:01:30Z",
    "request_time_taken": 1.68,
    "parsing_time_taken": 0.04,
    "total_time_taken": 1.72,
    "request_url": "https://www.youtube.com/results?search_query=Fortnite&sp=CAM%3D",
    "html_url": "https://www.searchapi.io/api/v1/searches/search_Amrlde4qgnnOHQmLgL8Pvjx0.html",
    "json_url": "https://www.searchapi.io/api/v1/searches/search_Amrlde4qgnnOHQmLgL8Pvjx0"
  },
  "search_parameters": {
    "engine": "youtube",
    "q": "Fortnite",
    "sp": "CAM%3D"
  },
  "results": "252137211",
  "ads": [
    {
      "position": 1,
      "id": "hvoD7ehZPcM",
      "title": "Play Free on Desktop",
      "link": "https://www.youtube.com/watch?v=hvoD7ehZPcM",
      "description": "Gta V - Play Free on Desktop",
      "website": "https://www.googleadservices.com/pagead/aclk?...",
      "channel": {
        "id": "UC6VcWc1rAoWdBCM0JxrRQ3A",
        "title": "Rockstar Games",
        "link": "https://www.youtube.com/user/RockstarGames"
      },
      "length": "1:01",
      "extensions": ["Ad"],
      "thumbnail": "https://i1.ytimg.com/vi/hvoD7ehZPcM/0.jpg"
    }
  ],
  "videos": [
    {
      "position": 2,
      "id": "wYeFAlVC8qU",
      "title": "Travis Scott and Fortnite Present: Astronomical (Full Event Video)",
      "link": "https://www.youtube.com/watch?v=wYeFAlVC8qU",
      "description": "Astronomical is an other-worldly experience by Travis Scott and Cactus Jack's creations, built from the ground up in Fortnite.",
      "views": "203,404,217 views",
      "extracted_views": 203404217,
      "channel": {
        "id": "UCtxdfwb9wfkoGocVUAJ-Bmg",
        "title": "Travis Scott",
        "link": "https://www.youtube.com/channel/UCtxdfwb9wfkoGocVUAJ-Bmg",
        "verified": "Official Artist Channel",
        "thumbnail": "https://yt3.ggpht.com/ytc/AGIKgqP4L9yLoLX6IcTyc_QO65X3ZhOFKACSnj09e3rqTw=s88-c-k-c0x00ffffff-no-rj"
      },
      "length": "8:58",
      "published_time": "3 years ago",
      "thumbnail": {
        "static": "https://i.ytimg.com/vi/wYeFAlVC8qU/hq720.jpg?sqp=-oaymwEcCOgCEMoBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLDscnRk_g5mtpN_NXgT04LE8iLmeA",
        "rich": "https://i.ytimg.com/vi/wYeFAlVC8qU/hq720.jpg?sqp=-oaymwEcCNAFEJQDSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLC1CeTGFmi-FiczD1ldigfq-qR9ZA"
      }
    },
    ...
  ],
  "sections": [
    {
      "section_name": "Shorts",
      "position": 6,
      "items": [
        {
          "position": 1,
          "id": "GA_Ow7tRgGc",
          "title": "Top 10 Fortnite Skins That NEVER Returned",
          "link": "https://www.youtube.com/shorts/GA_Ow7tRgGc",
          "duration": " 53 seconds ",
          "views": "36K views",
          "thumbnail": "https://i.ytimg.com/vi/GA_Ow7tRgGc/oar2.jpg?sqp=-oaymwEaCJUDENAFSFXyq4qpAwwIARUAAIhCcAHAAQY=&rs=AOn4CLCWDkc8JWZyUzyurIIR8thbQyr5YA"
        },
        ...
      ]
    },
    {
      "section_name": "Shorts",
      "position": 10,
      "items": [
        {
          "position": 1,
          "id": "aG2Mh7AphFs",
          "title": "Why You Should Give Fortnite Players the Win..🥹",
          "link": "https://www.youtube.com/shorts/aG2Mh7AphFs",
          "duration": " 56 seconds ",
          "views": "2.6M views",
          "thumbnail": "https://i.ytimg.com/vi/aG2Mh7AphFs/hq720.jpg?sqp=-oaymwEdCJUDENAFSFXyq4qpAw8IARUAAIhCcAHAAQbQAQE=&rs=AOn4CLCpUsMsug8p70d7a6BS5r8YC2Eh8Q"
        },
        ...
      ]
    }
  ],
  "pagination": {
    "next_page_token": "CANIFIIBCzRDUTZuODVQbkdnggELTkl3Rmt4QllVQ0mCAQtTQ05ycHdUbi14TYIBCzQ3dHFHOERTbFVFggELRzdRX3NxWkRJTneCAQtzMDczXzRlRkVZb4IBC0VObVJ5aHEza0UwggELejg5RTBQd2RaSFWCAQtkYWVqMmljYzZ3a4IBC3A5bjRtVnJaVHJRggELdHF3Zm1UNWIxb0WCAQtxTzAwUGdrcTk2NIIBC21paHQ2TGdrcWIwggELdTRjZFFId3hDRWOCAQtXeE0zMHNvdWNRb4IBC1N3SzJUTjBqTUJNggELdUsxMDVHS3pGWkGCAQt2bGZWSlBfQnh4RYIBC0pXdE9BdExUY3dBggELSlctS0liVjlQUlWyAQYKBAgXEALqAQIIAg%3D%3D"
  }
}