Skip to main content

Error Response Format

All errors follow a consistent structure:
{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error description",
    "details": {
      // Optional additional context
    }
  }
}

HTTP Status Codes

Status CodeMeaningWhen It Occurs
200SuccessRequest completed successfully
202AcceptedAsync job created, use job ID to poll status
400Bad RequestInvalid input or parameters
401UnauthorizedMissing or invalid API key
403ForbiddenAPI key lacks required permissions
404Not FoundResource doesn’t exist
408Request TimeoutOperation took too long
429Too Many RequestsRate limit or quota exceeded
500Internal Server ErrorServer-side error occurred

Error Codes Reference

Authentication Errors (401)

Error CodeMessageSolution
UNAUTHORIZEDRequest lacks authenticationInclude X-API-Key header
INVALID_API_KEYInvalid or inactive API keyCheck your API key is correct and active
API_KEY_INACTIVEAPI key has been deactivatedCreate a new API key
Example:
{
  "success": false,
  "error": {
    "code": "INVALID_API_KEY",
    "message": "Invalid or inactive API key"
  }
}

Authorization Errors (403)

Error CodeMessageSolution
FORBIDDENInsufficient permissionsUpgrade your plan or contact support

Validation Errors (400)

Error CodeMessageSolution
INVALID_INPUTValidation failedCheck request parameters match schema
INVALID_VIDEO_IDInvalid YouTube video ID or URLVerify the video ID is correct
MISSING_PARAMETERRequired parameter is missingInclude all required parameters
INVALID_URLInvalid URL providedEnsure URL is well-formed
CRAWL_LIMIT_EXCEEDEDCrawl limit too highReduce limit to max 1000 pages
Example:
{
  "success": false,
  "error": {
    "code": "INVALID_INPUT",
    "message": "Validation failed",
    "details": {
      "issues": [
        {
          "path": "format",
          "message": "Invalid format. Expected: json, text, srt, or vtt"
        }
      ]
    }
  }
}

Resource Errors (404)

Error CodeMessageSolution
NOT_FOUNDResource not foundVerify the resource ID exists
KEY_NOT_FOUNDAPI key not foundCheck the API key is valid
CHANNEL_NOT_FOUNDYouTube channel not foundVerify the channel ID
PLAYLIST_NOT_FOUNDYouTube playlist not foundVerify the playlist ID
TRANSCRIPT_UNAVAILABLEVideo transcript not availableTry a different video or check if captions exist
JOB_NOT_FOUNDJob ID not foundVerify the job ID is correct
WEBHOOK_NOT_FOUNDWebhook not foundCheck the webhook ID

Rate Limiting Errors (429)

Error CodeMessageSolution
RATE_LIMIT_EXCEEDEDToo many requestsWait for rate limit to reset (check X-RateLimit-Reset header)
QUOTA_EXCEEDEDMonthly quota exhaustedWait for quota reset or enable auto-recharge
Example:
{
  "success": false,
  "error": {
    "code": "QUOTA_EXCEEDED",
    "message": "Monthly quota exhausted. Enable auto-recharge or upgrade your plan.",
    "details": {
      "limit": 1000,
      "remaining": 0
    }
  }
}

YouTube Specific Errors

Error CodeStatusMessageSolution
TRANSCRIPT_UNAVAILABLE404Video transcript not availableVideo may not have captions
LANGUAGE_NOT_SUPPORTED400Language not supportedTry ‘en’ or check available languages
CHANNEL_NOT_FOUND404YouTube channel not foundVerify channel ID is correct
PLAYLIST_NOT_FOUND404YouTube playlist not foundVerify playlist ID is correct

Scraping Errors

Error CodeStatusMessageSolution
SCRAPING_FAILED500Failed to scrape URLURL may be inaccessible or blocked
INVALID_URL400Invalid URL providedCheck URL format
CRAWL_TIMEOUT408Crawl operation timed outReduce crawl limit or retry
CRAWL_LIMIT_EXCEEDED400Crawl limit too highMaximum 1000 pages per crawl

Job Errors

Error CodeStatusMessageSolution
JOB_NOT_FOUND404Job ID not foundVerify job ID is correct
JOB_FAILED500Job processing failedCheck job details for specific error
JOB_TIMEOUT408Job timed outRetry with smaller batch

Server Errors (500)

Error CodeMessageSolution
INTERNAL_ERRORInternal server errorRetry request, contact support if persists
DATABASE_ERRORDatabase operation failedRetry request
EXTERNAL_SERVICE_ERRORExternal service unavailableRetry request, check status page

Handling Errors in Your Code

TypeScript/JavaScript

try {
  const response = await fetch('https://api.scriptbase.app/api/v1/videos/invalid_id', {
    headers: { 'X-API-Key': 'sk_your_key' }
  });

  const data = await response.json();

  if (!data.success) {
    switch (data.error.code) {
      case 'INVALID_VIDEO_ID':
        console.error('Invalid video ID provided');
        break;
      case 'QUOTA_EXCEEDED':
        console.error('Quota exceeded. Waiting for reset...');
        break;
      case 'RATE_LIMIT_EXCEEDED':
        const retryAfter = response.headers.get('Retry-After');
        console.error(`Rate limited. Retry after ${retryAfter} seconds`);
        break;
      default:
        console.error(`Error: ${data.error.message}`);
    }
  }
} catch (error) {
  console.error('Network error:', error);
}

Python

import requests
import time

def fetch_video(video_id, api_key):
    response = requests.get(
        f'https://api.scriptbase.app/api/v1/videos/{video_id}',
        headers={'X-API-Key': api_key}
    )
    
    data = response.json()
    
    if not data.get('success'):
        error = data['error']
        
        if error['code'] == 'RATE_LIMIT_EXCEEDED':
            retry_after = int(response.headers.get('Retry-After', 60))
            print(f'Rate limited. Waiting {retry_after} seconds...')
            time.sleep(retry_after)
            return fetch_video(video_id, api_key)  # Retry
        
        elif error['code'] == 'QUOTA_EXCEEDED':
            raise Exception('Monthly quota exceeded')
        
        else:
            raise Exception(f"API Error: {error['message']}")
    
    return data['data']

Go

package main

import (
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "time"
)

type ErrorResponse struct {
    Success bool `json:"success"`
    Error   struct {
        Code    string                 `json:"code"`
        Message string                 `json:"message"`
        Details map[string]interface{} `json:"details,omitempty"`
    } `json:"error"`
}

func fetchVideo(videoID, apiKey string) error {
    req, _ := http.NewRequest(
        "GET",
        fmt.Sprintf("https://api.scriptbase.app/api/v1/videos/%s", videoID),
        nil,
    )
    req.Header.Set("X-API-Key", apiKey)

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        return err
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)

    var errorResp ErrorResponse
    if err := json.Unmarshal(body, &errorResp); err == nil && !errorResp.Success {
        switch errorResp.Error.Code {
        case "RATE_LIMIT_EXCEEDED":
            retryAfter := resp.Header.Get("Retry-After")
            fmt.Printf("Rate limited. Retry after %s seconds\n", retryAfter)
            return fmt.Errorf("rate limit exceeded")
        case "QUOTA_EXCEEDED":
            return fmt.Errorf("quota exceeded")
        default:
            return fmt.Errorf("API error: %s", errorResp.Error.Message)
        }
    }

    return nil
}

Response Headers for Debugging

When handling errors, check these headers for additional context:
HeaderDescriptionExample
X-RateLimit-RemainingRequests remaining this period45
X-RateLimit-ResetUnix timestamp when limit resets1704326400
Retry-AfterSeconds to wait before retrying60
X-Credits-RemainingCredits remaining in quota850

Common Error Scenarios

Problem: You’ve exhausted your monthly quota before the reset date.Solutions:
  • Enable auto-recharge in dashboard
  • Upgrade to a higher tier
  • Wait for monthly reset
  • Optimize your requests to use fewer credits
Problem: Too many requests in a short time period.Solutions:
  • Implement exponential backoff
  • Respect the Retry-After header
  • Batch your requests when possible
  • Upgrade to a higher tier with higher rate limits
Problem: Video doesn’t have transcripts/captions.Solutions:
  • Check if the video has captions on YouTube
  • Try different language codes
  • Handle this gracefully in your application
Problem: The video ID format is incorrect or video doesn’t exist.Solutions:
  • Verify the video ID is 11 characters
  • Ensure the video exists on YouTube
  • Check for typos in the ID

Need Help?

If you’re experiencing errors that aren’t covered here:
  1. Check the status page for ongoing incidents
  2. Review your implementation against the API Reference
  3. Contact support with the error code and request ID