Skip to content

Commit 124919e

Browse files
annotation docs
1 parent 21c344e commit 124919e

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed

src/pages/docs/api/rest-api.mdx

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,135 @@ In each case a successful result is a [paginated response](#pagination) with an
595595
```
596596
</Code>
597597

598+
### Retrieve metadata for a channel <a id="metadata-rest" />
599+
600+
#### GET rest.ably.io/channels/\{channelId\}
601+
602+
This returns a [ChannelDetails](/docs/api/realtime-sdk/channel-metadata#channel-details) for the given channel, indicating global [occupancy](/docs/api/rest-sdk/channel-status#occupancy). A side-effect of this request, in the current version of this API, is that it will cause the channel in question to become activated; therefore it is primarily intended to be used in conjunction with the [enumeration API](#enumeration-rest) or in situations where the application has another means to know whether or not a given channel is active.
603+
604+
### Enumerate all active channels <a id="enumeration-rest" />
605+
606+
#### GET rest.ably.io/channels
607+
608+
This enumerates all active channels in the application. This is a paginated API following the same API conventions as other paginated APIs in the [REST interface](/docs/api/rest-sdk).
609+
610+
### Publish annotations for a message <a id="annotations-publish" />
611+
612+
#### POST rest.ably.io/channels/\{channelId\}/messages/\{messageSerial\}/annotations
613+
614+
Publish one or more [annotations](/docs/messages/annotations) for a specific message identified by its serial in the `messageSerial` url param. All annotations in a single request are published atomically and must be for the same message.
615+
616+
See [our main annotation docs](/docs/messages/annotations) for more information on annotations.
617+
618+
The request body contains an array of annotation objects:
619+
620+
<Code>
621+
```json
622+
[{
623+
action: <number; 0 is create, 1 is delete>,
624+
type: <string, specifies how this annotation should be aggregated>,
625+
name: <optional string, arbitrary string that many aggregation types use to group by>,
626+
count: <optional number, used with the 'multiple' aggregation type>,
627+
id: <optional string, client-specified idempotency key>,
628+
clientId: <optional string, explicit client identifier>,
629+
data: <optional JSON-encodable data>,
630+
encoding: <optional string, encoding if specifying manually>,
631+
extras: <optional extras object>
632+
}]
633+
```
634+
</Code>
635+
636+
In JSON format, the accepted types for the `data` payload are:
637+
638+
* string
639+
* any JSON-encodable Array or Object.
640+
641+
MessagePack additionally [supports byte arrays](https://github.com/msgpack/msgpack/blob/master/spec.md#formats-bin)
642+
643+
For annotation types and aggregation details, see [annotation types](/docs/messages/annotations#annotation-types).
644+
645+
The message extras object is the same as for a message publish, see [message extras](#message-extras).
646+
647+
The id is the same as for a message publish, see [idempotent publishing](#idempotent-publish)
648+
649+
Example request:
650+
651+
<Code>
652+
```shell
653+
curl -X POST https://rest.ably.io/channels/mutable:channel/messages/01726585978590-001@abcdefghij:001/annotations \
654+
-u "{'{{API_KEY}}'}"{""} \
655+
-H "Content-Type: application/json" \
656+
--data '[{ "action": 0, "type": "reaction:distinct.v1", "name": ":thumbsup:" }]'
657+
```
658+
</Code>
659+
660+
##### Parameters
661+
662+
None
663+
664+
##### Options
665+
666+
| Option | Value |
667+
|--------|-------|
668+
| Content-Type | `application/json` or `application/x-msgpack` |
669+
| Accept | `application/json` (the default), `application/x-msgpack` |
670+
| Auth required | yes ([basic](#basic-authentication) or [token](#token-authentication)) |
671+
672+
##### Returns
673+
674+
When successful, returns status code 201 and an object with annotation details. When unsuccessful, returns an error as an [ErrorInfo](/docs/api/rest-sdk/types#error-info) object.
675+
676+
### Retrieve all annotations for a message <a id="annotations-list" />
677+
678+
#### GET rest.ably.io/channels/\{channelId\}/messages/\{messageSerial\}/annotations
679+
680+
Retrieve all annotations that have been published for a specific message identified by its serial, starting from the earliest.
681+
682+
Example request:
683+
684+
<Code>
685+
```shell
686+
curl https://rest.ably.io/channels/rest-example/messages/01726585978590-001@abcdefghij:001/annotations?limit=100 \
687+
-u "{'{{API_KEY}}'}"{""}
688+
```
689+
</Code>
690+
691+
##### Parameters
692+
693+
| Parameter | Description | Type |
694+
|-----------|-------------|------|
695+
| limit | The maximum number of records to return per page. A limit greater than 1,000 is invalid. Default: _100_ | integer |
696+
697+
##### Options
698+
699+
| Option | Value |
700+
|--------|-------|
701+
| Accept | `application/json` by default, or `application/x-msgpack` |
702+
| Auth required | yes ([basic](#basic-authentication) or [token](#token-authentication)) |
703+
704+
##### Returns
705+
706+
A successful request returns a [paginated response](#pagination) with an array containing the annotations for the specified message, starting from the first one to have been published for that message. If there are no annotations, an empty collection is returned.
707+
708+
<Code>
709+
```json
710+
[{
711+
action: <number; 0 for create, 1 for delete>,
712+
serial: <unique serial of this annotation>,
713+
id: <idempotency key>,
714+
timestamp: <annotation timestamp in ms since epoch>
715+
messageSerial: <the serial of the message that is being annotated>
716+
type: <annotation type>,
717+
name: <optional string>,
718+
count: <optional number>,
719+
clientId: <optional client identifier>,
720+
data: <optional annotation payload>,
721+
encoding: <optional encoding of the payload>,
722+
extras: <optional extras object>,
723+
}]
724+
```
725+
</Code>
726+
598727
### Retrieve instantaneous presence status for a channel <a id="presence" />
599728

600729
#### GET main.realtime.ably.net/channels/\{channelId\}/presence

0 commit comments

Comments
 (0)