# Youtube API Search By Category (`thescrappa/youtube-api-search-by-category`) Actor

Search for videos using a specific hashtag. Provide hashtag without #.

- **URL**: https://apify.com/thescrappa/youtube-api-search-by-category.md
- **Developed by:** [Scrappa](https://apify.com/thescrappa) (community)
- **Categories:** Social media, Developer tools
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.20 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## YouTube Search By Category Scraper

Get YouTube search results from predefined category searches such as education, music, gaming, news, sports, and technology. The Actor returns one dataset item per YouTube result, so you can export videos to JSON, CSV, Excel, or connect them to downstream Apify integrations.

### What You Can Get

- Category-based YouTube video results
- Titles, descriptions, thumbnails, video IDs, durations, view counts, and publish times
- Channel metadata including channel ID, name, URL, thumbnail, and verification status
- Badges such as `CC`, `New`, `4K`, or other labels returned by YouTube
- Live, Shorts, and Premium flags when available
- Continuation tokens in logs when another page is available

### Input

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `category` | array | Yes | Category to search in. Examples: `education`, `music`, `gaming`, `news`, `sports`, `tech`. |
| `sort` | array | No | Sort order. One of `relevance`, `rating`, `upload_date`, or `view_count`. Defaults to `relevance`. |
| `duration` | array | No | Video duration filter. One of `short`, `medium`, or `long`. |
| `upload_date` | array | No | Upload date filter. One of `hour`, `today`, `week`, `month`, or `year`. |
| `limit` | integer | No | Maximum results to request, from `1` to `1024`. The upstream API can return a smaller page with a continuation token. |
| `continuation` | string | No | Continuation token for the next page of results. |
| `contentType` | array | No | Filter by content type: `live`, `recorded`, or `premiere`. |
| `features` | string | No | Comma-separated feature filters such as `hd,cc`. |

Apify select fields are arrays in JSON input. Use a single selected value in each array, for example `"category": ["education"]`.

### Example Inputs

#### Education Videos

```json
{
  "category": ["education"],
  "sort": ["relevance"],
  "duration": ["short"],
  "limit": 10
}
```

#### High-View Music Videos

```json
{
  "category": ["music"],
  "sort": ["view_count"],
  "limit": 20
}
```

#### Recent Tech Videos

```json
{
  "category": ["tech"],
  "sort": ["upload_date"],
  "upload_date": ["week"],
  "limit": 20
}
```

#### Continue to the Next Page

```json
{
  "category": ["education"],
  "sort": ["relevance"],
  "limit": 20,
  "continuation": "PASTE_CONTINUATION_TOKEN_FROM_PREVIOUS_RUN"
}
```

When the API returns a next-page token, the Actor logs it as `Continuation token available for next page: ...`.

### Output

Each result is saved as one dataset item. Fields vary by YouTube result, but video results commonly include:

```json
{
  "type": "Video",
  "id": "KVLTxKyxioA",
  "title": "The Science of Teaching, Effective Education, and Great Schools",
  "description": "Scientific evidence suggests that the secret to thriving students...",
  "thumbnail": "https://i.ytimg.com/vi/KVLTxKyxioA/hq720.jpg",
  "duration": "6:21",
  "viewCount": "824,846 views",
  "publishedTime": "8 years ago",
  "channel": {
    "id": "UC-RKpEc4eE9PwJaupN91xYQ",
    "name": "Sprouts",
    "thumbnail": "https://yt3.ggpht.com/...",
    "verified": true,
    "isVerifiedArtist": false,
    "url": "https://www.youtube.com/@sprouts"
  },
  "badges": ["CC"],
  "isLive": false,
  "isShort": false,
  "isPremium": false,
  "expandableMetadata": {
    "label": "Summary"
  }
}
```

### Pricing

$0.30 per 1,000 results. No additional API keys required.

### Support

For issues or questions, contact us through Apify.

# Actor input Schema

## `category` (type: `array`):

Category to search in

## `sort` (type: `array`):

Sort by: relevance, rating, upload\_date, view\_count

## `duration` (type: `array`):

Video duration: short, medium, long

## `upload_date` (type: `array`):

Upload date filter

## `limit` (type: `integer`):

Maximum number of results to request. The upstream API can return a smaller page with a continuation token.

## `continuation` (type: `string`):

Pagination token for next page

## `contentType` (type: `array`):

Filter by content type

## `features` (type: `string`):

Comma-separated: live,4k,hd,subtitles,cc,360,vr180,3d,hdr

## Actor input object example

```json
{
  "category": [
    "education"
  ],
  "sort": [
    "relevance"
  ],
  "duration": [
    "short"
  ],
  "upload_date": [
    "hour"
  ],
  "limit": 10
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "category": [
        "education"
    ],
    "sort": [
        "relevance"
    ],
    "duration": [
        "short"
    ],
    "upload_date": [
        "hour"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("thescrappa/youtube-api-search-by-category").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "category": ["education"],
    "sort": ["relevance"],
    "duration": ["short"],
    "upload_date": ["hour"],
}

# Run the Actor and wait for it to finish
run = client.actor("thescrappa/youtube-api-search-by-category").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "category": [
    "education"
  ],
  "sort": [
    "relevance"
  ],
  "duration": [
    "short"
  ],
  "upload_date": [
    "hour"
  ]
}' |
apify call thescrappa/youtube-api-search-by-category --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=thescrappa/youtube-api-search-by-category",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/O1ltDU9qk4adR2x86/builds/2na6gjQJxcPeNwK82/openapi.json
