Tutorial · Python
How to scrape YouTube search results with Python (2026)
A Python walkthrough for GET /v1/youtube/search. Copy the snippet, run it, then read the JSON.
GET /v1/youtube/search · 1 credit
In this tutorial
You'll search YouTube for a phrase and see the results you get back.
Typical job: a scheduled competitor check. Search a phrase, narrow it with uploadDate, type, duration or region, page through with cursor, then fetch transcripts or video details for the ones you keep. This is keyword search; for a hashtag, use /search/hashtags.
Step 1
Get ready
Create a Social Fetch API key and get Python ready. New accounts include 100 free credits.

API key. Create a Social Fetch account, open API Keys and create a key. New accounts include 100 free credits.
Python setup. Python 3 with requests installed (pip install requests). Set SOCIALFETCH_API_KEY to your key.
When you're done, SOCIALFETCH_API_KEY is set in your shell.
Step 2
Make the request
Copy the Python sample and run it. It calls GET /v1/youtube/search with your key in the x-api-key header, using this example: /v1/youtube/search?query=api+tutorial.
It prints the response as a Python dict with data and meta. An error status stops the script at raise_for_status() instead.
Step 3
Read the response
The response is JSON with two parts: data holds the search results and meta holds creditsCharged and requestId. The sample below is a trimmed copy of a real response; the endpoint page lists every field. Credits are charged on completed lookups, not on failed requests.

Check data.lookupStatus first when the response has one. Keep meta.requestId in case a row looks wrong.
Watch out
the duration filter applies to videos, not Shorts. Keep type, uploadDate, duration and sortBy the same while you page with cursor. Results arrive in separate lists (videos, shorts, channels, playlists), so read the ones you asked for.
Step 4
You finished
The Playground, the docs and your code all call the same endpoint at the same price. Pick a next step below.
FAQ
Common questions
Do I need an official YouTube developer account?
No. Social Fetch authenticates with your Social Fetch API key. You call GET /v1/youtube/search and we handle the lookup. You still need to follow each platform's terms for how you use public data.
What does the YouTube search endpoint return?
JSON with two parts: data holds the search results and meta holds creditsCharged and requestId. The endpoint page and the API docs describe every field.
Can I filter YouTube search by type, date, or duration?
Yes. type accepts videos, shorts, channels or playlists. uploadDate accepts today, this_week, this_month or this_year. duration accepts under_3_min, between_3_and_20_min or over_20_min (for videos, not Shorts). sortBy can be relevance or popular. Keep filters the same while you page.
YouTube keyword search vs hashtag search?
Use this route for keyword searches with type, date and duration filters. Use GET /v1/youtube/search/hashtags for a hashtag. They are separate calls, so a keyword search won't act like a hashtag search.
How much does a successful request cost?
1 credit. Failed requests are free.
Is this okay for production?
Yes. It's the same API the Playground and the docs use: typed errors, a requestId on every response, and credits charged only on completed lookups. New accounts get 100 free credits.
Any Python-specific tips for this request?
Yes. Call response.raise_for_status() before response.json(), set a timeout on requests.get, and keep response.json()["meta"]["requestId"] when a row looks wrong.
Related