Channel Lookup

To only retrieve channels by certain types, include them in a comma-separated list in the query parameter like so: channel_types=io.pnut.core.pm,com.example.site.

Endpoints:

GET /channels/{channel_id}

Scope: messages

Retrieve a channel object.

URL Parameters

Name Description
channel_id ID of the requested channel
Example
curl "https://api.pnut.io/v0/channels/5" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    -H "X-Pretty-Json: 1"

Returns the requested channel

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

GET /channels

Scope: messages

Retrieve a list of specified channel objects. Only returns the first 200 found.

Query String Parameters

Name Description
ids Comma-separated list of channel IDs
Example
curl "https://api.pnut.io/v0/channels?ids=3,4,16" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    -H "X-Pretty-Json: 1"

Returns a list of channels

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

GET /users/me/channels

Token: user

Scope: messages

Retrieve a list of channels created by the authenticated user.

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

Returns a list of channels

{
    "meta": {
        "more": false,
        "min_id": "0",
        "max_id": "0",
        "code": 200
    },
    "data": [
        {"...Channel Object..."}
    ]
}

GET /users/me/channels/existing_pm

Token: user

Scope: messages

Retrieve a Private Message channel for a set of users, if one exists.

Query String Parameters

Name Description
ids Comma-separated list of User IDs or @-usernames. The authenticated user can be included or excluded.
Example
curl "https://api.pnut.io/v0/users/me/channels/existing_pm?ids=2" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    -H "X-Pretty-Json: 1"

Returns a channel.

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

GET /users/me/channels/num_unread

Token: user

Scope: messages

Retrieve the number of unread messages for the authenticated user.

Query String Parameters

Name Description
channel_types Comma-separated list of channel types to look up. Up to 4 at a time.
Example
curl "https://api.pnut.io/v0/users/me/channels/num_unread?channel_types=io.pnut.core.pm" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    -H "X-Pretty-Json: 1"

Returns an array of all the channel types requested, with their corresponding number of unread messages.

{
    "meta": {
        "code": 200
    },
    "data": {
        "io.pnut.core.pm": 2
    }
}

DELETE /users/me/channels/num_unread

Token: user

Scope: messages

Mark all unread private messages as read for the authenticated user.

Query String Parameters

Name Description
channel_types Comma-separated list of channel types to mark as read. Up to 4 at a time.
Example
curl "https://api.pnut.io/v0/users/me/channels/num_unread?channel_types=io.pnut.core.pm" \
    -H "Authorization: Bearer ${ACCESS_TOKEN}" \
    -X DELETE \
    -H "X-Pretty-Json: 1"

Returns an array of the channel types and their new count of 0.

{
    "meta": {
        "code": 200
    },
    "data": {
        "io.pnut.core.pm": 0
    }
}