Skip to content

SeanFengX/transcriptly-demo

Repository files navigation

YouTube Transcript API

A service API for retrieving YouTube video transcripts.

API Endpoint

Get Video Transcript

POST https://transcriptly.org/api/v1/transcript

Request Headers

Header Type Required Description
x-api-key string Yes API key

Request Parameters

Parameter Type Required Description
url string Yes YouTube video URL
language string No Language of the transcript to be returned, default is English

Request Example

{
  "url": "https://www.youtube.com/watch?v=your_video_id",
  "language": "en"
}

Response Format

Success Response (200 OK):

{
  "code": 200,
  "message": "Transcript generated successfully",
  "data": {
    "success": true,
		"data": [{
			"id": 1,
			"start": 0.12,
			"end": 2.159,
			"text": "this might sound crazy but the way to"
		}, {
			"id": 2,
			"start": 2.159,
			"end": 3.84,
			"text": "achieve what you want isn't what you"
		},
    {
      "id": 3,
      "start": 3.84,
      "end": 5.56,
      "text": "want isn't what you"
    },
    {
			"id": 176,
			"start": 395.56,
			"end": 397.919,
			"text": "video"
		}],
		"url": "https://www.youtube.com/watch?v=BJ2NvjS7Aio",
		"language": "en",
		"total": 176
  }
}

Error Response (HTTP status 400 Bad Request):

{
  "code": 400,
  "message": "Invalid request body"
}

Error Response (HTTP status 400 Bad Request):

{
  "code": 4001,
  "message": "Invalid YouTube URL"
}

Error Response (HTTP status 401 Unauthorized):

{
  "code": 401,
  "message": "Invalid API key"
}

Error Response (HTTP status 403 Forbidden):

{
  "code": 403,
  "message": "Insufficient credits"
}

Error Response (HTTP status 429 Too Many Requests):

{
  "code": 429,
  "message": "Access rate limit exceeded"
}

Error Response (HTTP status 500 Internal Server Error):

{
  "code": 5001,
  "message": "Transcript generated failed",
  "data": {
    "success": false,
    "data": [],
    "url": "https://www.youtube.com/watch?v=-FNIAzYLCQA",
    "language": "123",
    "total": 0,
    "error": "API request failed: 400"
  }
}

Local Development

  1. Clone the project and install dependencies:
npm install
# or
yarn install
  1. Configure environment variables: Create a .env.local file and add:
TRANSCRIPTLY_API_KEY=your_api_key_here
  1. Start the development server:
npm run dev
# or
yarn dev

The server will be running at http://localhost:3000.

Tech Stack

Important Notes

  • Ensure you provide a valid YouTube video URL
  • Keep your API key secure and never expose it publicly
  • Comply with YouTube's Terms of Service and usage policies

About

This is the sample code for YouTube Transcript service API from https://transcriptly.org

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published