REST API

The Visolix Video Downloader plugin provides external REST API access for video downloading functionality when the REST API feature is enabled in the plugin settings. This documentation covers the conditional API endpoints that require REST API activation.

Base URL

All API endpoints are prefixed with:

/wp-json/visolix/api/

Prerequisites

To use these endpoints, you must:

  1. Enable REST API in plugin settings: WordPress Admin → Visolix Video Downloader → Settings → REST API

  2. Set an API key in the plugin settings

  3. Have an active plugin license

Authentication

All external API endpoints require API key authentication:

  • Parameter: key=your_api_key (required)

The API key can be configured in the plugin settings under "REST API Settings".

Endpoints

1. Get Video Data

Endpoint: POST /wp-json/visolix/api/video-data

Retrieves raw video metadata and available download options for a given URL. This endpoint provides structured data about videos without initiating the actual download process.

Parameters

Parameter
Type
Required
Description

url

string

Yes

The video URL to analyze (must be a valid URL)

format

string

Conditional

Required only for YouTube URLs. Specifies the desired format/quality. See format options below.

key

string

Yes

API key for authentication

Format Options (YouTube Only)

When the URL is from YouTube, you must specify a format parameter. Available options:

Audio Formats:

  • mp3 - MP3 audio

  • m4a - M4A audio

  • webm_audio - WebM audio

  • aac - AAC audio

  • flac - FLAC audio

  • opus - Opus audio

  • ogg - OGG audio

  • wav - WAV audio

Video Formats:

  • 360 - MP4 (360p)

  • 480 - MP4 (480p)

  • 720 - MP4 (720p) [Default]

  • 1080 - MP4 (1080p)

  • 1440 - MP4 (1440p)

  • 2160 - WebM (4K)

Request Example

curl -X POST https://your-site.com/wp-json/visolix/api/video-data \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.youtube.com/watch?v=videourl",
    "format": "720",
    "key": "your_api_key_here"
  }'

Note: The format parameter is required only for YouTube URLs. For other platforms (Instagram, Facebook, TikTok, etc.), omit the format parameter.

Response

Content Response Example:

{
    "status": true,
    "data": {
        "links": [
            {
                "preview": "https://dummy-thumbnail-url.com/image.jpg",
                "url": "https://dummy-cdn-url.com/video.mp4",
                "ext": "mp4",
                "quality": "HD",
                "type": "video"
            }
        ]
    }
}

Youtube Content Response Example::

{
    "status": true,
    "data": {
        "id": "dummy_video_id_12345",
        "thumb": "https://dummy-thumbnail-url.com/image.jpg",
        "title": "Sample Video Title",
        "host": "youtube",
        "links": [
            {
                "url": "#",
                "ext": "mp4",
                "type": "video",
                "quality": "HD",
                "size": 0,
                "preview": "https://dummy-thumbnail-url.com/image.jpg"
            }
        ]
    }
}

Error Response (400/403/500):

{
  "status": false,
  "message": "Error message describing what went wrong"
}

Format Required Error (for YouTube URLs):

{
  "status": false,
  "message": "Format parameter is required for YouTube URLs"
}

2. Progress Check

Endpoint: POST /wp-json/visolix/api/progress-check

Checks the progress of an ongoing YouTube video download process using a progress ID. This endpoint is specifically designed for YouTube downloads and provides real-time progress updates.

Parameters

Parameter
Type
Required
Description

id

string

Yes

Download progress ID (non-empty string)

key

string

Yes

API key for authentication

Request Example

curl -X POST https://your-site.com/wp-json/visolix/api/progress-check \
  -H "Content-Type: application/json" \
  -d '{
    "id": "progress_id_123456",
    "key": "your_api_key_here"
  }'

Response

In Progress Response:

{
    "success": 0,
    "progress": 21,
    "download_url": null,
    "text": "Initialising",
    "message": "If you want your application to use our API, visit https://developers.visolix.com/ or contact us at [email protected]"
}

Download Complete Response:

{
    "success": 1,
    "progress": 1000,
    "download_url": "https://dummy-download-url.com/video.mp4",
    "text": "Finished",
    "message": "If you want your application to use our API, visit https://developers.visolix.com/ or contact us at [email protected]"
}

Error Response (400/403/500):

{
  "status": false,
  "message": "Progress ID not found or invalid"
}

Note: Progress value ranges from 0-1000 where 1000 represents 100% completion.

Error Codes

HTTP Status
Error Code
Description

400

missing_captcha

CAPTCHA response is required but missing

400

invalid_captcha_service

Invalid CAPTCHA service configured

400

captcha_failed

CAPTCHA verification failed

400

missing_required_parameters

Required parameters are missing

403

rest_api_disabled

REST API is disabled in settings

403

license_inactive

Plugin license is not active

500

internal_error

Internal server error

Supported Platforms

The API supports video downloads from the following platforms:

  • YouTube

  • Instagram

  • Facebook

  • TikTok

  • Snapchat

  • Telegram

  • ShareChat

  • Odnoklassniki (OK.ru)

  • Moj

Configuration

To enable REST API access:

  1. Go to WordPress Admin → Visolix Video Downloader → Settings

  2. Enable "REST API" option

  3. Set your API key

  4. Configure CAPTCHA if desired

  5. Save settings

Examples

cURL Example - Get Video Data

# For YouTube URLs (format required)
curl -X POST https://your-site.com/wp-json/visolix/api/video-data \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.youtube.com/watch?v=ABC123",
    "format": "720",
    "key": "your_api_key_here"
  }'

# For Instagram URLs (no format needed)
curl -X POST https://your-site.com/wp-json/visolix/api/video-data \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.instagram.com/p/ABC123/",
    "key": "your_api_key_here"
  }'

cURL Example - Check Download Progress

curl -X POST https://your-site.com/wp-json/visolix/api/progress-check \
  -H "Content-Type: application/json" \
  -d '{
    "id": "your_progress_id_here",
    "key": "your_api_key_here"
  }'

PHP Example - Get Video Data

<?php
// Get video data
$api_url = 'https://your-site.com/wp-json/visolix/api/video-data';
$api_key = 'your_api_key';

// For YouTube (format required)
$data = array(
    'url' => 'https://www.youtube.com/watch?v=ABC123',
    'format' => '720',
    'key' => $api_key
);

// For other platforms (no format needed)
// $data = array(
//     'url' => 'https://www.instagram.com/p/ABC123/',
//     'key' => $api_key
// );

$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($http_code == 200) {
    $result = json_decode($response, true);
    if ($result['status']) {
        echo "Video data retrieved successfully!\n";
        if (isset($result['data']['links'])) {
            foreach ($result['data']['links'] as $link) {
                echo "Quality: " . $link['quality'] . "\n";
                echo "URL: " . $link['url'] . "\n";
            }
        }
    } else {
        echo "Error: " . $result['message'] . "\n";
    }
}

PHP Example - Check Download Progress

<?php
// Check download progress using REST API
$api_url = 'https://your-site.com/wp-json/visolix/api/progress-check';
$api_key = 'your_api_key';
$progress_id = 'your_progress_id_here';

$data = array(
    'id' => $progress_id,
    'key' => $api_key
);

$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($http_code == 200) {
    $result = json_decode($response, true);
    echo "Progress: " . $result['progress'] . "/1000\n";
    echo "Status: " . $result['text'] . "\n";

    if ($result['success'] == 1 && $result['download_url']) {
        echo "Download URL: " . $result['download_url'] . "\n";
    }
}

JavaScript Example - Get Video Data

// Fetch video data using REST API
const apiUrl = 'https://your-site.com/wp-json/visolix/api/video-data';
const apiKey = 'your_api_key';

async function getVideoData(url, format = null) {
    const data = {
        url: url,
        key: apiKey
    };

    // Add format only for YouTube
    if (format) {
        data.format = format;
    }

    try {
        const response = await fetch(apiUrl, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(data)
        });

        const result = await response.json();

        if (result.status) {
            console.log('Video data retrieved successfully!');
            if (result.data.links) {
                result.data.links.forEach(link => {
                    console.log(`Quality: ${link.quality}, URL: ${link.url}`);
                });
            }
        } else {
            console.error('Error:', result.message);
        }
    } catch (error) {
        console.error('Request failed:', error);
    }
}

// Usage examples
getVideoData('https://www.youtube.com/watch?v=ABC123', '720'); // YouTube with format
getVideoData('https://www.instagram.com/p/ABC123/'); // Instagram without format

JavaScript Example - Check Download Progress

// Check download progress using REST API
const progressApiUrl = 'https://your-site.com/wp-json/visolix/api/progress-check';
const apiKey = 'your_api_key';

async function checkProgress(progressId) {
    try {
        const response = await fetch(progressApiUrl, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                id: progressId,
                key: apiKey
            })
        });

        const result = await response.json();

        console.log(`Progress: ${result.progress}/1000`);
        console.log(`Status: ${result.text}`);

        if (result.success === 1) {
            console.log(`Download URL: ${result.download_url}`);
            return true; // Download complete
        }

        return false; // Still processing
    } catch (error) {
        console.error('Progress check failed:', error);
        return false;
    }
}

// Usage
const progressId = 'your_progress_id_here';
const isComplete = await checkProgress(progressId);

Troubleshooting

Common Issues

  1. 403 Forbidden: Check if REST API is enabled and license is active

  2. Invalid API Key: Verify your API key in plugin settings

For more information or support, please visit the Visolix or contact support.

Last updated