Introduction

In general, the REST API is optimised for mobile app development.

You can also try:

XMPP-FTW, which is better for realtime web application programming. Refer to their docs for more information.

Buddycloud HTTP REST API

Welcome to the Buddycloud REST API documentation.

The listed REST API calls give you access to the entire Buddycloud stack. These API calls are designed to make it easy to add rich in-app messaging and social features to your web or mobile app.

Getting Help

We really want this API to be useful to you. If you run into problems please contact us. Documentation fixes and ideas for improvements are always welcome.

These pages are generated using Slate.

REST API Conventions

Encoding

The REST API uses UTF-8 character encoding. Request headers should include a Content-Type of application/json; charset=utf-8.

Authentication

The REST API uses HTTP basic authentication. The username should also include the user’s domain (e.g. [email protected]).

External Authentication

Buddycloud’s backend enables you to authenticate your users against your own site by forwarding login requests to your own API. Email us to have this feature enabled for your domain.

Time Format

All timestamps are ISO-8601 formatted.

Discovery

Applications shall work with hardcoded API endpoints but, if need be, there’s a way to discover the REST API endpoint for a given Buddycloud domain.

REST API Discovery

Problem: Your application is designed for users on multiple Buddycloud sites each with their own REST API. It is necessary to discover the API endpoint for each user’s domain.

Solution: Buddycloud solves this by using a DNS lookup to discover the REST API endpoint.

Example

In order to resolve the API endpoint for buddycloud.com, do:

dig txt +short _buddycloud-api._tcp.buddycloud.com

You shall get a TXT record such as the following as response:

"v=1.0" "host=buddycloud.com" "protocol=https" "path=/api" "port=443"

Which means the API endpoint for buddycloud.com is:

https://buddycloud.com:443/api

To find the API for a user’s domain:

API TXT record information

Parameter Description Example
v API version number v=1.0
host server to use host=buddycloud.com
protocol which connection type to use protocol=https
path API prefix path=/api-endpoint
port port to use port=443

The following API endpoint reflects the above response: https://buddycloud.com:443/api-endpoint.

Accounts

Your users will need to authenticate against the server with a username that looks like username@domain. For example [email protected].

Create User

POST /api/account

Example

Creating the [email protected] account using curl:

curl https://buddycloud.com/api/account \
     -X POST \
     -H "Content-Type: application/json; charset=utf-8" \
     -d '{ \
            "username": "[email protected]", \
            "password": "romeo-forever", \
            "email": "[email protected]" \
         }'

This will create a new account for username and set their password and email. The email is used for password resets and for optional alerts from the push notification system.

Payload Parameters

Argument Required Notes
username always of form [email protected]; ≤1023 bytes
password ≤1023 bytes
email an email for password resets and optional push notifications

Check User Credentials

GET /api/

Example

Checking if [email protected] matches with password romeo-forever, using curl:

curl https://buddycloud.com/api/ \
    -X GET \
    -u [email protected]:romeo-forever

Use this endpoint to check if you have valid User credentials (username and password).

If you’re returned 200 OK, the credentials are valid.

Delete User

DELETE /api/account

Example

Deleting the [email protected] account using curl:

curl https://buddycloud.com/api/account \
     -X DELETE \
     -u [email protected]:romeo-forever

Removes a user account.

Change Password

POST /api/account/pw/change

Example

Changing the [email protected]’s password using curl:

curl https://buddycloud.com/api/account/pw/change \
     -X POST \
     -u [email protected]:romeo-forever \
     -H "Content-Type: application/json; charset=utf-8" \
     -d '{ \
            "username": "[email protected]", \
            "password": "new-password" \
         }'

Changes the user’s password.

Reset Password

POST /api/account/pw/reset

Example

Resetting the [email protected]’s password using curl:

curl https://buddycloud.com/api/account/pw/reset \
     -X POST \
     -H "Content-Type: application/json" \
     -d '{ "username": "[email protected]" }'

This resets the user’s password by sending a new password to the email address provided by the user during registration.

Channels

Channels are a group of publish-subscribe nodes. For example, the channel [email protected] is an group of nodes owned by the user [email protected]. Examples of such nodes that could be:

Channels and Nodes

Nodes

Nodes are publish-subscribe streams of posts with the same content type.

Each node has:

Personal Nodes v. Topic Nodes

Buddycloud divides nodes into two categories: topic and personal.

For example, the channel [email protected] comprises personal nodes for each type of information that juliet wants to share, such as her social activities, reflections on her mood, and the media she comments on.

Personal Node Topic Node
e.g. [email protected]/{nodeID} e.g. [email protected]/posts
represents a real person represents a topic
<channelID>@example.com <channelID>@topics.example.com
named after a user’s username not tied to a user’s username
owned by the matching username can be owned by any user
can receive private chat messages not applicable
geolocation optionally shared with followers anyone can search for nearby channels

Node Privacy Settings

Nodes may be private or public. Node Privacy is controlled by the node’s access_model:

Public Node Private Node
access model open authorize
visibility anyone can view requires a subscription request to view

The node metadata for public and private nodes is always publicly accessible.

Who creates the set of nodes for a channel?

Your application is responsible for creating the set of nodes it is going to use for a given channel. For example, the social application running at https://buddycloud.com automatically creates the following nodes everytime a new channel is created:

Name Personal Channel Topic Channel Description
status a one-line status message
posts ATOM formatted activity stream
geoloc-previous where they were
geoloc-current where they are
geoloc-future where they will go next
public-key public key for secure messaging

Create Node

POST /api/channelID/nodeID

Example

Creating a node called new-node using curl:

curl https://buddycloud.com/api/[email protected]/new-node \
    -X POST \
    -u [email protected]:romeo-forever

This allows creation of nodes.

Delete Node

DELETE /api/channelID/nodeID

Example

Deleting the node called new-node using curl:

curl https://buddycloud.com/api/[email protected]/new-node \
    -X DELETE \
    -u [email protected]:romeo-forever

This will remove a node.

Fetch Metadata

GET /api/channelID/metadata/nodeID

Example

Fetching the node new-node’s metadata using curl:

curl https://buddycloud.com/api/[email protected]/metadata/new-node \
     -X GET \
     -u [email protected]:romeo-forever

Metadata allows you to describe the node, set defaults and even add a location to the node so that it will show up in nearby queries.

Node metadata is always visible for both public and private nodes.

Update Metadata

POST /api/channelID/metadata/nodeID

Example

Updating the node new-node’s metadata using curl:

curl https://buddycloud.com/api/[email protected]/metadata/new-node \
     -X POST \
     -u [email protected]:romeo-forever \
     -H "Content-Type: application/json" \
     -d '{ \
            "title": "New Node Title", \
            "description": "Everything about Juliet", \
            "default_affiliation": "publisher" \
         }'

Use this endpoint to update a given node’s metadata.

Parameters

Field Edit? Values Description
channelID false ≤1023 bytes user@<domain> or topic@topics.<domain>
title true up to 50 characters the node’s title
description true up to 200 characters a short string describing the node
creation_date false RFC3399 timestamp when the node was created
access_model true open, authorize whether the node is public or private
channel_type false personal, topic whether this is a personal node or a topic node
default_ affiliation true publisher, follower the permissions a new subscriber is granted

A complete set of node metadata is available from the Buddycloud protocol specification.

Posts

New posts to a node are automaticaly:

Different channel types have different post formats.

Field value examples:

Post Parameters

Field Description Responsible
Example
author the username of this post’s author, set by the server server
content the post’s content - usually this is activity stream event user
O Romeo, Romeo! Wherefore art thou Romeo?
id the unique POST_ID assigned to this post by the server server
17163726-ea90-453e-ad25-455336a83fd4
media a list of media objects this post might refer to user
[ { "id": "romeo-photo-id", "channel": "[email protected]" } ]
replyTo the parent POST_ID if this post is a reply to another post user
9b7724d0-7ef5-4331-8974-81754abb7ba0
published the date when this post was created server
2012-11-02T03:41:55.484Z
updated the last time there was a reply in this thread or when the post was created server
2012-11-02T03:41:55.484Z

Pagination

Buddycloud uses Result Set Management for pagination of results obtained by the different endpoints for fetching posts specified below. This is useful when:

Query Parameters

You will pass pagination parameters via the URL query part.

Parameter Description
max The maximum number of returned entries
before Get posts newer than entry with this POST_ID
after Return only entries older than the entry with this POST_ID

Create Post

POST /api/channelID/content/nodeID

Example

Creating a new post to the posts node of [email protected], using curl:

curl https://buddycloud.com/api/[email protected]/content/posts \
     -X POST \
     -u [email protected]:romeo-forever \
     -H "Content-Type: application/json" \
     -d '{ "content": "O Romeo, Romeo, wherefore art thou Romeo?" }'

Response will be as follows:

HTTP/1.1 201 Created

Location: https://buddycloud.com/[email protected]/content/posts/$POST_ID

Use this endpoint to create new post to a given node.

Delete Post

DELETE /api/channelID/content/nodeID/postID

Example

Deleting post of id $POST_ID from the posts node of [email protected], using curl:

curl https://buddycloud.com/api/[email protected]/content/posts/$POST_ID \
     -X DELETE \
     -u [email protected]:romeo-forever 

Removes a post from a node.

When a post is deleted,

Fetch Specific Post

GET /api/channelID/content/nodeID/postID

Example

Fetching specific post of id $POST_ID from the [email protected]/posts node, using curl:

curl https://buddycloud.com/api/[email protected]/content/posts/$POST_ID \
    -X GET \
    -H "Accept: application/json"

Response would be as follows:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "id": "$POST_ID",
    "author": "[email protected]",
    "updated": "1595-06-01T12:00:00Z",
    "content": "But, soft! What light through yonder window breaks? It is the east, and Juliet is the sun.",
    "media": null
}

If you have interest in fetching a particular post whose $POST_ID is already known to you, you can use this endpoint for that matter.

For obvious reasons, this endpoint doesn’t support pagination. The other endpoints below potentially return multiple entries, with proper pagination support.

Fetch a Post’s Child Posts

GET /api/channelID/content/nodeID/postID/replyTo

Example

Fetching child posts of post to node [email protected]/posts of id $POST_ID using curl:

curl https://buddycloud.com/api/[email protected]/content/posts/$POST_ID/replyTo \
     -X GET \
     -H "Accept: application/json"

Response would be as follows:

HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "id": "$NEWEST_CHILD_POST_ID",
        "author": "[email protected]",
        "updated": "1595-06-01T12:00:00Z",
        "content": "But, soft! What light through yonder window breaks? It is the east, and Juliet is the sun.",
        "replyTo": "$POST_ID",
        "media": null
    },
    ...
    {
        "id": "$OLDEST_CHILD_POST_ID",
        "author": "[email protected]",
        "updated": "1591-06-04T12:00:00Z",
        "content": "Thus with a kiss I die.",
        "replyTo": "$POST_ID",
        "media": null
    }
]

Same endpoint using pagination

GET /api/channelID/content/nodeID/postID/replyTo? param=val&param=val

Example

Fetching posts from a node using pagination, using curl:

curl https://buddycloud.com/api/[email protected]/content/posts?after=$NEWEST_POST_ID \
     -X GET \
     -H "Accept: application/json"

Then, response would be as follows:

HTTP/1.1 200 OK
Content-Type: application/json

[
    [Post with id == "NEWEST_CHILD_POST_ID" omitted]
    ...
    {
        "id": "$OLDEST_CHILD_POST_ID",
        "author": "[email protected]",
        "updated": "1591-06-04T12:00:00Z",
        "content": "Thus with a kiss I die.",
        "replyTo": "$POST_ID",
        "media": null
    }
]

Retrieves one or more posts that are children of a given node specified by $POST_ID using pagination ranges.

Fetch Recent Posts

GET /api/channelID/content/nodeID

Example

Fetching the most recent posts from the [email protected]/posts node, using curl:

curl https://buddycloud.com/api/[email protected]/content/posts \
     -X GET \
     -H "Accept: application/json"

Response would be as follows:

HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "id": "$NEWEST_POST_ID",
        "author": "[email protected]",
        "updated": "1595-06-01T12:00:00Z",
        "content": "But, soft! What light through yonder window breaks? It is the east, and Juliet is the sun.",
        "media": null
    },
    ...
    {
        "id": "$OLDEST_POST_ID",
        "author": "[email protected]",
        "updated": "1591-06-04T12:00:00Z",
        "content": "Thus with a kiss I die.",
        "media": null
    }
]

Same endpoint using pagination

GET /api/channelID/content/nodeID? param=val&param=val

Example

Fetching posts from a node using pagination, using curl:

curl https://buddycloud.com/api/[email protected]/content/posts?max=3 \
     -X GET \
     -H "Accept: application/json"

Then, response would be as follows:

HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "id": "$NEWEST_POST_ID",
        "author": "[email protected]",
        "updated": "1595-06-01T12:00:00Z",
        "content": "But, soft! What light through yonder window breaks? It is the east, and Juliet is the sun.",
        "media": null
    },
    ...
    {
        "id": "$OLDEST_POST_ID",
        "author": "[email protected]",
        "updated": "1591-06-04T12:00:00Z",
        "content": "Thus with a kiss I die.",
        "media": null
    }
]

Retrieves one or more posts using pagination ranges.

This is useful for retrieving recent posts to an individual node.

Often it’s useful to quickly show, for example, the 20 most recent posts. However some of these posts may reference a parent post outside of you apps' cache.

For another approach, please refer to the Fetch Recent Post Threads section depicted below.

Fetch Recent Post Threads

GET /api/channelID/content/nodeID/threads

Example

Fetching the most recent post threads from the [email protected]/posts node, using curl:

curl https://buddycloud.com/api/[email protected]/content/posts/threads \
     -X GET \
     -H "Accept: application/json"

Response would be as follows:

HTTP/1.1 200 OK
Content-Type: application/json

[
  {
    "id": "$PARENT_POST_ID"
    "updated": "2015-01-30T01:39:00.070Z",
    "items": [
        {
            "id": "$OLDEST_CHILD_POST_ID",
            "author": "[email protected]",
            "updated": "1595-06-01T12:00:00Z",
            "content": "First reply.",
            "replyTo": "$PARENT_POST_ID"
            "media": null
        },
        ...
        [More Child Posts...]
        ...
        {
            "id": "$NEWEST_CHILD_POST_ID",
            "author": "[email protected]",
            "updated": "1595-06-01T12:00:00Z",
            "content": "Last thing ever said.",
            "replyTo": "$PARENT_POST_ID"
            "media": null
        },
        {
            "id": "$PARENT_POST_ID",
            "author": "[email protected]",
            "updated": "1591-06-04T12:00:00Z",
            "content": "First thing ever said.",
            "media": null
        }
    ]
  }
  ...
  [More Post Threads]
]

Retrieves one or more post threads, that is, collections of chained posts, using pagination ranges (where max depicts the maximum number of threads expected in the response).

Subscriptions

Retrieving a user’s channel subscription list will return the nodes that they follow and their affiliation with that node, which can be either:

…as well as the nodes where they have a subscription state of pending (which means the subscription is waiting to be approved).

Subscription Privacy

Users can only request their own subscriptions and are unable to view other user’s subscriptions.

Fetch Subscriptions

GET /api/subscribed

Example

Fetching subscriptions of [email protected], using curl:

curl https://buddycloud.com/api/subscribed \
     -X GET \
     -u [email protected]:romeo-forever \
     -H "Accept: application/json"

Response would be as follows:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "[email protected]/posts": "owner",
    "[email protected]/status": "owner",
    "[email protected]/posts": "pending",
    "[email protected]/posts": "publisher"
}

Returns the user’s channel subscriptions as a JSON object.

The object’s keys are of the form {channel}/{node}.

The values denote the subscription type:

Follow Channel

POST /api/subscribed

Example

[email protected] is subscribing to [email protected]/posts, using curl:

curl https://buddycloud.com/api/subscribed \
     -X POST \
     -u [email protected]:romeo-forever \
     -H "Content-Type: application/json" \
     -d '{ "[email protected]/posts": "publisher" }'

Following behavior is dependent on the channel type:

Following a private channel:

Unfollow Channel

Same endpoint as before, but passing ‘none’ in the payload

POST /api/subscribed

Example

[email protected] unfollows [email protected]/posts, using curl:

curl https://buddycloud.com/api/subscribed \
     -X POST \
     -u [email protected]:romeo-forever \
     -H "Content-Type: application/json" \
     -d '{ \
             "[email protected]/posts": "none" \
         }'

Unfollowing a private channel removes the ability to read, upvote or delete posts.

Unfollowing a private channel will require re-requesting a subscription and re-approval of a moderator.

Followers

Followers of the nodes in a channel have one of the following affiliations:

Affiliation User sees Description
owner owner add/remove moderators
moderator moderator approve subscription requests & delete posts
publisher follower+post create new posts
member follower only view posts
pending pending nothing
outcast null only visibile to the owner and moderator affiliation

The outcast affiliation is useful for dealing with abusive users.

Fetch Followers

GET /api/channelID/subscribers/nodeID

Example

Fetching followers of the [email protected]/posts node, using curl:

curl https://buddycloud.com/api/[email protected]/subscribers/posts \
     -X GET \
     -u [email protected]:juliet-forever \
     -H "Content-Type: application/json"

Response would be as follows:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "[email protected]": "owner",
    "[email protected]": "publisher"
}

This request returns a list of channel followers and their affiliation in the channel.

Public channels Private Channels
Return the list without authentication requesting user must also be an owner moderator publisher or member of the channel

Retrieve Pending Followers

GET /api/channelID/subscribers/nodeID/approve

Example

Retrieving pending subscriptions to the [email protected] node, using curl:

curl https://buddycloud.com/api/[email protected]/subscribers/posts/approve \
     -X GET \
     -u [email protected]:juliet-forever \
     -H "Content-Type: application/json"

Response would be as follows:

HTTP/1.1 200 OK
Content-Type application/json

[
    {
        "subscription": "subscribed",
        "jid": "[email protected]"
    },
    {
        "subscription": "pending",
        "jid": "[email protected]"
    },
    {
        "subscription": "pending",
        "jid": "[email protected]"
    }
]

Retrieves the list of subscriptions of a node. Returns a list of objects containing the subscriber JID and the values of its subscription state (subscribed or pending).

Authorise Pending Followers

POST /api/channelID/subscribers/nodeID/approve

Example

Authorising subscription of [email protected] and denying to [email protected], using curl:

curl https://buddycloud.com/api/[email protected]/subscribers/posts/approve \
     -X POST \
     -u [email protected]:juliet-forever \
     -H "Content-Type: application/json" \
     -d '[ \
             { \
                 "subscription": "subscribed", \
                 "jid": "[email protected]" \
             }, \
             { \
                 "subscription": "none", \
                 "jid": "[email protected]" \
             } \
         ]'

This allows a channel’s owner or moderator to approve or deny incoming subscription requests.

Subscription State Description
pending No action taken by owner or moderator.
subscribed Permission to follow channel granted.
none Permission to follow channel denied.

Alter Follower Affiliations

POST /api/channelID/subscribers/nodeID

Example

Changing [email protected]’s subscription affiliation to [email protected]/posts to member, using curl:

curl https://buddycloud.com/api/[email protected]/subscribers/posts \
     -X POST \
     -u [email protected]:juliet-forever \
     -H "Content-Type: application/json" \
     -d '{ \
             "[email protected]": "member" \
         }'

This enables users to promote (or e) user subscriptions to publisher, member or even moderator. By setting a subscription to outcast, the user is banned.

Media

File’s inherit the permissions of the channel they are shared with. For example sharing files onto a private channel will mean that only that channel’s followers can download them.

Media can be any type of file, and any file size (Buddycloud site administrators usually set about 1GB as a maximum size.)

Special MediaIDs

The media id of avatar is currently reserved and used for storing a channels avatar. Uploading with the avatar id will replace the user’s avatar.

List Media

GET /api/channelID/media

curl https://buddycloud.com/api/[email protected]/media \
     -X GET \
     -u [email protected]:romeo-forever

Response would be as follows:

HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "id": "lETuJi8rPE4IfQrygN8rVtGx3",
        "fileName": "photo.jpg",
        "author": "[email protected]",
        "title": "Juliet's pic",
        "mimeType": "image/jpeg",
        "description": "Juliet's picture 1595/06/01",
        "fileExtension": "jpg",
        "shaChecksum": "bc46e5fac2f1cbb607c8b253a5af33181f161562",
        "fileSize": "60892",
        "height": "312",
        "width": "312",
        "entityId": "[email protected]"
    }
]

This returns a list of all avaliable media objects in a channel.

Fetch Media

Get the raw media

GET /api/channelID/media/mediaID

Example

Retrieving the raw media of id $MEDIA_ID, using curl:

curl https://buddycloud.com/api/[email protected]/media/$MEDIA_ID \
     -X GET \
     -u [email protected]:romeo-forever

Get the media thumbnail preview

GET /api/channelID/media/mediaID?maxheight=val&maxwidth=val

Example

Retrieving a preview of the media of id $MEDIA_ID, using curl:

curl https://buddycloud.com/api/[email protected]/media/$MEDIA_ID?maxheight=150&maxwidth=150 \
     -X GET \
     -u [email protected]:romeo-forever

Get avatar

GET /api/channelID/media/avatar

Example

Retrieving avatar of [email protected], using curl:

curl https://buddycloud.com/api/[email protected]/media/avatar \
     -X GET \
     -u [email protected]:romeo-forever

This request returns a media file.

The request can also be used to return an image preview or small user avatar sized files by adding the maxheight and maxwidth parameter to the request.

If the media object belongs to a public channel, you don’t need an Authorization header. Notice that if you’re building a web frontend, embedding public media from the media-server means just creating an <img> tag.

Parameter Required Description
maxheight optional Bound the ouput by a maximum height
maxwidth optional Bound the output by a maximum width

When both maxheight and maxwidth are requested the server will return a file smaller than or equal to both parameters.

Post Media

POST /api/channelID/media

Example

Posting new media to the [email protected] channel, using curl:

curl https://buddycloud.com/api/[email protected]/media \
     -X POST \
     -u [email protected]:romeo-forever \
     -H "Content-Type: application/json" \
     -d '{ \
             "data": "media data in bytes", \
             "content-type": "image/png", \
             "filename": "prom.png", \
             "title": "Juliet's prom pic", \
             "description": "Juliet's beautiful prom pic!" \
         }'

Response would be as follows:

HTTP/1.1 201 Created
Content-Type: application/json

{
    "id": "lETuJi8rPE4IfQrygN6rVtGx3",
    "fileName": "prom.png",
    "author": "[email protected]",
    "title": "Juliet's prom pic",
    "mimeType": "image/png",
    "description": "Juliet's beautiful prom pic!",
    "fileExtension": "png",
    "shaChecksum": "bc46e5fac2f1cbb607c8b253a5af33181f161562",
    "fileSize": 60892,
    "height": 312,
    "width": 312,
    "entityId": "[email protected]"
}

This call enables media and media-metadata uploading and modification.

Posting new media will return the object id and metadata.

Updating existing media with the same id will overwrite the existing media content.

Delete Media

DELETE /api/channelID/media/mediaID

Example

Deleting media of id $MEDIA_ID from the [email protected] channel, using curl:

curl https://buddycloud.com/api/[email protected]/media/$MEDIA_ID \
     -x DELETE \
     -u [email protected]:romeo-forever

Removes media from the channel.

Deleting media will remove it from the requested channel. This does not remove it from other channels where it has been reshared.

Fetch Media Metadata

GET /api/channelID/media/mediaID/metadata

Example

Fetching metadata of media of id $MEDIA_ID, using curl:

curl https://buddycloud.com/api/[email protected]/media/$MEDIA_ID/metadata \
     -X GET \
     -u [email protected]:romeo-forever

Response would be as follows:

HTTP/1.1 200 OK
Content-Type: application/json

[
    {
        "id": "lETuJi8rPE4IfQrygN8rVtGx3",
        "fileName": "photo.jpg",
        "author": "[email protected]",
        "title": "Juliet's pic",
        "mimeType": "image/jpeg",
        "description": "Juliet's picture 1595/06/01",
        "fileExtension": "jpg",
        "shaChecksum": "bc46e5fac2f1cbb607c8b253a5af33181f161562",
        "fileSize": "60892",
        "height": "312",
        "width": "312",
        "entityId": "[email protected]"
    }
]

Endpoint used to fetch a given media’s metadata.

Update Media Metadata

PUT /api/channelID/media/mediaID

Example

Updating the media of id $MEDIA_ID’s name and title, using curl:

curl https://buddycloud.com/api/[email protected]/media/$MEDIA_ID \
     -X PUT \
     -u [email protected]:romeo-forever \
     -d '{ \
            "filename": "A good name for that picture of Jules", \
            "title": "A new title" \
        }' 

Use this endpoint to update a give media’s metadata.

The possible metadata parameters are:

Parameter Required Description
height server-set Height of the uploaded image or video. This is calculated by the server and not user-editable.
width server-set Width of the uploaded image or video. This is calculated by the server and not user-editable.
author server-set the username of the uploader
shaChecksum server-set SHA1 file checksum
uploadedDate server-set when the media was uploaded
lastUpdatedDate server-set when the media was updated / re-uploaded
mimeType required The file mimetype (e.g. image/jpeg)
fileName required The uploaded filename and extension.
entityId required The channel where the media object was posted.
title optional a short title of the object
description optional a longer form description of the object

Realtime

To get content updates in realtime directly through the REST API, your application can rely on long-polling an endpoint specifically designed with this goal in mind. The first section below depicts it in detail.

But to make your application truly aware of all kinds of Buddycloud events, you’ll need more.

If you’re building a mobile app, you can set it up so that it will listen for incoming push notifications when important events happen. The last sections below describe every step needed to make your app fully Buddycloud-powered.

Otherwise, the recommended thing is to have your app use XMPP-FTW. Please also refer to this guide with more on how to get started.

New Post Updates

First, get the last known timestamp

GET /api/notifications/posts

Example

Asking for the last known timestamp, using curl:

curl https://buddycloud.com/api/notifications/posts \
    -X GET

Response would be as follows:

{
    "last": "$LAST_TIMESTAMP",
    "items": []
}

Finally, start long polling

GET /api/notifications/posts?since=lastTT

Example

Using the last known timestamp to start long polling:

curl https://buddycloud.com/api/notifications/posts?since=$LAST_TIMESTAMP \
    -X GET

Once a new update arrives, response would be as follows:

{
    "last": "$LAST_TIMESTAMP_UPDATED",
    "items": [
        {
            "id": "$POST_ID",
            "source": "[email protected]/posts"
            "author": "[email protected]"
            "published": "2014-06-24T15:34:54.449Z",
            "updated": "2014-06-24T15:34:54.449Z",
            "content": "This the newest post in town",
            "media": null,
            "replyTo": "$PARENT_POST_ID"
        }
        ...
        [Potentially more posts from this node or other nodes here]
    ]

Don’t forget that the last known timestamp now is $LAST_TIMESTAMP_UPDATED!

Get New Post Updates By Long Polling

Use this endpoint to start long polling for new posts updates. Multiple updates shall arrive at a time, for all nodes the user is subscribed to (the user your app is currently working with).

Your application will need to provide the last known timestamp lastTT everytime it makes a new long polling request. On the right there are good examples of the intended flow of this process of getting new posts updates.

A new posts update should arrive in the form of a JSON response comprised of all the new posts' contents alongside information about the nodes that the new post belong to, respectively (the source key of each post has this value).

Push Notifications

Get SENDER ID From The Pusher

GET /api/notification_metadata?type=gcm

Example

Retrieving $SENDER_ID from the buddycloud.com’s Pusher service, using curl:

curl https://buddycloud.com/api/notification_metadata?type=gcm \
    -X GET \
    -u [email protected]:romeo-forever
    -H "Accept: application/json"

Response would be as follows:

{ "google_project_id": "$SENDER_ID" }

Do some work in your app to obtain a $REG_ID and then…

Send REGISTRATION ID To The Pusher

POST /api/notification_settings

Example

Sending $REG_ID when registering with buddycloud.com’s Pusher service, using curl:

curl https://buddycloud.com/api/notification_settings \
    -X POST \
    -u [email protected]:romeo-forever \
    -H "Content-Type: application/json" \
    -d '{ \
           "type": "gcm", \
           "target": "$SENDER_ID" \
    }'

Alongside the type and target keys, you can specify specific events you want to monitor (or not). By default you’ll monitor most events. More information about this can be found here.

Get Push Notifications By Registering With The Pusher Service

There’s some work you will have to do in your mobile application in order to enable it to receive Buddycloud updates via push notifications, sent by our Pusher service. It will need to become a Google Cloud Messaging client so that it’s able to receive those updates. Please refer to this guide and perform instructions given there.

Then, you will use some API calls in order to talk to our Pusher server so that you can register your application with it. In short, you’ll need to get a SENDER_ID from the Pusher, use it within your application to register with Google Cloud Messaging and then send your REG_ID back to the Pusher to register with it too. This guide explains the process more thoroughly and on the right you can find the specs of both endpoints used alongside short examples.