Skip to content

Namespace: bpquotes/v1 (base URL /wp-json/bpquotes/v1/)

The plugin registers four routes:

Route Method Who
/render/{activity_id} POST Logged-in member who can see the activity
/ai/suggest POST Logged-in member
/ai/report POST Logged-in member
/ai/reports GET Administrator (manage_options)

It also adds a bp_quotes field to the BuddyPress activity REST response (buddypress/v1/activity). The field holds the quote meta (bg-type, bg-value, bg-inverted-value) or is empty for normal posts.

Authentication: use a logged-in session and send the X-WP-Nonce header with a wp_rest nonce. On the front end the plugin gives you bpquotes_obj.rest_nonce and bpquotes_obj.rest_root. The root already ends in bpquotes/v1/, so append only the route.

Errors use the standard WordPress shape with a stable code:

{
"code": "bpquotes_render_throttled",
"message": "Too many render requests right now. Please try again in a minute.",
"data": { "status": 429 }
}

A missing login returns bpquotes_authentication_required (401). A missing admin right returns bpquotes_insufficient_permissions (403).


Creates a PNG of a quote and returns share links.

Permission: logged in, and allowed to read the activity (bp_activity_user_can_read).

Parameter Type Default Description
activity_id integer required In the path. The activity to render.
size string card card (1200x630), square (1080x1080) or story (1080x1920)

Response (200):

{
"url": "https://example.com/wp-content/uploads/bpquotes-shared/665-card-3f2a9c.png",
"expires_at": "2026-10-27T15:00:00+00:00",
"share_links": {
"twitter": "https://twitter.com/intent/tweet?...",
"facebook": "https://www.facebook.com/sharer/sharer.php?...",
"whatsapp": "https://api.whatsapp.com/send?...",
"linkedin": "https://www.linkedin.com/sharing/share-offsite/?...",
"pinterest": "https://pinterest.com/pin/create/button/?..."
}
}
  • The picture is cached for one hour. Cached pictures do not count toward the limit of 10 new renders per member per minute.
  • If the picture cannot be made for a soft reason (no GD, busy, disk), url is an empty string, image_error holds the message, and share_links omit pinterest.
  • share_links follow the Share targets setting and the bpquotes_share_targets filter.
  • Each call counts one share per member, quote and day.
Code Status Meaning
bpquotes_activity_missing 404 No such activity
bpquotes_forbidden 403 The member cannot read this activity
bpquotes_not_quoted 400 The activity has no quote background
bpquotes_invalid_activity 400 Invalid ID
bpquotes_render_throttled 429 Over 10 new renders in a minute

Returns quote ideas from the configured AI provider.

Permission: logged in. AI must be enabled and have a provider.

Parameter Type Required Default Description
prompt string Yes none Topic, mood or draft (cut to 2000 characters)
context string No none compose or refine
count integer No 3 1 to 5

Response (200):

{
"suggestions": ["First idea", "Second idea", "Third idea"],
"model": "claude-opus-4-7",
"latency_ms": 842,
"remaining_quota": {
"site_today": 4700,
"user_today": 120,
"site_limit": 5000,
"user_limit": 200
}
}

Quota numbers are approximate tokens left today (UTC).

Code Status Meaning
bpquotes_ai_disabled 403 AI suggestions are off
bpquotes_ai_empty_prompt 400 Empty prompt
bpquotes_ai_no_provider 400 No provider chosen
bpquotes_ai_unavailable 503 Service not loaded, or paused for five minutes after repeated provider failures
bpquotes_ai_site_quota_exhausted 429 Site daily limit reached
bpquotes_ai_user_quota_exhausted 429 Member daily limit reached

Provider errors are passed back as WP_Error responses.


Records that a suggestion was inappropriate.

Permission: logged in.

Parameter Type Required Description
text string Yes The suggestion text (cut to 1000 characters)
reason string No Short reason (cut to 280 characters)

Response (200): { "reported": true }

An empty text returns bpquotes_ai_report_failed (400). The plugin keeps the 200 newest reports.


Lists recent reports, newest first (up to 50).

Permission: administrator.

{
"items": [
{
"id": "bpq_65f1c2a0b1e3d",
"text": "Reported text",
"reason": "offensive",
"user_id": 44,
"timestamp": 1790000000
}
],
"total": 1
}

timestamp is a Unix time.


const res = await fetch( `${ bpquotes_obj.rest_root }render/${ activityId }`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': bpquotes_obj.rest_nonce,
},
body: JSON.stringify( { size: 'card' } ),
} );
const data = await res.json();

The plugin adds bpquotes_obj on pages where the quote tools load.