Install
First, install the AIsa CLI if you have not already:What can agents do with it?
Content research
Find videos and channels around a topic.
Trend discovery
Identify what is gaining attention on YouTube.
Competitor tracking
Monitor channels and content formats in a niche.
Topic exploration
Gather video-first evidence for research workflows.
Quick Start
Base URL
Authentication
All requests require the AIsa API key in the Authorization header:AISA_API_KEY:
Getting Your API Key
- Sign in or create an account at AIsa Console
- Navigate to your Dashboard
- Copy your API key
API Reference
YouTube Search
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
engine | string | Yes | Must be youtube |
q | string | Yes | Search query (same syntax as YouTube search box) |
sp | string | No | YouTube filter token for pagination or advanced filters |
gl | string | No | Country code for localized results (e.g., us, jp, gb). Not all country codes are supported — see notes below |
hl | string | No | Interface language (e.g., en, zh, ja) |
Example: Basic Search
Example: Search with Country & Language
Example: Pagination with sp Token
Response
The API returns structured YouTube search results including video metadata, channel info, thumbnails, and pagination tokens. Note: The response structure may vary by query language. English queries typically return results in thevideos array. Some non-English queries may return results grouped in a sections array instead. Always check for both fields.
sections instead of a flat videos array:
Advanced Search Tips
YouTube’sq parameter supports the same search syntax as the YouTube search box:
| Search Syntax | Description | Example |
|---|---|---|
| Basic keywords | Standard search | q=python tutorial |
| Exact phrase | Quote for exact match | q="machine learning basics" |
| Channel filter | Search within a channel | q=channel:GoogleDevelopers python |
| Duration hint | Combine with keywords | q=python tutorial long |
Using the sp Filter Token
The sp parameter accepts YouTube’s encoded filter tokens. Common values:
| Filter | sp Value | Description |
|---|---|---|
| Videos only | EgIQAQ%3D%3D | Filter to video results only |
| Channels only | EgIQAg%3D%3D | Filter to channel results only |
| Playlists only | EgIQAw%3D%3D | Filter to playlist results only |
| Live now | EgJAAQ%3D%3D | Currently live streams |
| This week | EgIIAw%3D%3D | Uploaded this week |
| This month | EgIIBA%3D%3D | Uploaded this month |
| Short (<4 min) | EgIYAQ%3D%3D | Short duration videos |
| Long (>20 min) | EgIYAg%3D%3D | Long duration videos |
sp tokens from the next_page_token field in previous API responses for pagination.
Pagination
Use thenext_page_token from a response to fetch the next page of results:
Code Examples
JavaScript
Python
Python (urllib, no dependencies)
Note:urllibmay encounter 403 errors due to its default User-Agent. Usingrequests(above) is recommended. If you must useurllib, always set a custom User-Agent header.
Combining with Other AIsa APIs
One of the key advantages of AIsa is the unified API key. Use the sameAISA_API_KEY to combine YouTube search with other AIsa capabilities:
YouTube Search + LLM Summary
YouTube Search + Web Search
Notes
- All requests are pay-per-use through your AIsa balance — no separate YouTube API quota management
- The
engineparameter must always be set toyoutube - Video URLs follow the format
https://www.youtube.com/watch?v={videoId} - Channel URLs follow the format
https://www.youtube.com/channel/{channelId} - Use
next_page_tokenfrom previous responses as thespvalue for pagination - The
gl(country) parameter does not support all ISO country codes. Known unsupported values includecn(China). If you getUnsupported valueerrors, try omittingglor use a different country code - Non-English queries may return results in a
sectionsarray instead of a flatvideosarray — always handle both formats - IMPORTANT: Python
urllibmay return 403 errors due to its default User-Agent. Use therequestslibrary instead, or add a customUser-Agentheader - IMPORTANT: When using curl commands, ensure environment variables like
$AISA_API_KEYare properly expanded - IMPORTANT: When piping curl output to
jq, use-sflag and ensure the API key is set
Error Handling
| Status | Meaning |
|---|---|
| 200 | Successful search response |
| 400 | Invalid request parameters (missing engine or q) |
| 401 | Unauthorized — invalid or missing AIsa API key |
| 429 | Rate limited |
| 500 | Internal server error |
Troubleshooting: API Key Issues
- Check that the
AISA_API_KEYenvironment variable is set:
- Verify the API key works with a simple test:
Troubleshooting: No Results
- Verify your query is not empty
- Try a broader search term
- If using
gl, verify the country code is supported — not all ISO codes work (e.g.,cnis unsupported). Try omittingglto test - Ensure
engine=youtubeis included in every request - Check if results are in
sectionsinstead ofvideos(common for non-English queries)
Resources
- AIsa API Documentation
- AIsa Console
- YouTube Search API Reference
- AIsa Smart Search API
- AIsa Chat Completions API
- ClawHub Skills
Get started
- Sign up at aisa.one (new accounts start with $2 free credit).
- Generate an API key from the console.
- Set your key and install the skill:
- Start a new agent session so the runtime loads the updated skill instructions.
Related
YouTube SERP
Existing SERP-oriented YouTube skill.
AIsa YouTube Search
AIsa-branded YouTube search workflow.
YouTube Search endpoint
Endpoint reference for YouTube search.