Search
YouTube search results for a query, with the same sorting and filters the site offers.
GET/v1/youtube/search
Costs 1 credit per request. Only requests that return data are charged.
Parameters
| Name | Type | Description |
|---|---|---|
qrequired |
string | The search query. |
limitoptional |
integer | How many results to return. Default: 20. From 1 to 40. |
typeoptional |
string | Kind of result. One of: video, short, channel, playlist, all. Default: video. |
sortoptional |
string | Result order. One of: relevance, popularity, newest, mostViewed. Default: relevance. |
uploadedoptional |
string | Only results uploaded within this period. One of: hour, today, week, month, year. |
countryoptional |
string | Two-letter country code the search is run for. |
langoptional |
string | Interface language code for titles and labels. |
Example request
curl "https://pipefetch.com/v1/youtube/search?q=web+scraping+tutorial&limit=20" \
-H "x-api-key: YOUR_API_KEY"const res = await fetch('https://pipefetch.com/v1/youtube/search?q=web+scraping+tutorial&limit=20', {
headers: { 'x-api-key': process.env.PIPEFETCH_API_KEY },
});
const { data, credits } = await res.json();import os, requests
res = requests.get(
"https://pipefetch.com/v1/youtube/search",
params={"q": "web scraping tutorial", "limit": 20},
headers={"x-api-key": os.environ["PIPEFETCH_API_KEY"]},
)
data = res.json()["data"]Example response
A real answer to the request above. Long texts and lists are shortened here.
{
"data": {
"query": "web scraping tutorial",
"results": [
{
"type": "video",
"id": "QhD015WUMxE",
"url": "https://www.youtube.com/watch?v=QhD015WUMxE",
"title": "Beginners Guide To Web Scraping with Python - All You Need To Know",
"description": "The web is full of data. Lots and lots of data. Data prime for scraping. But manually going to a website and copying and pasting the ...",
"publishedAt": "2022-05-19T14:34:23.927Z",
"publishedAtPrecision": "estimated",
"durationSeconds": 456,
"viewCount": 491436,
"viewCountIsExact": true,
"isLive": false,
"thumbnailUrl": "https://i.ytimg.com/vi/QhD015WUMxE/hq720.jpg",
"position": 1,
"channel": {
"id": "UCZDA1kA3y3EIg25BpcHSpwQ",
"name": "Tinkernut",
"handle": "@Tinkernut",
"url": "https://www.youtube.com/@Tinkernut",
"isVerified": true
}
},
{
"type": "video",
"id": "hHQlcnubuFI",
"url": "https://www.youtube.com/watch?v=hHQlcnubuFI",
"title": "Learn Web Scraping in 5 Minutes (NO PRIOR KNOWLEDGE)",
"description": "Get Rid of IP Blocking for just $1 with DataImpulse: ...",
"publishedAt": "2026-03-04T12:19:23.927Z",
"publishedAtPrecision": "estimated",
"durationSeconds": 293,
"viewCount": 191388,
"viewCountIsExact": true,
"isLive": false,
"thumbnailUrl": "https://i.ytimg.com/vi/hHQlcnubuFI/hq720.jpg",
"position": 2,
"channel": {
"id": "UCFVteOob_YXJHPaGTqlDV2Q",
"name": "CodeHead",
"handle": "@codehead01",
"url": "https://www.youtube.com/@codehead01",
"isVerified": true
}
}
]
},
"credits": {
"used": 1,
"remaining": 99
}
}Good to know
- A search with no results answers 404 no_results and costs nothing.
Errors
Every error has the same shape, and none of them is charged. The full list is in the error reference.
Looking for an overview and use cases? See the YouTube Search API page.