# YouTube API - Videos, Transcripts, Search, Channels & Comments (`socialscrapers/youtube-api`) Actor

YouTube API for real-time data: get video details, transcripts in any available language, search results, channel details and videos, comments and playlists as clean JSON in about 1-3 seconds per call. No YouTube API key, quota or login. Cursor paging, and you pay only for calls that return data.

- **URL**: https://apify.com/socialscrapers/youtube-api.md
- **Developed by:** [Social Scrapers](https://apify.com/socialscrapers) (community)
- **Categories:** Social media, Developer tools
- **Features:** Limited permissions, Multi-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.16 / 1,000 transcripts

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/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**YouTube API** is a real-time API for public YouTube data, with no YouTube account, login or API key, and no quota. Send an HTTP request, get JSON back in seconds: video details, transcripts in any language a video has, search results with filters, channels, a channel's videos, Shorts and live streams, comments and playlists. One page per call, with a cursor for the next page. You pay only for calls that return data.

> 💡 **Need a feature that isn't here? Just ask.** Open an issue on the **Issues** tab and tell us what you need: a new field, filter, input type or output format. We build requested features fast, usually within 24 hours, at no extra cost.

> ⭐ **Found it useful?** A short review on the **Reviews** tab helps other people find this API, and tells us what to build next.

### What does YouTube API do?

YouTube API answers each request with what YouTube shows a visitor who is not logged in, as clean JSON:

- 🎬 **Video details**: title, description, exact publish time, length, views, likes, the exact comment count, tags, hashtags, category, chapters, links in the description, thumbnail, live status, and the channel with its subscribers and verified badge. Works for videos, Shorts and live streams.
- 📝 **Transcripts**: the full text of a video's captions, optionally with the timed lines, in any language the video has captions in (made by a person, or YouTube's automatic ones), plus the list of every language available.
- 🔎 **Search**: YouTube's results page by page, with filters for result type (videos, Shorts, channels, live, movies), upload date, duration, order and features (4K, HD, subtitles, Creative Commons and more).
- 📺 **Channels**: subscribers, video count, total views, join date, country, the links on the About page, keywords, avatar and banner.
- 🗂️ **A channel's videos**: the Videos, Shorts or Live tab, newest first, most popular or oldest, with views, length and age.
- 💬 **Comments**: top or newest comments page by page, with likes, reply counts, the author and pinned or hearted flags.
- 📃 **Playlists**: every video of a public playlist in order, with its title, owner and counts.
- 💸 **Pay per successful call**: errors, empty pages, and videos without captions or that are missing or private cost nothing.

It is a server: no run to start and no dataset to fetch. Call it from any language, a no-code tool or your own backend, the same way you call any web API.

### Endpoints

| Endpoint | Parameters | Returns |
|---|---|---|
| `GET /v1/video` | `url` | A video with its details. |
| `GET /v1/transcript` | `url`, `lang`, `format` | One transcript of a video, with the languages it has. |
| `GET /v1/search` | `q`, `type`, `upload_date`, `duration`, `sort`, `features`, `cursor` | One page of search results (about 20 videos, plus Shorts and channels). |
| `GET /v1/channel` | `handle_or_url` | A channel with its details. |
| `GET /v1/channel-videos` | `handle_or_url`, `tab`, `sort`, `cursor` | One page of a channel's videos, Shorts or live streams (about 30). |
| `GET /v1/comments` | `url`, `sort`, `cursor` | One page of a video's comments (about 20). |
| `GET /v1/playlist` | `url`, `cursor` | One page of a playlist's videos (up to 100). |
| `GET /` | | What the API serves (free). |

- `url` takes a video link (`https://www.youtube.com/watch?v=_T8cn2J13-4`, a `youtu.be`, Shorts, live or embed link) or its 11-character id. For `/v1/playlist`, a playlist link or its id.
- `handle_or_url` takes an @handle (`@NASA`), a channel link (`https://www.youtube.com/@NASA`, `/channel/UC…`, `/c/…`, `/user/…`) or a channel id (`UC…`). A link to a channel's Shorts or Live tab picks that tab.
- `lang` is a language code such as `en`, `es`, `pt-BR` or `zh-Hans`. Without it you get the video's default captions, usually its spoken language. A video without captions in the language you ask for returns its default ones; the `language` field says which you got.
- `format` is `text` (the full text, the default) or `segments` (the full text plus each timed line).
- Search filters: `type` = `all`, `video`, `shorts`, `channel`, `live` or `movie`; `upload_date` = `any`, `hour`, `today`, `week`, `month` or `year`; `duration` = `any`, `short` (under 4 minutes), `medium` (4 to 20) or `long` (over 20); `sort` = `relevance` or `popularity`; `features` = a comma list of `live`, `4k`, `hd`, `subtitles`, `creative_commons`, `360`, `vr180`, `3d`, `hdr`, `location`, `purchased`. A YouTube search link works too, filters included.
- `tab` = `videos`, `shorts` or `streams`; its `sort` = `newest`, `popular` or `oldest`. Comments' `sort` = `top` or `newest`.
- `cursor` is the `next_cursor` of the previous page. A later page needs the cursor alone.

The **Server** tab of this page lists every endpoint with its fields and lets you try them in the browser.

### How to use YouTube API

1. Copy your API token from **Settings → API & Integrations** in Apify Console.
2. Send a GET request to the API with the token in the `Authorization` header:

```bash
curl -H "Authorization: Bearer <YOUR_APIFY_TOKEN>" \
  "https://socialscrapers--youtube-api.apify.actor/v1/video?url=https://www.youtube.com/watch?v=_T8cn2J13-4"
```

More examples:

```bash
## A transcript, in Spanish if the video has Spanish captions, with timed lines
curl -H "Authorization: Bearer <YOUR_APIFY_TOKEN>" \
  "https://socialscrapers--youtube-api.apify.actor/v1/transcript?url=_T8cn2J13-4&lang=es&format=segments"

## Search this week's long videos, then the next page
curl -H "Authorization: Bearer <YOUR_APIFY_TOKEN>" \
  "https://socialscrapers--youtube-api.apify.actor/v1/search?q=drone+footage&upload_date=week&duration=long"
curl -H "Authorization: Bearer <YOUR_APIFY_TOKEN>" \
  "https://socialscrapers--youtube-api.apify.actor/v1/search?cursor=<next_cursor>"

## A channel, and its most popular Shorts
curl -H "Authorization: Bearer <YOUR_APIFY_TOKEN>" \
  "https://socialscrapers--youtube-api.apify.actor/v1/channel?handle_or_url=@NASA"
curl -H "Authorization: Bearer <YOUR_APIFY_TOKEN>" \
  "https://socialscrapers--youtube-api.apify.actor/v1/channel-videos?handle_or_url=@NASA&tab=shorts&sort=popular"

## The newest comments of a video
curl -H "Authorization: Bearer <YOUR_APIFY_TOKEN>" \
  "https://socialscrapers--youtube-api.apify.actor/v1/comments?url=_T8cn2J13-4&sort=newest"

## A playlist
curl -H "Authorization: Bearer <YOUR_APIFY_TOKEN>" \
  "https://socialscrapers--youtube-api.apify.actor/v1/playlist?url=https://www.youtube.com/playlist?list=PL2aBZuCeDwlQvNtHhNJtarm9OewQwVntv"
```

In JavaScript:

```js
const res = await fetch('https://socialscrapers--youtube-api.apify.actor/v1/transcript?url=_T8cn2J13-4', {
  headers: { Authorization: `Bearer ${process.env.APIFY_TOKEN}` },
});
const { ok, data, error } = await res.json();
```

In Python:

```python
import requests

r = requests.get(
    "https://socialscrapers--youtube-api.apify.actor/v1/search",
    params={"q": "drone footage", "type": "video"},
    headers={"Authorization": f"Bearer {APIFY_TOKEN}"},
)
body = r.json()
```

You can also start the Actor from its **Input** tab: it then makes one call and saves the result to a dataset, which you can export as JSON, CSV or Excel. The next page's cursor is in the run's `OUTPUT` record.

### Responses

Every answer has the same envelope. A transcript:

```json
{
  "ok": true,
  "data": {
    "videoId": "_T8cn2J13-4",
    "url": "https://www.youtube.com/watch?v=_T8cn2J13-4",
    "title": "How We Are Going to the Moon - 4K",
    "channelName": "NASA",
    "durationSeconds": 331,
    "language": "en",
    "languageName": "English",
    "isAutoGenerated": false,
    "wordCount": 873,
    "availableLanguages": [
      { "language": "en", "languageName": "English", "isAutoGenerated": false },
      { "language": "en", "languageName": "English", "isAutoGenerated": true }
    ],
    "fullText": "Between 1968 and 1972, America launched 9 human missions to the Moon, 6 of which successfully touched down…",
    "segments": [
      { "start": 1.31, "duration": 7.39, "text": "Between 1968 and 1972, America launched 9 human missions to the Moon, 6 of which successfully" }
    ]
  },
  "next_cursor": null
}
```

A page of search results:

```json
{
  "ok": true,
  "data": {
    "query": "nasa artemis",
    "estimatedResults": 3510030,
    "items": [
      {
        "type": "video",
        "id": "_T8cn2J13-4",
        "url": "https://www.youtube.com/watch?v=_T8cn2J13-4",
        "title": "How We Are Going to the Moon - 4K",
        "durationSeconds": 331,
        "viewCount": 11863614,
        "publishedTimeText": "6 years ago",
        "thumbnail": "https://i.ytimg.com/vi/_T8cn2J13-4/hq720.jpg",
        "channelName": "NASA",
        "channelHandle": "@NASA",
        "badges": ["4K", "CC"],
        "position": 1
      }
    ]
  },
  "next_cursor": "eyJrIjoic2VhcmNoIiwicSI6Im5hc2EgYXJ0ZW1pcyIs..."
}
```

A failure:

```json
{ "ok": false, "error": { "code": "no_transcript", "message": "Video abcDEF12345 has no transcript: The video has no captions." } }
```

| Status | `error.code` | Meaning | Charged |
|---|---|---|---|
| 200 | | Data, or an empty page | Only when it returns data |
| 400 | `invalid_request`, `invalid_cursor` | A parameter is missing or cannot be read, or the cursor has expired | No |
| 404 | `not_found`, `private`, `no_transcript` | No such video, channel or playlist; a private, members-only or age-restricted video; a video without captions | No |
| 429 | `over_capacity` | Too many calls at once: retry after the `Retry-After` seconds | No |
| 502 | `youtube_refused`, `upstream_timeout` | YouTube did not answer in time: retry | No |
| 500 | `internal_error` | Something went wrong on our side | No |

Each call is answered within about 45 seconds; most take one to three seconds. The first call after a quiet spell can take a few seconds more.

### How much does YouTube API cost?

You pay per successful call that returns data. Errors, empty pages, and videos, channels or playlists that are missing, private or without captions are free. A transcript covers its video's first hour; a longer video also counts each started minute past it.

| Call | Price per 1,000 calls |
|---|---|
| Video details (`/v1/video`) | $1.20 |
| Transcript (`/v1/transcript`) | $1.45 |
| Each started minute of a transcript's video past its first hour | $0.02 |
| Page of search results (`/v1/search`) | $2.00 |
| Channel details (`/v1/channel`) | $1.00 |
| Page of a channel's videos (`/v1/channel-videos`) | $2.00 |
| Page of comments (`/v1/comments`) | $2.00 |
| Page of a playlist (`/v1/playlist`) | $2.00 |

Apify's Silver and Gold plans pay less per call. There is no run to start, so there is no start fee and no compute cost on your side.

### FAQ

**Do I need a YouTube account or a YouTube API key?** No. Everything comes from what YouTube shows a visitor who is not logged in, and there is no daily quota to manage.

**Which transcript do I get without `lang`?** The video's default captions, the ones YouTube picks for it, usually in its spoken language. `availableLanguages` lists every language the video has, so you can ask for another one in a second call.

**Are auto-generated captions included?** Yes. When a video has captions made by a person in your language you get those; otherwise YouTube's automatic captions in that language. `isAutoGenerated` says which.

**How are long videos priced?** A transcript covers the video's first hour. Each started minute past it is one extra-minute event, charged with the transcript: a 2-hour podcast is one transcript plus 60 extra minutes.

**Can it read private or members-only videos?** No. Only public data that anyone can see without logging in. Such a video answers with `404` and code `private`, and is not charged.

**How do I get more than one page?** Pass the `next_cursor` of a page as `cursor` in the next call, until `next_cursor` is `null`.

**Why are some view counts rounded?** A channel tab and a playlist show views as YouTube shows them there (1.2M). Search results and `/v1/video` give exact counts.

**What happens when I send many calls at once?** Calls are shared fairly between users. When too many arrive at once you get `429` with a `Retry-After` header; wait that many seconds and retry.

**Is it legal to use this data?** The API reads only public data. You are responsible for using it lawfully: comments and channel pages can hold personal data, which laws such as the GDPR and the CCPA protect, so collect and keep only what you have a legitimate reason to process.

### Other scrapers by Social Scrapers

| Scraper | What it gets |
| --- | --- |
| [TikTok API](https://apify.com/socialscrapers/tiktok-api) | Profiles, Videos and Comments |
| [TikTok Comments Scraper](https://apify.com/socialscrapers/tiktok-comments-scraper) | Comments, Replies and Likes |
| [TikTok Hashtag Scraper](https://apify.com/socialscrapers/tiktok-hashtag-scraper) | Top Videos, Views and Likes |
| [TikTok Profile Scraper](https://apify.com/socialscrapers/tiktok-profile-scraper) | Followers, Bio, Stats and Videos |
| [TikTok Scraper](https://apify.com/socialscrapers/tiktok-scraper) | Videos, Profiles, Hashtags and Comments |
| [TikTok Sound Scraper](https://apify.com/socialscrapers/tiktok-sound-scraper) | Videos Using a Sound and Music Info |
| [TikTok Video Scraper](https://apify.com/socialscrapers/tiktok-video-scraper) | Views, Likes, Captions and Comments |
| [Instagram API](https://apify.com/socialscrapers/instagram-api) | Profiles, Posts, Reels, Comments and Hashtags |
| [Instagram Comments Scraper](https://apify.com/socialscrapers/instagram-comments-scraper) | Comments, Likes and Reply Counts |
| [Instagram Hashtag Scraper](https://apify.com/socialscrapers/instagram-hashtag-scraper) | Reels and Keyword Search |
| [Instagram Post Details Scraper](https://apify.com/socialscrapers/instagram-post-details-scraper) | Likes, Comments, Views and Media |
| [Instagram Post Scraper](https://apify.com/socialscrapers/instagram-post-scraper) | Posts, Reels and Comments |
| [Instagram Profile Scraper](https://apify.com/socialscrapers/instagram-profile-scraper) | Followers, Bio, Posts and Reels |
| [Instagram Reels Scraper](https://apify.com/socialscrapers/instagram-reels-scraper) | Reels, Plays, Likes and Comments |
| [Instagram Reels Transcript Scraper](https://apify.com/socialscrapers/instagram-reels-transcript-scraper) | Speech to Text and Captions |
| [Instagram Scraper](https://apify.com/socialscrapers/instagram-scraper) | Posts, Profiles, Reels, Comments and Hashtags |
| [YouTube Channel Scraper](https://apify.com/socialscrapers/youtube-channel-scraper) | Videos, Shorts, Subscribers and About |
| [YouTube Comments Scraper](https://apify.com/socialscrapers/youtube-comments-scraper) | Comments, Replies and Likes |
| [YouTube Scraper](https://apify.com/socialscrapers/youtube-scraper) | Videos, Shorts, Channels and Comments |
| [YouTube Search Scraper](https://apify.com/socialscrapers/youtube-search-scraper) | Videos, Channels, Views and Filters |
| [YouTube Shorts Scraper](https://apify.com/socialscrapers/youtube-shorts-scraper) | Shorts, Views, Likes and Search |
| [YouTube Transcript Scraper](https://apify.com/socialscrapers/youtube-transcript-scraper) | Subtitles, Captions and SRT |
| [YouTube Video Details Scraper](https://apify.com/socialscrapers/youtube-video-details-scraper) | Stats, Subtitles and Comments |
| [Facebook Ads Library Scraper](https://apify.com/socialscrapers/facebook-ads-library-scraper) | Meta Ad Library and Spend |
| [Facebook Comments Scraper](https://apify.com/socialscrapers/facebook-comments-scraper) | Posts, Reels, Videos and Replies |
| [Facebook Groups Scraper](https://apify.com/socialscrapers/facebook-groups-scraper) | Public Group Posts and Reactions |
| [Facebook Marketplace Scraper](https://apify.com/socialscrapers/facebook-marketplace-scraper) | Prices, Locations and Sellers |
| [Facebook Page Contact Info Scraper](https://apify.com/socialscrapers/facebook-page-contact-scraper) | Email, Phone and WhatsApp |
| [Facebook Posts Scraper](https://apify.com/socialscrapers/facebook-profile-posts-scraper) | Pages, Profiles and Timelines |
| [Facebook Pages Scraper](https://apify.com/socialscrapers/facebook-profile-scraper) | Profiles, Contact Info and Reviews |
| [Facebook Reels Scraper](https://apify.com/socialscrapers/facebook-reels-scraper) | Reels, Videos, Plays and Captions |
| [X (Twitter) Profile Scraper](https://apify.com/socialscrapers/x-profile-scraper) | Followers, Bio and Tweets |
| [X (Twitter) Tweet Scraper](https://apify.com/socialscrapers/x-tweet-scraper) | Latest Posts by Profile |
| [Threads Profile Scraper](https://apify.com/socialscrapers/threads-profile-scraper) | Followers, Bio, Links and Posts |
| [Threads Replies Scraper](https://apify.com/socialscrapers/threads-replies-scraper) | Comments, Authors, Likes and Media |
| [Threads Scraper](https://apify.com/socialscrapers/threads-scraper) | Posts, Profiles, Replies and Search |
| [Threads Search Scraper](https://apify.com/socialscrapers/threads-search-scraper) | Keywords, Hashtags, Top and Recent Posts |
| [Reddit Comments Scraper](https://apify.com/socialscrapers/reddit-comments-scraper) | Threads, Replies, Votes and Authors |
| [Reddit Scraper](https://apify.com/socialscrapers/reddit-scraper) | Posts, Comments, Subreddits, Users and Search |
| [Reddit Search Scraper](https://apify.com/socialscrapers/reddit-search-scraper) | Posts by Keyword, Subreddit and Date |
| [Reddit User Scraper](https://apify.com/socialscrapers/reddit-user-scraper) | Profiles, Karma, Posts and Comments |
| [Subreddit Scraper](https://apify.com/socialscrapers/subreddit-scraper) | Hot, New and Top Posts with Comments |
| [Quora Scraper](https://apify.com/socialscrapers/quora-scraper) | Answers, Questions, Profiles and Topic Search |
| [LinkedIn Ad Library Scraper](https://apify.com/socialscrapers/linkedin-ad-library-scraper) | Ads, Advertisers and Impressions |
| [LinkedIn Job Search Scraper](https://apify.com/socialscrapers/linkedin-job-search-scraper) | Filters, Salaries and New Jobs |
| [LinkedIn Jobs Scraper](https://apify.com/socialscrapers/linkedin-jobs-scraper) | Job Listings, Salaries and Companies |
| [Google Maps Email Extractor](https://apify.com/socialscrapers/google-maps-email-extractor) | Emails, Phones and Social Links |
| [Google Maps Scraper](https://apify.com/socialscrapers/google-maps-scraper) | Places, Phones, Websites, Ratings and Hours |
| [Google News Scraper](https://apify.com/socialscrapers/google-news-scraper) | Headlines, Articles and Search |
| [Google Ads Transparency Scraper](https://apify.com/socialscrapers/google-ads-transparency-scraper) | Ad Creatives and Advertisers |
| [Amazon Product Scraper](https://apify.com/socialscrapers/amazon-product-scraper) | Search Results, Prices, Ratings, ASINs |
| [Indeed Jobs Scraper](https://apify.com/socialscrapers/indeed-jobs-scraper) | Salaries, Full Descriptions, Company Data |
| [Contact Details Scraper](https://apify.com/socialscrapers/contact-details-scraper) | Emails, Phones and Social Links |
| [Telegram Channel Scraper](https://apify.com/socialscrapers/telegram-channel-scraper) | Posts, Views and Media |
| [Doximity Scraper](https://apify.com/socialscrapers/doximity-physician-scraper) | Physician Profiles and Doctor Directory |
| [KevinMD Scraper](https://apify.com/socialscrapers/kevinmd-articles-scraper) | Physician Articles and Author Specialties |
| [Op-Med Scraper](https://apify.com/socialscrapers/opmed-articles-scraper) | Physician Essays and Doctor Profiles |
| [Career Site Jobs Scraper](https://apify.com/socialscrapers/career-site-jobs-scraper) | Greenhouse, Lever, Ashby and Workday |
| [Google Trends Scraper](https://apify.com/socialscrapers/google-trends-scraper) | Interest Over Time, Regions and Queries |

# Actor input Schema

## `endpoint` (type: `string`):

What to read: a video's details, a video's transcript, one page of search results, a channel's details, one page of a channel's videos, Shorts or streams, one page of a video's comments, or one page of a playlist.

## `url` (type: `string`):

For Video details, Transcript and Comments: a video link (watch, youtu.be, Shorts or live link) or its 11-character id. For Playlist: a playlist link or its id.

## `lang` (type: `string`):

For Transcript: a language code such as en, es or pt-BR. Leave empty for the video's default captions (usually its spoken language). A video without captions in that language returns its default ones.

## `format` (type: `string`):

For Transcript: the full text only, or the full text plus timed segments (start, duration and text of each line).

## `q` (type: `string`):

For Search: what to search for, such as drone footage, or a YouTube search link.

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

For Search: all results, or only videos, Shorts, channels, live streams or movies.

## `upload_date` (type: `string`):

For Search: only videos uploaded in the last hour, today, this week, this month or this year.

## `duration` (type: `string`):

For Search: only short videos (under 4 minutes), medium ones (4 to 20 minutes) or long ones (over 20 minutes).

## `sort` (type: `string`):

For Search: relevance (default) or popularity. For Channel videos: newest (default), popular or oldest. For Comments: top (default) or newest.

## `handle_or_url` (type: `string`):

For Channel details and Channel videos: an @handle (@NASA), a channel link, or a channel id (UC...).

## `tab` (type: `string`):

For Channel videos: the Videos, Shorts or Live tab.

## `cursor` (type: `string`):

Leave empty for the first page. For the next page, paste the next_cursor of the previous run's OUTPUT record (or of a previous API call).

## Actor input object example

```json
{
  "endpoint": "transcript",
  "url": "https://www.youtube.com/watch?v=_T8cn2J13-4",
  "format": "text",
  "type": "all",
  "upload_date": "any",
  "duration": "any",
  "tab": "videos"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `output` (type: `string`):

No description

# 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 = {
    "endpoint": "transcript",
    "url": "https://www.youtube.com/watch?v=_T8cn2J13-4"
};

// Run the Actor and wait for it to finish
const run = await client.actor("socialscrapers/youtube-api").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 = {
    "endpoint": "transcript",
    "url": "https://www.youtube.com/watch?v=_T8cn2J13-4",
}

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

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

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

```

## CLI example

```bash
echo '{
  "endpoint": "transcript",
  "url": "https://www.youtube.com/watch?v=_T8cn2J13-4"
}' |
apify call socialscrapers/youtube-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,socialscrapers/youtube-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/zQeJpsKCwA6PzScA1/builds/UpEDbVfDhjtqpG2TL/openapi.json
