NAV
php javascript

Introduction

Welcome to the PlayTube Script API! You can use our API to access PlayTube API endpoints, which can get information from various features

We have language bindings in PHP and JavaScript! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.

Registrations

This api endpoint provides user registration

http://your-site.com/api/v<api version>/

To register, use this code:

$curl   = curl_init();

$params = array(
    'username' => 'john_smith',
    'email' => 'john_smith@email.com',
    'password' => 'secret12345',
    'confirm_password' => 'secret12345',
    'gender' => 'male'
);

$post = http_build_query($params);
curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=register");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$post);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/?type=register',
    type: 'POST',
    dataType: 'json',
    data: {
        username: 'john_smith2',
        email: 'john_smith2@email.com',
        password: 'secret12345',
        confirm_password: 'secret12345',
        gender: 'male'
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "success_type": "registered",
    "message": "Successfully joined, Please wait..",
    "data": {
        "user_id": "Registered user id",
        "s": "e317c1a2118e6cd6834aa028d2cda35a8ee31bbc151455751321708067ed8b92e350b062cf294abac6",
        "cookie": "e317c1a2118e6cd6834aa028d2cda35a8ee31bbc151455751321708067ed8b92e350b062cf294abac6"
    }
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

GET Parameters

Parameter Value Description
type register API endpoint type
platform phone or web API endpoint platform (Default phone)

POST Parameters

Parameter Default Description
username none User name
email none E-mail addresses
password none User Password
confirm_password none Confirm User Password
gender male User Gender

Errors

The Registrations API uses the following error codes:

Error Code ID Error message
400 1 You are already logged in
400 2 Sorry, User registration is currently disabled
400 3 Please write your username
400 4 Username must be between 5 / 32
400 5 Username is already exists
400 6 Invalid username characters
400 7 Please write your email
400 8 This e-mail is already in use
400 9 This e-mail is invalid
400 10 Please write your password
400 11 Password is too short
400 12 Please confirm your password
400 13 Password not match
500 14 Error: an unknown error occurred. Please try again later

Login

To login, use this code:


$curl   = curl_init();

$params = array(
    'username' => 'john_smith',
    'password' => 'secret12345',
);

$post = http_build_query($params);
curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=login");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$post);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/?type=login',
    type: 'POST',
    dataType: 'json',
    data: {
        username: 'john_smith2',
        password: 'secret12345',
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": {
        "session_id": "622ab513b757137026818e327b1789262f7f3f461514876799f14d01d60cf175eaec553f8ff2c9e1e9",
        "message": "Successfully logged in, Please wait.",
        "user_id": 4,
        "cookie": "622ab513b757137026818e327b1789262f7f3f461514876799f14d01d60cf175eaec553f8ff2c9e1e9"
    }
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api provides user login endpoint

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type login API endpoint type
platform phone or web API endpoint platform (Default phone)

POST Parameters

Parameter Description
username User name
password User Password

Errors

The Login API uses the following error codes:

Error Code ID Error message
400 1 Please enter your username and password
304 2 Your account is not active yet, please confirm your E-mail
400 3 Invalid username or password

Logout

To logout, use this code:

$curl   = curl_init();

$params = array(
    'user_id' => 'user id',
    's' => 'replace with your session id',
);

$post = http_build_query($params);
curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=logout");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$post);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/?type=logout',
    type: 'POST',
    dataType: 'json',
    data: {
        user_id: 'user id',
        s: 'replace with your session id',
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": {
        "message": "Successfully logged out",
    }
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api provides user logout endpoint

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type logout API endpoint type
platform phone or web API endpoint platform (Default phone)

POST Parameters

Parameter Description
user_id User name
s User session id

Errors

The Logout API uses the following error codes:

Error Code ID Error message
400 1 Bad Request, Invalid or missing parameter
400 2 Error 400 - Session does not exist

Reset Password

To reset user password, use this code:

$curl   = curl_init();

$params = array(
    'email' => 'john_smith@email.com',
);

$post = http_build_query($params);
curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=reset_password");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$post);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/?type=reset_password',
    type: 'POST',
    dataType: 'json',
    data: {
        email: 'john_smith@email.com'
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": {
        "email": "user email",
        "message": "A reset password link has been sent to your e-mail address",
    }
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api provides user password reset endpoint

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type reset_password API endpoint type
platform phone or web API endpoint platform (Default phone)

POST Parameters

Parameter Description
email User email address

Errors

The Reset password API uses the following error codes:

Error Code ID Error message
400 1 No user email sent
400 2 E-mail is not exists

Get videos

Use this code to get featured,top & latest videos:

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=get_videos");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
$out  = curl_exec($curl);
curl_close($curl);
print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/',
    type: 'GET',
    dataType: 'json',
    data: {
        type: 'get_videos'
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": {
        "featured": [ `{array of featured  videos}...` ],
        "top": [ `{array of top videos}...` ],
        "latest": [ `{array of latest videos}...` ]
    }
}

This api endpoint retrieveses featured,top & latest videos

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Default Description
type get_videos none API endpoint type
featured_offset [int - video_id] none Featured videos offset position
top_offset [int - video_id] none Top videos offset position
latest_offset [int - video_id] none Latest videos offset position
limit [int - video_id] 10 Total limit for featured,top & latest videos

Get videos by category id

Use this code to get videos by category:

$curl   = curl_init();

curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=get_videos_by_category&category_id=<category id>");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/',
    type: 'GET',
    dataType: 'json',
    data: {
        type: 'get_videos_by_category',
        category_id: <category id>
    },
})
.done(function(data) {
    console.log(data);
});

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": [ `{array of videos by category id}...` ]
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api endpoint retrieveses videos by category id

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Default Description
type get_videos_by_category none API endpoint type
offset [int - video_id] none Videos offset position
limit [int - video_id] 10 Videos total limit

Errors

The Get videos by category id API uses the following error codes:

Error Code ID Error message
400 1 Bad Request, Invalid or missing parameter

Get videos by channel id

Use this code to get videos by channel id:

$curl   = curl_init();

curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=get_videos_by_channel&<channel id>");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/',
    type: 'GET',
    dataType: 'json',
    data: {
        type: 'get_videos_by_channel',
        channel_id: <channel id>
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": [`{array of videos by channel id}...`]
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api endpoint retrieveses videos by channel id i.e. by user id

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Default Description
type get_videos_by_channel none API endpoint type
offset [int - video_id] none Videos offset position
limit [int - video_id] 10 Videos total limit

Errors

The Get videos by category id API uses the following error codes:

Error Code ID Error message
400 1 Bad Request, Invalid or missing parameter

Get videos details

Use this code to get video data:

$curl   = curl_init();

curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=get_video_details&video_id=<video id>");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/',
    type: 'GET',
    dataType: 'json',
    data: {
        type: 'get_video_details',
        video_id: 'srTSWpg8AuaYtH6'
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": { `video details`... }
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api endpoint retrieveses video data

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type get_video_details API endpoint type
video_id [str - video_id] Video id hash e.g. http://your-site.com/watch/`5tfbLTOFIKckRly`

Errors

The Get videos details API uses the following error codes:

Error Code ID Error message
400 1 Bad Request, Invalid or missing parameter
404 2 Video does not exist
500 3 Error: an unknown error occurred. Please try again later

Search videos

Use this code to search videos by keyword:

$curl   = curl_init();
$params = array(
    'type' => 'search_videos',
    'keyword' => 'search  keyword'
);

$get    = http_build_query($params);

curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?$get");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/',
    type: 'GET',
    dataType: 'json',
    data: {
        type: 'search_videos',
        keyword: 'Search keyword'
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": [ {`array of matched videos`...} ]
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api endpoint retrieveses videos by search keyword

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type search_videos API endpoint type
keyword [str] Search query keyword. Note min keyword length is 4 characters
offset [int] Videos offset position
limit [int] Videos total limit

Errors

The search videos API uses the following error codes:

Error Code ID Error message
400 1 Bad Request, Invalid or missing parameter

Delete video

Use this code to delete your video:


$curl   = curl_init();

$params = array(
    'user_id' => 'user id',
    's' => 'user session id'
);

$post = http_build_query($params);
curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=delete_video&id=<video id>");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$post);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/?type=delete_video&id=<video id>',
    type: 'POST',
    dataType: 'json',
    data: {
        s: 'c03c02aeb003d02161dfa21d02f7546a566dde1715130663881152f49eb451065cb3aff21e80744c21',
        user_id: 1
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "success_type": "deleted",
    "message": "Your video was successfully deleted"
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api endpoint provides videos deletion

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type delete_video API endpoint type
id [int] Video integer id
user_id [int] User integer id
s [str] User session id

Errors

The delete videos API uses the following error codes:

Error Code ID Error message
400 1 Not logged in
400 2 Bad Request, Invalid or missing parameter
404 3 Video does not exist

Get channel info

Use this code to fetch channel information:

$curl   = curl_init();

curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=get_channel_info&channel_id=<channel id>");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/',
    type: 'GET',
    dataType: 'json',
    data: {
        type:'get_channel_info',
        channel_id: '<channel id>'

    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": {
        "id": 2,
        "username": "john_smith",
        "email": "john_smith@gmail.com",
        "first_name": "",
        "last_name": "",
        "gender": "male",
        "language": "english",
        "avatar": "http:\/\/your-site.com\/upload\/photos\/d-avatar.jpg",
        "cover": "http:\/\/your-site.com\/upload\/photos\/d-cover.jpg",
        "about": "",
        "google": "",
        "facebook": "",
        "twitter": "",
        "verified": 0,
        "is_pro": 0,
        "url": "http:\/\/your-site.com\/@john_smith"
    }
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api endpoint retrieveses channel info

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type get_channel_info API endpoint type
channel_id [int] Channel integer id

Errors

The get channel info API uses the following error codes:

Error Code ID Error message
400 1 Bad Request, Invalid or missing parameter
404 2 Channel does not exist

Get my play-lists

Use this code to get your playlists:

$curl   = curl_init();

$params = array(
    'user_id' => '<user id>',
    's' => '<user session id>'
);

$post = http_build_query($params);
curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=get_my_playlists&limit=1");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$post);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/?type=get_my_playlists&limit=1',
    type: 'POST',
    dataType: 'json',
    data: {
        user_id:'<user id>',
        s: '<user session id>'

    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": [
        {
            "id": 2,
            "list_id": "nudjshKNB7jVIXf",
            "user_id": 2,
            "name": "My list num 1",
            "description": "My list num 1 desc",
            "privacy": 1,
            "views": 0,
            "icon": "",
            "time": 1513599469,
            "videos": [
                {
                    "id": 491,
                    "video_id": "xUgfMwQPfsFC7Ae",
                    "user_id": 1,
                    "title": "Gary Yourofsky On Effective Activism &amp; Not Losing Hope",
                    "thumbnail": "https:\/\/i.ytimg.com\/vi\/ZLIn4Zre9eE\/mqdefault.jpg",
                    "time": 1513066970,
                    "time_date": "2017-12-12 11:22:50",
                    "duration": "5:24",
                    "views": 2,
                    "url": "http:\/\/your-site.com\/watch\/xUgfMwQPfsFC7Ae",
                    "owner": {
                        "id": 1,
                        "username": "user_name",
                        "email": "http:\/\/your-site.com",
                        "first_name": "",
                        "last_name": "",
                        "gender": "male",
                        "language": "english",
                        "avatar": "http:\/\/your-site.com\/upload\/photos\/2017\/12\/cEcNZKMyD6gvFc26krd3_12_8e487ea310f952b227df1d22b2e9ab53_image.png",
                        "cover": "http:\/\/your-site.com\/upload\/photos\/2017\/12\/pRZtqCuDrIvZ4WXd1lcB_12_0c3d64c25dd3e0b7d221ae1fab715321_image.png",
                        "about": "",
                        "google": "",
                        "facebook": "",
                        "twitter": "",
                        "verified": 0,
                        "is_pro": 0,
                        "url": "http:\/\/your-site.com\/@user_name"
                    }
                },
                {...}
            ]
        },
        {...}
    ]
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api endpoint retrieveses user playlists

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type get_my_playlists API endpoint type
user_id [int] User integer id
s [str] User session id
offset [int] PlayLists offset position
limit [int] PlayLists total limit

Errors

The get playlists API uses the following error codes:

Error Code ID Error message
400 1 Not logged in

Get site settings

Use this code to fetch site settings:

$curl   = curl_init();

curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=get_settings");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
$out = curl_exec($curl);
curl_close($curl);
print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/',
    type: 'GET',
    dataType: 'json',
    data: {
        type:'get_settings',
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": {
        "site_settings": {
            "theme": "default",
            "censored_words": "",
            "title": "http:\/\/your-site.com",
            "name": "http:\/\/your-site.com",
            "keyword": "example,video sharing",
            "email": "site@email.com",
            "description": "Site description",
            "site_url": "http:\/\/your-site.com",
            ...
        },
        "categories": {
            "1": "Film & Animation",
            "2": "Cars & Vehicles",
            "3": "Music",
            "4": "Pets & Animals",
            "5": "Sports",
            "6": "Travel & Events",
            "7": "Gaming",
            "8": "People & Blogs",
            "9": "Comedy",
            "10": "Entertainment",
            "11": "News & Politics",
            "12": "How-to & Style",
            "13": "Non-profits & Activism"
        }
    }
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api endpoint retrieveses site configurations

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type get_settings API endpoint type
user_id [int] User integer id
s [str] User session id

Get Subscriptions

Use this code to fetch all subscriptions:

$curl   = curl_init();

$params = array(
    'user_id' => '<user id>',
    's' => '<user session id>'
);

$post = http_build_query($params);
curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=get_subscriptions&channel=1");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$post);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/?type=get_subscriptions&channel=1',
    type: 'POST',
    dataType: 'json',
    data: {
        user_id: '<user id>',
        s: '<user session id>'
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": [
        {
            "id": 1,
            "username": "john_smith",
            "email": "http:\/\/your-site.com",
            "first_name": "",
            "last_name": "",
            "gender": "male",
            "language": "english",
            "avatar": "http:\/\/your-site.com\/upload\/photos\/2017\/12\/d-avatar.png",
            "cover": "http:\/\/your-site.com\/upload\/photos\/2017\/12\/d-cover.png",
            "about": "",
            "google": "",
            "facebook": "",
            "twitter": "",
            "verified": 0,
            "is_pro": 0,
            "url": "http:\/\/your-site.com\/@john_smith"
        }
        ....
    ]
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api endpoint retrieveses an user subscriptions

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type get_subscriptions API endpoint type
user_id [int] User integer id
s [str] User session id
channel [int] 1 or 0 Integer 1 / 0 for channels or videos
offset [int] Data offset position
limit [int] Data total limit

Errors

The get subscriptions API uses the following error codes:

Error Code ID Error message
400 1 Not logged in
400 2 Bad Request, Invalid or missing parameter

Get Trending videos

Use this code to fetch all trending videos:

$curl   = curl_init();

curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=get_trending_videos");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/',
    type: 'GET',
    dataType: 'json',
    data: {
        type:'get_trending_videos'
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "data": [
        {
            "id": 735,
            "video_id": "6WQhxKeJpzgmNCm",
            "user_id": 1,
            "title": "Big buck bunny",
            "description": "",
            "thumbnail": "http:\/\/your-site.com\/upload\/photos\/2018\/01\/0571132a49b6f0104127e9f3915d994e48ed8d9fMZnm1CTU6q3gh93P8pqX.video_thumb.jpeg",
            "video_location": "http:\/\/your-site.com\/upload\/videos\/2018\/01\/zRXPr8NNzoZSY5qDpjJi_02_ca76824eb668a522d94367198c9862f6_video.mp4",
            "youtube": "",
            "vimeo": "",
            "daily": "",
            "time": 1514895693,
            "time_date": "2018-01-02 15:21:33",
            "active": 0,
            "tags": "big_buck_bunny",
            "duration": "00:00",
            "size": 1200484,
            "converted": 1,
            "category_id": 1,
            "views": 2,
            "featured": 0,
            "registered": "2018\/1",
            "type": "",
            "org_thumbnail": "upload\/photos\/2018\/01\/0571132a49b6f0104127e9f3915d994e48ed8d9fMZnm1CTU6q3gh93P8pqX.video_thumb.jpeg",
            "video_id_": "6WQhxKeJpzgmNCm",
            "source": "Uploaded",
            "video_type": "video\/mp4",
            "url": "http:\/\/your-site.com\/watch\/6WQhxKeJpzgmNCm",
            "edit_description": "big_buck_bunny.webm",
            "markup_description": "big_buck_bunny.webm.",
            "owner": {
                "id": 1,
                "username": "john_smith",
                "email": "http:\/\/your-site.com",
                "first_name": "",
                "last_name": "",
                "gender": "male",
                "language": "english",
                "avatar": "http:\/\/your-site.com\/upload\/photos\/2017\/12\/image.png",
                "cover": "http:\/\/your-site.com\/upload\/photos\/2017\/12\/image.png",
                "about": "",
                "google": "",
                "facebook": "",
                "twitter": "",
                "verified": 0,
                "is_pro": 0,
                "url": "http:\/\/your-site.com\/@john_smith"
            },
            "is_liked": 0,
            "is_disliked": 0,
            "is_owner": false,
            "time_alpha": "02 Jan 2018",
            "time_ago": "21 hours ago",
            "category_name": "Film & Animation"
        }
    ]
}
....

This api endpoint retrieveses trending videos

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type get_trending_videos API endpoint type
offset [int] Videos offset position
limit [int] Videos total limit

Get video comments

Use this code to fetch all videos comments:

$curl   = curl_init();

curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=get_video_comments&video_id=<video id>");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/',
    type: 'GET',
    dataType: 'json',
    data: {
        type:'get_video_comments',
        video_id: '<video id'>
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "total": 1,
    "api_version": "api version",
    "data": [
        {
            "id": 21,
            "user_id": 1,
            "video_id": 3,
            "text": "Commnet text",
            "time": "11 seconds ago",
            "pinned": "0",
            "likes": 0,
            "dis_likes": 0,
            "dislikes": 0,
            "is_liked": 0,
            "is_owner": 0,
            "is_disliked": 0,
            "owner": {
                "id": 1,
                "username": "john_smith",
                "email": "http:\/\/your-site.com",
                "first_name": "",
                "last_name": "",
                "gender": "male",
                "language": "english",
                "avatar": "http:\/\/your-site.com\/upload\/photos\/2017\/12\/image.png",
                "cover": "http:\/\/your-site.com\/upload\/photos\/2017\/12\/image.png",
                "about": "",
                "google": "",
                "facebook": "",
                "twitter": "",
                "verified": 0,
                "is_pro": 0,
                "url": "http:\/\/your-site.com\/@john_smith"
            },
            "replies": [
                {
                    "id": 5,
                    "user_id": 1,
                    "comment_id": 21,
                    "video_id": 3,
                    "post_id": 0,
                    "text": "Reply text ....",
                    "time": "7 seconds ago",
                    "owner": {
                        "id": 1,
                        "username": "john_smith",
                        "email": "http:\/\/your-site.com",
                        "first_name": "",
                        "last_name": "",
                        "gender": "male",
                        "language": "english",
                        "avatar": "http:\/\/your-site.com\/upload\/photos\/2017\/12\/image.png",
                        "cover": "http:\/\/your-site.com\/upload\/photos\/2017\/12\/image.png",
                        "about": "",
                        "google": "",
                        "facebook": "",
                        "twitter": "",
                        "verified": 0,
                        "is_pro": 0,
                        "url": "http:\/\/your-site.com\/@john_smith"
                    },
                    "likes": 0,
                    "dislikes": 0,
                    "is_liked": 0,
                    "is_disliked": 0,
                    "is_owner": 0
                },
            ]
        }
    ]
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api endpoint retrieveses video comments

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type get_video_comments API endpoint type
video_id [int] Video integer id
offset [int] Comments offset position

Errors

The get video comments API uses the following error codes:

Error Code ID Error message
400 1 Bad Request, Invalid or missing parameter
404 2 Video does not exist

Like / Dislike comments

Use this code to like or dislike video comments:

$curl   = curl_init();

$params = array(
    'user_id' => '<user id>',
    'id' => '<comment id>',
    'like_type' => 'up',
    's' => '<user session id>'
);

$post = http_build_query($params);
curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=like_dislike_comments");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$post);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/?type=like_dislike_comments',
    type: 'POST',
    dataType: 'json',
    data: {
        s:'<user session id>',
        user_id: '<user id>',
        id: '<comment id>',
        like_type:'up'
    },
})
.done(function(data) {
    console.log(data);
});

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "success_type": "added_like / deleted_like"
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api provides comment Liking and Disliking endpoint

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type like_dislike_comments API endpoint type

POST Parameters

Parameter Value Description
id [int] Comment integer id
like_type [str] User action type, use: up / down
user_id [int] User integer id
s [str] User session id

Errors

The comments voting API uses the following error codes:

Error Code ID Error message
400 1 Not logged in
400 2 Bad Request, Invalid or missing parameter
404 3 Error: 404 - Comment does not exist

Like / Dislike videos

Use this code to like or dislike videos:

$curl   = curl_init();

$params = array(
    'user_id' => '<user id>',
    'video_id' => '<video id>',
    'action' => 'up',
    's' => '<user session id>'
);

$post = http_build_query($params);
curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=like_dislike_video");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$post);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/?type=like_dislike_video',
    type: 'POST',
    dataType: 'json',
    data: {
        s:'<user session id>',
        user_id: '<user id>',
        video_id: '<video id>',
        action:'up'
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version",
    "success_type": "added_like / deleted_like"
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api provides video Liking and Disliking endpoint

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type like_dislike_video API endpoint type

POST Parameters

Parameter Value Description
video_id [int] Video integer id
action [str] User action type, use: up / down
user_id [int] User integer id
s [str] User session id

Errors

The videos voting API uses the following error codes:

Error Code ID Error message
400 1 Not logged in
400 2 Bad Request, Invalid or missing parameter
404 3 Video does not exist

Comment video

Use this code to comment videos:

$curl   = curl_init();

$params = array(
    's':'<user session id>',
    'user_id': '<user id>',
    'video_id': '<video id>',
    'text':'this is a comment....'
);

$post = http_build_query($params);
curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=add_comment");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$post);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/?type=add_comment',
    type: 'POST',
    dataType: 'json',
    data: {
        s:'<user session id>',
        user_id: '<user id>',
        video_id: '<video id>',
        text:'this is a comment....'
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "api version"
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api provides video commenting endpoint

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type add_comment API endpoint type

POST Parameters

Parameter Value Description
video_id [int] Video integer id
text [str] Comment text e.g. Lorem Ipsum is simply dummy text...
user_id [int] User integer id
s [str] User session id

Errors

The videos voting API uses the following error codes:

Error Code ID Error message
400 1 Not logged in
400 2 Bad Request, Invalid or missing parameter
404 3 Video does not exist
500 4 Error: an unknown error occurred. Please try again later

Subscribe to channel

Use this code to subscribe to a channel:

$curl   = curl_init();

$params = array(
    'user_id' => '<user id>',
    's' => '<user session id>'
);

$post = http_build_query($params);
curl_setopt($curl, CURLOPT_URL, "http://your-site.com/api/v<api version>/?type=subscribe_to_channel&channel_id=<channel id>");
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS,$post);
$out = curl_exec($curl);
curl_close($curl);

print_r($out);
$.ajax({
    url: 'http://your-site.com/api/v<api version>/?type=subscribe_to_channel&channel_id=<channel id>',
    type: 'POST',
    dataType: 'json',
    data: {
        s: '<user session id>',
        user_id: '<user id>',
    },
})
.done(function(data) {
    console.log(data);
})

JSON Success Response Format

{
    "api_status": "200",
    "api_version": "1.0"
}

JSON Error Response Format

{
    "api_status": "error code",
    "api_version": "api version",
    "errors": {
        "error_id": "error id",
        "error_text": "error message"
    }
}

This api provides channel subscription endpoint

HTTP Request

GET http://your-site.com/api/v<api version>/

GET Parameters

Parameter Value Description
type subscribe_to_channel API endpoint type
channel_id [int] Channel integer id
user_id [int] User integer id
s [str] User session id

Errors

The channel subscription API uses the following error codes:

Error Code ID Error message
400 1 Not logged in
400 2 Bad Request, Invalid or missing parameter
404 3 Bad Request, Invalid channel id please check your details