|
| 1 | +export const metadata = { |
| 2 | + title: "API Endpoints", |
| 3 | + description: "Explains all endpoints in Versia's federation API.", |
| 4 | +} |
| 5 | + |
| 6 | +# Endpoints |
| 7 | + |
| 8 | +## Well-known |
| 9 | + |
| 10 | +<Warning> |
| 11 | + This endpoint is exempt from the signature requirement. No signatures are required for requests or responses to it. |
| 12 | + |
| 13 | + The following `Accept` headers are also allowed for requests to this endpoint: |
| 14 | + - `application/jrd+json` |
| 15 | + - `application/json` |
| 16 | +</Warning> |
| 17 | + |
| 18 | +<Row> |
| 19 | + <Col> |
| 20 | + |
| 21 | + <Properties name="Well-known"> |
| 22 | + <Property name="endpoint"> |
| 23 | + Must be `/.well-known/versia`. |
| 24 | + </Property> |
| 25 | + <Property name="method"> |
| 26 | + Must be `GET`. |
| 27 | + </Property> |
| 28 | + <Property name="response"> |
| 29 | + A small JSON object with a single attribute: |
| 30 | + |
| 31 | + - `versions`: Supported Versia Protocol versions. |
| 32 | + - Versions marked as "Working Draft X" are represented as `0.X`. |
| 33 | + </Property> |
| 34 | + </Properties> |
| 35 | + |
| 36 | + </Col> |
| 37 | + <Col sticky> |
| 38 | + |
| 39 | + ```http {{ 'title': 'Example request' }} |
| 40 | + GET /.well-known/versia |
| 41 | + Host: b.social |
| 42 | + Accept: application/jrd+json |
| 43 | + ``` |
| 44 | + |
| 45 | + ```http {{ 'title': 'Example response' }} |
| 46 | + HTTP/1.1 200 OK |
| 47 | + Content-Type: application/jrd+json |
| 48 | +
|
| 49 | + { |
| 50 | + "versions": [ |
| 51 | + "0.6.0", |
| 52 | + "0.5.0" |
| 53 | + ] |
| 54 | + } |
| 55 | + ``` |
| 56 | + |
| 57 | + </Col> |
| 58 | +</Row> |
| 59 | + |
| 60 | +## Instance metadata |
| 61 | + |
| 62 | +<Warning> |
| 63 | + This endpoint is exempt from the signature requirement. No signatures are required for requests or responses to it. |
| 64 | +</Warning> |
| 65 | + |
| 66 | +<Row> |
| 67 | + <Col> |
| 68 | + |
| 69 | + <Properties name="InstanceMetadata"> |
| 70 | + <Property name="endpoint"> |
| 71 | + Must be `/.versia/v0.6/instance`. |
| 72 | + </Property> |
| 73 | + <Property name="method"> |
| 74 | + Must be `GET`. |
| 75 | + </Property> |
| 76 | + <Property name="response"> |
| 77 | + Instance's metadata, as defined in the [Instance Metadata](/entities/instance-metadata) document. |
| 78 | + </Property> |
| 79 | + </Properties> |
| 80 | + |
| 81 | + </Col> |
| 82 | + <Col sticky> |
| 83 | + |
| 84 | + ```http {{ 'title': 'Example request' }} |
| 85 | + GET /.versia/v0.6/instance |
| 86 | + Host: b.social |
| 87 | + Accept: application/vnd.versia+json |
| 88 | + ``` |
| 89 | + |
| 90 | + ```http {{ 'title': 'Example response' }} |
| 91 | + HTTP/1.1 200 OK |
| 92 | + Content-Type: application/vnd.versia+json; charset=utf-8 |
| 93 | +
|
| 94 | + { |
| 95 | + "type": "InstanceMetadata", |
| 96 | + "name": "Bob!!", |
| 97 | + // ... |
| 98 | + } |
| 99 | + ``` |
| 100 | + |
| 101 | + </Col> |
| 102 | +</Row> |
| 103 | + |
| 104 | +## Entity data |
| 105 | + |
| 106 | +<Row> |
| 107 | + <Col> |
| 108 | + <Properties name="EntityData"> |
| 109 | + <Property name="endpoint"> |
| 110 | + Must be `/.versia/v0.6/entities/{entity_type}/{id}`. |
| 111 | + |
| 112 | + - `{entity_type}`: The type of the entity to fetch, URL-encoded. |
| 113 | + - `{id}`: The ID of the entity to fetch, URL-encoded. |
| 114 | + |
| 115 | + Example: `GET /.versia/v0.6/entities/pub.versia%3Agroups%2FGroup/1234` fetches the [Group](/extensions/groups) entity with ID `1234`. |
| 116 | + </Property> |
| 117 | + <Property name="method"> |
| 118 | + Must be `GET`. |
| 119 | + </Property> |
| 120 | + <Property name="response"> |
| 121 | + Entity data as JSON, as defined in its [Entity](/entities) definition document. |
| 122 | + </Property> |
| 123 | + </Properties> |
| 124 | + </Col> |
| 125 | + |
| 126 | + <Col sticky> |
| 127 | + |
| 128 | + ```http {{ 'title': 'Example request' }} |
| 129 | + GET /.versia/v0.6/entities/user/1234 |
| 130 | + Host: b.social |
| 131 | + Accept: application/vnd.versia+json |
| 132 | + ``` |
| 133 | + |
| 134 | + ```http {{ 'title': 'Example response' }} |
| 135 | + HTTP/1.1 200 OK |
| 136 | + Content-Type: application/vnd.versia+json; charset=utf-8 |
| 137 | +
|
| 138 | + { |
| 139 | + "type": "User", |
| 140 | + "id": "1234", |
| 141 | + // ... |
| 142 | + } |
| 143 | + ``` |
| 144 | + </Col> |
| 145 | +</Row> |
| 146 | + |
| 147 | +## Entity collections |
| 148 | + |
| 149 | +<Row> |
| 150 | + <Col> |
| 151 | + <Properties name="EntityCollection"> |
| 152 | + <Property name="endpoint"> |
| 153 | + Must be `/.versia/v0.6/entities/{entity_type}/{id}/collections/{collection_type}`. |
| 154 | + |
| 155 | + - `{entity_type}`: The type of the entity to fetch, URL-encoded. |
| 156 | + - `{id}`: The ID of the entity to fetch, URL-encoded. |
| 157 | + - `{collection_type}`: The type of the collection to fetch, URL-encoded. |
| 158 | + |
| 159 | + Example: `GET /.versia/v0.6/entities/User/1234/collections/followers` fetches the followers of the user with ID `1234`. |
| 160 | + </Property> |
| 161 | + <Property name="method"> |
| 162 | + Must be `GET`. |
| 163 | + </Property> |
| 164 | + <Property name="response"> |
| 165 | + Must be either a [Collection](/structures/collection) or a [URICollection](/structures/collection#uri-collection) as JSON. |
| 166 | + </Property> |
| 167 | + </Properties> |
| 168 | + </Col> |
| 169 | + |
| 170 | + <Col sticky> |
| 171 | + |
| 172 | + ```http {{ 'title': 'Example request' }} |
| 173 | + GET /.versia/v0.6/entities/user/1234/collections/followers |
| 174 | + Host: b.social |
| 175 | + Accept: application/vnd.versia+json |
| 176 | + ``` |
| 177 | + |
| 178 | + ```http {{ 'title': 'Example response' }} |
| 179 | + HTTP/1.1 200 OK |
| 180 | + Content-Type: application/vnd.versia+json; charset=utf-8 |
| 181 | +
|
| 182 | + { |
| 183 | + "type": "Followers", |
| 184 | + "id": "1234", |
| 185 | + // ... |
| 186 | + } |
| 187 | + ``` |
| 188 | + </Col> |
| 189 | +</Row> |
| 190 | + |
| 191 | +### Pagination |
| 192 | + |
| 193 | +Collections MUST support pagination, using the following URI parameters: |
| 194 | + |
| 195 | +- `offset`: The number of items to skip before returning the first item. This is a zero-based index. |
| 196 | +- `limit`: The maximum number of items to return. This is a one-based index. Implementations MUST support a minimum of `1` and a maximum of `40` items. |
| 197 | + |
| 198 | +```http {{ 'title': 'Example paginated collection request' }} |
| 199 | +GET /.versia/v0.6/entities/user/1234/collections/followers?offset=10&limit=20 |
| 200 | +Host: b.social |
| 201 | +Accept: application/vnd.versia+json |
| 202 | +``` |
| 203 | + |
| 204 | +## Inbox |
| 205 | + |
| 206 | +The inbox endpoint is used for instances to send entities to each other. It is a single endpoint that can receive messages for every user (also known as a shared inbox). |
| 207 | + |
| 208 | +The delivery mechanism is described further in the [Federation](/federation#inboxes) document. |
| 209 | + |
| 210 | +<Row> |
| 211 | + <Col> |
| 212 | + <Properties name="Inbox"> |
| 213 | + <Property name="endpoint"> |
| 214 | + Must be `/.versia/v0.6/inbox`. |
| 215 | + </Property> |
| 216 | + <Property name="method"> |
| 217 | + Must be `POST`. |
| 218 | + </Property> |
| 219 | + </Properties> |
| 220 | + </Col> |
| 221 | + |
| 222 | + <Col sticky> |
| 223 | + |
| 224 | + ```http {{ 'title': 'Example request' }} |
| 225 | + POST /.versia/v0.6/inbox |
| 226 | + Host: b.social |
| 227 | + Accept: application/vnd.versia+json |
| 228 | + Content-Type: application/vnd.versia+json; charset=utf-8 |
| 229 | +
|
| 230 | + { |
| 231 | + "type": "Note", |
| 232 | + "id": "1234", |
| 233 | + ... |
| 234 | + } |
| 235 | + ``` |
| 236 | + |
| 237 | + </Col> |
| 238 | +</Row> |
0 commit comments