Contents
Unlock Episode - Plugixa Stream
POST /plugixa-stream/v1/episodes/{id}/unlock
Spend the caller’s coins on one episode, at its price: the episode’s own, else the title’s, else the price tier for its number, else the site’s episode price. Bonus coins are spent first.
Any signed-in user (an Application Password, or the login cookie with an X-WP-Nonce header). Signed out, it answers 401 plugixa_stream_login_required. It always acts on the caller’s own account. Rate-limited with the other unlock requests: 60 a minute per account.
Note. An episode the caller already owns is never charged twice: the answer is
409and nothing is taken.
Request
POST https://your-site.example/wp-json/plugixa-stream/v1/episodes/2818/unlock
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The episode’s id |
Responses
200 OK. The episode is the caller’s.
{
"success": true,
"data": {
"balance": {
"paid": 300,
"bonus": 0,
"total": 300
},
"coins": 50
}
}
| Field | Type | Meaning |
|---|---|---|
data.balance.paid |
integer |
Coins bought |
data.balance.bonus |
integer |
Coins given: check-in rewards, pack bonuses, grants |
data.balance.total |
integer |
Both |
data.coins |
integer |
Coins spent |
Errors
| Status | Code | When |
|---|---|---|
401 |
plugixa_stream_login_required |
Signed out. |
403 |
plugixa_stream_kids_profile |
The account’s active profile is a kids profile, which may not spend. |
404 |
plugixa_stream_not_found |
No such episode, or it or its title is not published or not shown on the active profile. |
409 |
plugixa_stream_already |
The episode is free, the caller is VIP, or they already unlocked it. |
402 |
plugixa_stream_insufficient_coins |
Not enough coins. |
500 |
plugixa_stream_wallet |
The wallet could not be updated. Nothing was charged. |
429 |
plugixa_stream_rate_limited |
More than 60 requests of this kind in the current minute. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-stream/v1/episodes/2818/unlock" \
-u "$WP_USER:$WP_APP_PASSWORD"
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-stream/v1/episodes/2818/unlock');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-stream/v1/episodes/2818/unlock', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
},
});
const { data } = await response.json();
Quick Links
Share