Video Search API in Python: Fetch Video Results as JSON
The fastest way to get video search data into a Python project is a single HTTP request with an API key. No SDK to install, no video files to touch — the /api/videos endpoint returns the video results as JSON, and Python’s requests library turns that JSON into a list of dicts you can iterate immediately.
This tutorial walks through the whole thing with working code: authenticating with the X-API-Key header, fetching results with requests, iterating the videos array, and parsing the fields you actually care about — title, URL, thumbnail, and duration. It also covers the honest engine support list so you know exactly what each parameter does.
TL;DR: Authenticate with headers={"X-API-Key": "YOUR_API_KEY"}, call GET /api/videos?q=QUERY&engine=ddg, and iterate data["videos"] for title, url, thumbnailUrl, duration, source, and views. Engines: google, ddg (default), yahoo, bing, brave.
Setup: key and endpoint
You need two things: an API key and the endpoint. The key goes in an X-API-Key header on every request. The endpoint is https://apiserpent.com/api/videos, and the query string carries the search parameters — q for the query, engine to pick the video index, country for localization, and num for the result count.
Install the HTTP library if you have not already:
pip install requests
Your first Python call
Here is a complete, runnable example:
import requests
resp = requests.get(
"https://apiserpent.com/api/videos",
headers={"X-API-Key": "YOUR_API_KEY"},
params={
"q": "machine learning tutorial",
"engine": "ddg",
"country": "us",
"num": 20,
},
)
data = resp.json()
for video in data["videos"]:
print(video["title"], video["duration"], video["url"])
That is the entire integration. If resp.status_code is 200, data is a dict and data["videos"] is a list. On the rare transient 429, treat it as automated overuse or server load and back off a moment before retrying — a tiny time.sleep in a retry loop is enough for most scripts.
Iterating over results
Each item in videos is a flat dict with the same keys regardless of engine:
| Key | Type | Meaning |
|---|---|---|
title | str | Video title |
url | str | Watch page |
thumbnailUrl | str | Preview image |
embedUrl | str | Embed-ready URL, when available |
duration | str | Runtime, e.g. 12:34 |
source | str | Platform, e.g. YouTube |
views | str | View count, when available |
Use video.get("views") rather than video["views"] because views are only present when the engine exposes them. The same defensive read is a good idea for embedUrl.
Reading the JSON response
The full response shape is:
{
"searchParameters": {
"q": "machine learning tutorial",
"engine": "ddg",
"type": "videos",
"num": 20
},
"videos": [
{
"title": "Machine Learning Full Course for Beginners",
"url": "https://www.youtube.com/watch?v=example123",
"thumbnailUrl": "https://i.ytimg.com/vi/example123/hqdefault.jpg",
"embedUrl": "https://www.youtube.com/embed/example123",
"duration": "3:42:15",
"source": "YouTube",
"views": "2.4M views"
}
],
"totalResults": 20,
"credits": { "used": 1, "remaining": 99 }
}
searchParameters echoes what you sent — useful for logging. totalResults is the count you requested (or the engine’s ceiling, up to 60). credits tells you the cost of the call and your remaining balance. For a Node.js equivalent, the same request is one fetch away:
const res = await fetch(
'https://apiserpent.com/api/videos?q=machine+learning+tutorial&engine=ddg&country=us&num=20',
{ headers: { 'X-API-Key': 'YOUR_API_KEY' } }
);
const json = await res.json();
for (const v of json.videos) {
console.log(v.title, v.duration, v.thumbnailUrl);
}
Filters: duration, freshness, resolution
The endpoint accepts filters that narrow results before they reach your script:
num— results per request, up to 60.freshness—1d,7d, or30dto limit to recently published video.duration—short,medium, orlong.resolution—highorstandard(primarily DuckDuckGo).country— one of 112 ISO country codes.
For a "latest tutorials" script, combine them: freshness=7d&duration=medium&num=60 returns the recent mid-length videos ranking for your query.
Engine support
Video search is not a single index, and the endpoint gives you a choice. The honest list:
| Engine | Default? | Notes |
|---|---|---|
google | No | Google video results, including YouTube and web videos |
ddg | Yes | DuckDuckGo video search, with resolution data |
yahoo | No | Yahoo’s dedicated video search portal |
bing | No | Bing video results |
brave | No | Brave video results |
All engines return the same JSON shape and share the same price within each tier, so switching is a one-parameter change in the params dict.
Next steps
From here, the natural step is a monitoring script: run the fetch for a list of keywords on a schedule, store the videos arrays keyed by (query, country, date), and diff snapshots to catch new entrants and position changes. For volume, swap requests for httpx and reuse an async client across keywords — the API contract is identical. Test queries live in the playground or read the Video Search API reference for the full parameter list.
Video results, in your Python process.
Serpent returns parsed JSON for video results across Google, DuckDuckGo, Yahoo, Bing, and Brave through one endpoint. Flat per-call pricing, no subscription. Video search requires paid credits from call 1.
Get Your Free API KeyExplore: Video Search API · Documentation · Pricing
FAQ
What does the video search API return in JSON?
A response has a searchParameters object, a videos array where each item carries title, url, thumbnailUrl, embedUrl, duration, source, and views (when available), plus totalResults and a credits block. DuckDuckGo also returns resolution data.
Which engines can I query for video search?
The /api/videos endpoint supports engine=google, engine=ddg (the default), engine=yahoo, engine=bing, and engine=brave. All engines share the same price within each tier and return the same JSON shape.
Is the Python example production-ready?
The requests example works as-is for scripts. For higher volume, switch to httpx with an async client or connection pooling, and handle transient HTTP 429 responses as automated overuse or server load by backing off and retrying with a small delay.
Does video search require paid credits?
Yes. Video search requires paid credits from call 1. It costs $0.30 per 1,000 requests on Default, $0.03 per 1,000 on Growth ($100+ deposit), and $0.02 per 1,000 on Scale ($500+ deposit), with no subscription.

