Skip to content

REST API

BuddyPress Giphy does not register its own REST namespace or endpoints. It extends the existing BuddyPress activity REST API by adding a bp_giphy field to every activity object.

When an activity has an attached GIF, the BuddyPress activity endpoint returns a bp_giphy object alongside the standard activity fields.

Endpoint

GET /wp-json/buddypress/v1/activity
GET /wp-json/buddypress/v1/activity/{id}

Added field

{
"id": 42,
"content": "Check this out",
"bp_giphy": {
"bp_activity_gif_id": "26ufdipkqArnFD0FG",
"bp_activity_gif": "https://media.giphy.com/media/26ufdipkqArnFD0FG/giphy.gif"
}
}

When the activity has no attached GIF, bp_giphy is false.

Field properties

Property Type Description
bp_activity_gif_id string The identifier assigned by the GIF provider (GIPHY or Klipy).
bp_activity_gif string The direct image URL of the GIF.

The plugin hooks bp_rest_activity_prepare_value at priority 10. On every call to the activity REST endpoint, it reads the activity’s _bp_activity_gif_data meta record and adds it as bp_giphy to the response object.

There is no write endpoint. GIF data is saved when a member posts an activity through the BuddyPress front-end form. The REST field is read-only.

When working server-side, read the activity meta directly:

$gif_data = bp_activity_get_meta( $activity_id, '_bp_activity_gif_data', true );
if ( ! empty( $gif_data['bp_activity_gif'] ) ) {
$gif_url = $gif_data['bp_activity_gif'];
$gif_id = $gif_data['bp_activity_gif_id'];
}

The BuddyPress activity endpoint follows standard BuddyPress REST authentication rules. No extra capabilities are required to read bp_giphy data - it is available to any request that can read the activity object.

  • Filter Reference - the bp_rest_activity_prepare_value hook that adds this field, and the buddypress_giphy_show_button filter for controlling front-end GIF access.