Channel Lookup
Endpoints:
- Get a channel
- Get multiple channels
- Get the authenticated user's created channels
- Get a PM channel between users
- Get the number of channels unread by the authenticated user
- Set all channels 'read'
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
.
GET /channels/{channel_id}
Scope:
Retrieve a channel object.
URL Parameters
Name | Description |
---|---|
channel_id |
ID of the requested channel |
Example
curl "https://api.pnut.io/v1/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:
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/v1/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:
Scope:
Retrieve a list of channels created by the authenticated user.
Example
curl "https://api.pnut.io/v1/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:
Scope:
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/v1/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:
Scope:
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. Defaults to io.pnut.core.pm |
Example
curl "https://api.pnut.io/v1/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:
Scope:
Mark all unread messages as read for the specified channel types 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. Defaults to io.pnut.core.pm |
Example
curl "https://api.pnut.io/v1/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
}
}