Channel Subscribing

Endpoints:

Subscribed channels act like an "inbox" of channels ordered by their most recent messages.

GET /users/me/channels/subscribed

Token: user

Scope: messages

Retrieve a list of channels the authenticated user is subscribed to.

Example
curl "https://api.pnut.io/v1/users/me/channels/subscribed" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    -H "X-Pretty-Json: 1"

Returns a list of subscribed channels.

{
    "meta": {
        "more": false,
        "max_id": "0",
        "min_id": "0",
        "unread_counts": {
            "io.pnut.core.chat": 0,
            "io.pnut.core.pm": 0
        },
        "code": 200
    },
    "data": [
        {"...Channel Object..."}
    ]
}

GET /channels/{channel_id}/subscribers

Scope: messages

Retrieve a list of users subscribed to a channel.

If ?include_presence=1 is included on the call, the users' presence field will reflect their presence in the channel, not their global user presence.

URL Parameters

Name Description
channel_id ID of the channel retrieve subscribers for.
Example
curl "https://api.pnut.io/v1/channels/18/subscribers" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    -H "X-Pretty-Json: 1"

Returns a list of users.

{
    "meta": {
        "code": 200
    },
    "data": [
        {"...User Object..."}
    ]
}

PUT /channels/{channel_id}/subscribe

Token: user

Scope: messages

Subscribe to updates from a channel. Subscribing unmutes it, if you were muting it.

URL Parameters

Name Description
channel_id ID of the channel to subscribe to.
Example
curl "https://api.pnut.io/v1/channels/18/subscribe" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    -X PUT \
    -H "X-Pretty-Json: 1"

Returns the subscribed channel.

{
    "meta": {
        "code": 200
    },
    "data": {"...Channel Object..."}
}

DELETE /channels/{channel_id}/subscribe

Token: user

Scope: messages

Delete a subscription for a channel. Unsubscribing also deletes any existing stream marker for the channel.

URL Parameters

Name Description
channel_id ID of the channel to unsubscribe from.
Example
curl "https://api.pnut.io/v1/channels/18/subscribe" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    -X DELETE \
    -H "X-Pretty-Json: 1"

Returns the unsubscribed channel.

{
    "meta": {
        "code": 200
    },
    "data": {"....Channel Object..."}
}