Skip to content

AVideo Platform API

Daniel Neto edited this page Feb 6, 2025 · 9 revisions

This document provides an overview of the AVideo API, including usage examples and authentication methods. The API enables third-party applications to interact with the AVideo platform. You can use this API to build custom applications or integrate with our mobile application.

1. Enabling the API Plugin

Ensure the API plugin is enabled on your AVideo installation. Access the Info button within the plugin settings to explore available resources. You must have admin privileges to access this information. Here’s an example from the demo site: API Info.

chrome-capture-2023-1-8

2. Authentication

Most API calls require user authentication. You can submit either a raw password or an encoded password:

  • Raw Password: Use the plain password directly.

  • Encoded Password: Use a hashed password. Password hashes are unique per website. To generate a hash for a password, you can use the encryptPass endpoint. Example:

    https://demo.avideo.com/objects/encryptPass.json.php?pass=123
    

The response will provide the hash:

{
    "hash": "f321d14cdeeb7cded7489f504fa8862b"
}

Example API Calls

  • Raw Password:

    https://demo.avideo.com/plugin/API/get.json.php?APIName=signIn&user=admin&pass=123
    
  • Encoded Password:

    https://demo.avideo.com/plugin/API/get.json.php?APIName=signIn&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
    

Simple and reusable login script:

  1. Provides a login form.
  2. Authenticates the user using raw or encoded password.
  3. Stores the session after successful login.
  4. Includes a function to check if the user is logged in.

PHP File: login.php

<?php
session_start();

// AVideo API Base URL
define('API_URL', 'https://demo.avideo.com/plugin/API/get.json.php');

// Function to authenticate the user
function authenticateUser($username, $password) {
    $apiUrl = API_URL . "?APIName=signIn&user=" . urlencode($username) . "&pass=" . urlencode($password);

    // Perform API request
    $response = file_get_contents($apiUrl);
    $data = json_decode($response, true);

    // Check if authentication was successful
    if (!empty($data['status']) && $data['status'] === "1") {
        $_SESSION['user'] = [
            'id' => $data['id'],
            'user' => $data['user'],
            'name' => $data['name'],
            'email' => $data['email']
        ];
        return true;
    }
    return false;
}

// Function to check if the user is logged in
function isUserLoggedIn() {
    return isset($_SESSION['user']);
}

// Handle logout
if (isset($_GET['logout'])) {
    session_destroy();
    header("Location: login.php");
    exit;
}

// Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $username = $_POST['username'] ?? '';
    $password = $_POST['password'] ?? '';

    if (authenticateUser($username, $password)) {
        header("Location: dashboard.php"); // Redirect to a dashboard or protected page
        exit;
    } else {
        $error = "Invalid username or password.";
    }
}

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login</title>
    <style>
        body { font-family: Arial, sans-serif; margin: 50px; }
        form { max-width: 300px; margin: auto; }
        input { display: block; width: 100%; padding: 10px; margin: 10px 0; }
        button { width: 100%; padding: 10px; background-color: blue; color: white; border: none; cursor: pointer; }
        .error { color: red; text-align: center; }
    </style>
</head>
<body>

<h2>Login</h2>

<?php if (!empty($error)) echo "<p class='error'>$error</p>"; ?>

<form method="POST">
    <input type="text" name="username" placeholder="Username" required>
    <input type="password" name="password" placeholder="Password" required>
    <button type="submit">Login</button>
</form>

</body>
</html>

Dashboard (Protected Page) - dashboard.php

This page checks if the user is logged in and displays their info.

<?php
session_start();

// Redirect if not logged in
if (!isset($_SESSION['user'])) {
    header("Location: login.php");
    exit;
}

$user = $_SESSION['user'];
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dashboard</title>
</head>
<body>

<h2>Welcome, <?php echo htmlspecialchars($user['name']); ?>!</h2>
<p>User: <?php echo htmlspecialchars($user['user']); ?></p>
<p>Email: <?php echo htmlspecialchars($user['email']); ?></p>

<a href="login.php?logout=true">Logout</a>

</body>
</html>

How It Works:

  1. User visits login.php and enters their credentials.
  2. The script calls AVideo API to authenticate.
  3. If successful, a session is created with user details.
  4. The user is redirected to dashboard.php.
  5. The dashboard verifies if the session exists before displaying user details.
  6. Clicking Logout destroys the session and redirects back to login.php.

3. Uploading Videos

The API allows you to upload videos from third-party applications. The Streamer handles all security, permissions, and encoding tasks. Follow the detailed guide for uploading videos to learn how to set up video uploads.

4. Sample API Call Video Response

Below is an example output from calling the API:

https://demo.avideo.com/plugin/API/get.json.php?APIName=video&catName=default&rowCount=1
{
    "error": false,
    "message": "",
    "response": {
        "rowCount": 1,
        "totalRows": 60,
        "rows": [
            {
                "id": 7618408,
                "isLive": 1,
                "categories_id": 1,
                "description": "",
                "user": "movieclips",
                "name": "Daniel Neto",
                "email": "[email protected]",
                "isAdmin": 0,
                "photoURL": "videos/userPhoto/photo5.png",
                "canStream": 1,
                "canUpload": 1,
                "channelName": "MovieclipsTrailers",
                "emailVerified": 1,
                "views_count": 0,
                "rrating": "",
                "users_id": 5,
                "type": "Live",
                "title": "&zwnj;Live 24 hours",
                "clean_title": "zwnj-live-24-hours",
                "poster": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                "thumbsJpgSmall": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                "href": "https://demo.avideo.com/live/0/MovieclipsTrailers",
                "link": "https://demo.avideo.com/live/0/MovieclipsTrailers",
                "imgGif": "",
                "className": "live_0_5c5d5402641e9",
                "galleryCallback": "",
                "stats": {
                    "type": "live",
                    "photo": "https://demoavideocom.cdn.ypt.me/videos/userPhoto/photo5.png?cache=1675861349_1675861447",
                    "UserPhoto": "https://demoavideocom.cdn.ypt.me/videos/userPhoto/photo5.png?cache=1675861349_1675861447",
                    "title": "&zwnj;Live 24 hours",
                    "users_id": 5,
                    "name": "Movieclips Trailers",
                    "href": "https://demo.avideo.com/live/0/MovieclipsTrailers",
                    "link": "https://demo.avideo.com/live/0/MovieclipsTrailers",
                    "callback": "",
                    "poster": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                    "imgGif": "",
                    "categories_id": 1,
                    "className": "live_0_5c5d5402641e9",
                    "comingsoon": false,
                    "description": false,
                    "timezone": "America/Sao_Paulo",
                    "live_servers_id": 0,
                    "key": "5c5d5402641e9",
                    "isPrivate": false,
                    "isPasswordProtected": false,
                    "method": "Live::_getStats"
                },
                "embedlink": "https://demo.avideo.com/live/0/MovieclipsTrailers?embed=1",
                "images": {
                    "poster": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                    "posterPortrait": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                    "posterPortraitPath": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                    "posterPortraitThumbs": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                    "posterPortraitThumbsSmall": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                    "thumbsGif": "",
                    "gifPortrait": "",
                    "thumbsJpg": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                    "thumbsJpgSmall": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                    "spectrumSource": false,
                    "posterLandscape": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                    "posterLandscapePath": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                    "posterLandscapeThumbs": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                    "posterLandscapeThumbsSmall": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg"
                },
                "videos": {
                    "m3u8": {
                        "url": "https://demoavideocomlive.cdn.ypt.me/5c5d5402641e9/index.m3u8",
                        "url_noCDN": "https://demoavideocomlive.cdn.ypt.me/5c5d5402641e9/index.m3u8",
                        "type": "video",
                        "format": "m3u8",
                        "resolution": "auto"
                    }
                },
                "Poster": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                "Thumbnail": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                "createdHumanTiming": "Live",
                "videoLink": "",
                "next_videos_id": null,
                "isSuggested": 0,
                "trailer1": "",
                "trailer2": "",
                "trailer3": "",
                "total_seconds_watching": 0,
                "duration": "Live",
                "duration_in_seconds": 0,
                "likes": 0,
                "dislikes": 0,
                "users_id_company": null,
                "iconClass": "fa fa-folder",
                "category": "Default",
                "clean_category": "default",
                "category_description": "",
                "videoCreation": "2023-02-08 11:13:47",
                "videoModified": "2023-02-08 11:13:47",
                "groups": [],
                "tags": [],
                "videoTags": [
                    {
                        "type_name": "Starring",
                        "name": ""
                    },
                    {
                        "type_name": "Language",
                        "name": "English"
                    },
                   ...
                ],
                "videoTagsObject": {
                    "Starring": [],
                    "Language": [
                        "English"
                    ],
                    "Release_Date": [
                        "2023"
                    ],
                    "Running_Time": [
                        "0"
                    ],
                    "Genres": [
                        "Default"
                    ]
                },
                "descriptionHTML": "",
                "progress": {
                    "percent": 0,
                    "lastVideoTime": 0
                },
                "isFavorite": null,
                "isWatchLater": null,
                "favoriteId": null,
                "watchLaterId": null,
                "total_seconds_watching_human": "",
                "views_count_short": "",
                "identification": "Movieclips Trailers",
                "UserPhoto": "videos/userPhoto/photo5.png",
                "isSubscribed": true,
                "subtitles": [],
                "subtitlesSRT": [],
                "comments": [],
                "commentsTotal": 0,
                "subscribers": 1,
                "relatedVideos": [],
                "wwbnURL": "https://demo.avideo.com/live/0/MovieclipsTrailers",
                "wwbnEmbedURL": "https://demo.avideo.com/live/0/MovieclipsTrailers?embed=1",
                "wwbnImgThumbnail": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                "wwbnImgPoster": "https://demo.avideo.com/plugin/Live/getImage.php?live_servers_id=0&playlists_id_live=&live_index=&u=movieclips&format=jpg",
                "wwbnTitle": "&zwnj;Live 24 hours",
                "wwbnDescription": "",
                "wwbnChannelURL": "https://demo.avideo.com/channel/TheAdminChannel",
                "wwbnImgChannel": "https://demoavideocom.cdn.ypt.me/videos/userPhoto/photo1.png?cache=1675861349_1675861447",
                "wwbnType": "live"
            },
            ...
        ],
        "current": 1,
        "hasMore": true
    },
    "msg": "",
    "users_id": 1
}

5. Collecting Video and Ad Play Statistics

To implement and collect statistics, you can follow the detailed Developer Guide: Collecting Video and Ad Play Statistics. This guide covers how to:

  • Track how many times each video is played.
  • Monitor how long each user watches a video and capture their last viewing position.
  • Record ad play events to generate reports.
  • Implement these features for different platforms, including web, mobile, and other devices.

Important Details

  • Video Statistics: Collects data on user interactions with videos, such as total play count, watch duration, and last watched position. Ensure you configure your API calls to send this data correctly.
  • Ad Statistics: Requires tracking ad events such as impressions, clicks, and completions. Integration can vary based on the platform (e.g., web, mobile).

6. Additional Resources

Clone this wiki locally