@@ -1214,88 +1214,6 @@ using an `unstable` version.
12141214When this capability is not listed, clients should use ` "1" ` as the
12151215default and only stable ` available ` room version.
12161216
1217- ## Pagination
1218-
1219- {{% boxes/note %}}
1220- The paths referred to in this section are not actual endpoints. They
1221- only serve as examples to explain how pagination functions.
1222- {{% /boxes/note %}}
1223-
1224- Pagination is the process of dividing a dataset into multiple discrete
1225- pages. Matrix makes use of pagination to allow clients to view extremely
1226- large datasets. These datasets are not limited to events in a room (for
1227- example clients may want to paginate a list of rooms in addition to
1228- events within those rooms). Regardless of what is being paginated, there
1229- is a common approach which is used to give clients an easy way of
1230- selecting subsets of a potentially changing dataset. Each endpoint that
1231- uses pagination may use different parameters. However the theme among
1232- them is that they take a ` from ` and ` to ` token, and occasionally a
1233- ` limit ` and ` dir ` . Together, these parameters describe the position in a
1234- data set, where ` from ` and ` to ` are known as "stream tokens" matching
1235- the regular expression ` [a-zA-Z0-9.=_-]+ ` . If supported, the ` dir `
1236- defines the direction of events to return: either forwards (` f ` ) or
1237- backwards (` b ` ). The response may contain tokens that can be used for
1238- retrieving results before or after the returned set. These tokens may be
1239- called <span class =" title-ref " >start</span > or <span
1240- class="title-ref">prev\_ batch</span > for retrieving the previous result
1241- set, or <span class =" title-ref " >end</span >, <span
1242- class="title-ref">next\_ batch</span > or <span
1243- class="title-ref">next\_ token</span > for retrieving the next result set.
1244-
1245- In the following examples, 'START' and 'END' are placeholders to signify
1246- the start and end of the data sets respectively.
1247-
1248- For example, if an endpoint had events E1 -> ; E15. The client wants
1249- the last 5 events and doesn't know any previous events:
1250-
1251- ```
1252- S E
1253- |-E1-E2-E3-E4-E5-E6-E7-E8-E9-E10-E11-E12-E13-E14-E15-|
1254- | | |
1255- | _____| <--backwards-- |
1256- |__________________ | | ________|
1257- | | | |
1258- GET /somepath?to=START&limit=5&dir=b&from=END
1259- Returns:
1260- E15,E14,E13,E12,E11
1261- ```
1262-
1263- Another example: a public room list has rooms R1 -> ; R17. The client
1264- is showing 5 rooms at a time on screen, and is on page 2. They want to
1265- now show page 3 (rooms R11 -> ; 15):
1266-
1267- ```
1268- S E
1269- | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | stream token
1270- |-R1-R2-R3-R4-R5-R6-R7-R8-R9-R10-R11-R12-R13-R14-R15-R16-R17| room
1271- |____________| |________________|
1272- | |
1273- Currently |
1274- viewing |
1275- |
1276- GET /roomslist?from=9&to=END&limit=5
1277- Returns: R11,R12,R13,R14,R15
1278- ```
1279-
1280- Note that tokens are treated in an * exclusive* , not inclusive, manner.
1281- The end token from the initial request was '9' which corresponded to
1282- R10. When the 2nd request was made, R10 did not appear again, even
1283- though from=9 was specified. If you know the token, you already have the
1284- data.
1285-
1286- Responses for pagination-capable endpoints SHOULD have a ` chunk ` array
1287- alongside the applicable stream tokens to represent the result set.
1288-
1289- In general, when the end of a result set is reached the applicable
1290- stream token will be excluded from the response. For example, if a user
1291- was backwards-paginating events in a room they'd eventually reach the
1292- first event in the room. In this scenario, the ` prev_batch ` token would
1293- be excluded from the response. Some paginated endpoints are open-ended
1294- in one direction, such as endpoints which expose an event stream for an
1295- active room. In this case, it is not possible for the client to reach
1296- the true "end" of the data set and therefore should always be presented
1297- with a token to keep moving forwards.
1298-
12991217## Filtering
13001218
13011219Filters can be created on the server and can be passed as a parameter to
0 commit comments