Contents
On this page
Import Catalogue - Plugixa Stream
POST /plugixa-stream/v1/admin/catalog/import
Create or update titles and episodes from a CSV file in the export format. A row with an id updates it; an episode row whose number the title already has updates that episode; anything else is created, as a draft unless its status says otherwise.
Needs a user with the plugixa_stream_create and plugixa_stream_edit capabilities and WordPress’s upload_files (signed in with an Application Password or the login cookie).
Note. A real import handles 25 rows per call. Send the same file again with
startset to thenextthe answer gave, untilnextisnull. A dry run reads the whole file in one call and changes nothing.
Request
POST https://your-site.example/wp-json/plugixa-stream/v1/admin/catalog/import
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
csv |
string |
Yes | The file’s content, at most 5 MB and 5,000 rows. The first line names the columns and must include type and title. |
start |
integer |
No | The row to start from, counted from 0. Defaults to 0. |
dry_run |
boolean |
No | Report what would happen without changing anything. |
A column missing from the file leaves that field as it is; a column present but empty clears it. Image columns are links: a file already in the Media Library is reused, any other is downloaded once.
{
"csv": "type,title,series,number,video\nseries,Flash Gordon,,,\nepisode,Chapter 1: The Planet of Peril,Flash Gordon,1,https://archive.org/download/flash-gordon-1936/chapter-1.mp4\n",
"start": 0,
"dry_run": true
}
Responses
200 OK. data is the report.
{
"success": true,
"data": {
"total": 2,
"next": null,
"created": {
"titles": 1,
"episodes": 1
},
"updated": {
"titles": 0,
"episodes": 0
},
"errors": []
}
}
| Field | Type | Meaning |
|---|---|---|
data.total |
integer |
Rows in the file, blank lines not counted |
data.next |
integer|null |
The start of the next batch, null when done |
data.created |
object |
Titles and episodes created in this call (or that would be, in a dry run) |
data.updated |
object |
Titles and episodes updated |
data.errors |
object[] |
Rows that were skipped: line (the line in the file) and message |
Errors
| Status | Code | When |
|---|---|---|
401 / 403 |
plugixa_stream_forbidden |
The caller lacks one of the three capabilities. |
422 |
plugixa_stream_csv |
The file is over 5 MB or 5,000 rows, empty, or its first line lacks type or title. |
Plus the errors every endpoint can return.
A problem in one row does not stop the import: it is listed in errors and the next row goes on.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-stream/v1/admin/catalog/import" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"csv":"type,title,series,number,video\nseries,Flash Gordon,,,\nepisode,Chapter 1: The Planet of Peril,Flash Gordon,1,https://archive.org/download/flash-gordon-1936/chapter-1.mp4\n","start":0,"dry_run":true}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-stream/v1/admin/catalog/import');
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([
'csv' => 'type,title,series,number,video
series,Flash Gordon,,,
episode,Chapter 1: The Planet of Peril,Flash Gordon,1,https://archive.org/download/flash-gordon-1936/chapter-1.mp4
',
'start' => 0,
'dry_run' => true,
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-stream/v1/admin/catalog/import', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ csv: 'type,title,series,number,video
series,Flash Gordon,,,
episode,Chapter 1: The Planet of Peril,Flash Gordon,1,https://archive.org/download/flash-gordon-1936/chapter-1.mp4
', start: 0, dry_run: true }),
});
const { data } = await response.json();
Quick Links
Share