Quick Start
Get started with the CleanScript API in just a few minutes.
Step 1: Get an API Key
To use the CleanScript API, you need an API key. You can create one in your dashboard.
Step 2: Make Your First API Call
Use the following code examples to make your first API call. Replace "YOUR_API_KEY" with the key you generated.
Important
Your API key is secret and should not be exposed in client-side code. For production applications, make API calls from your server.
Get Transcript Example
1// Using fetch
2const apiKey = 'YOUR_API_KEY'; // Replace with your API key
3const videoId = 'dQw4w9WgXcQ';
4
5async function getTranscript() {
6 try {
7 const response = await fetch(
8 `https://api.cleanscript.ai/v1/transcript?videoId=${videoId}`,
9 {
10 method: 'GET',
11 headers: {
12 'Authorization': `Bearer ${apiKey}`,
13 'Accept': 'application/json',
14 },
15 }
16 );
17
18 if (!response.ok) {
19 const errorData = await response.json();
20 throw new Error(errorData.detail || 'API request failed');
21 }
22
23 const data = await response.json();
24 console.log('Transcript data:', data);
25 return data;
26 } catch (error) {
27 console.error('Error fetching transcript:', error);
28 throw error;
29 }
30}
31
32// Call the function
33getTranscript()
34 .then(data => {
35 // Process the transcript data
36 const video = data[0];
37 const transcript = video.chapters[0].subtitles.map(sub => sub.text).join("\n");
38 console.log('Video title:', video.title);
39 console.log('Full transcript:', transcript);
40 })
41 .catch(error => {
42 console.error('Failed to get transcript:', error);
43 });
Step 3: Understanding the Response
The API returns an array of video information objects, each containing:
- title: The title of the video
- description: The video description
- channel: The YouTube channel name
- duration: Video duration in seconds
- totalTokenLength: Total tokens in the transcript (GPT-4 tokenizer)
- chapters: Array of chapters, each containing:
- title: Chapter title
- startTime/endTime: Timestamps in seconds
- transcript: The full transcript text
- subtitles: Array of individual subtitle entries with timestamps
- tokenLength: Tokens in this chapter
What's Next?
Explore these resources for more information:
- API Reference: Complete documentation for all API endpoints
- Error Handling: Learn how to handle API errors properly
- Integration Examples: See examples of integrating with LangChain, LlamaIndex, and more
Rate Limits and Quotas
Your API requests are subject to rate limits and quotas based on your plan. Check your usage dashboard to view your current limits and consumption.