Contents
On this page
Add Video to Playlist - Plugixa Video
POST /pvx/v1/playlists/{id}/items
Add a video at the end of a playlist. Adding a video that is already in it changes nothing.
Needs a user (signed in with an Application Password or the login cookie) who manages the playlist: its owner, or a user who may edit other people’s videos (editors and administrators). Needs the Playlists app on in Plugixa Video -> App manager; with it off, this route answers 404.
Request
POST https://your-site.example/wp-json/pvx/v1/playlists/1550/items
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The playlist’s id |
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
video_id |
integer |
Yes | A published or scheduled video, or one the caller may edit. |
A playlist holds at most 500 videos.
{
"video_id": 840
}
Responses
200 OK. data lists the playlist’s videos now.
{
"success": true,
"data": {
"video_ids": [838, 840]
}
}
| Field | Type | Meaning |
|---|---|---|
data.video_ids |
integer[] |
The playlist’s video ids in order, unpublished ones included |
Errors
| Status | Code | When |
|---|---|---|
401 |
plugixa_video_login_required |
Signed out. |
404 |
plugixa_video_not_found |
No playlist with that id, or a private playlist of someone else. |
403 |
plugixa_video_forbidden |
The caller can see the playlist but does not manage it. |
404 |
plugixa_video_not_found |
Also: video_id is not a video the caller may add. |
422 |
plugixa_video_limit |
The playlist already holds 500 videos. |
400 |
rest_missing_callback_param |
video_id is missing. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/pvx/v1/playlists/1550/items" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"video_id":840}'
<?php
$ch = curl_init('https://your-site.example/wp-json/pvx/v1/playlists/1550/items');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'video_id' => 840,
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/pvx/v1/playlists/1550/items', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ video_id: 840 }),
});
const { data } = await response.json();
Quick Links
Share