-
Notifications
You must be signed in to change notification settings - Fork 3
Improve the catalog response format #6
Comments
Another way to do this is by directly returning the items array (JSON Array) without the pagination object and attributes. The pagination attributes can still be responded in HTTP headers. Example: WordPressQuery parameters: GithubQuery parameters: |
Servers which respond with array of results inside an object: OGC SensorThingsQuery parameters: {
"value": [ ], // results
"@iot.nextLink":
"http://examples.org/v1.0/Things?$top=100&$skip=100"
} ConfluenceQuery parameters: {
"_links": {
"base": "http://localhost:8080/confluence",
"context": "",
"next": "/rest/api/space/ds/content/page?limit=5&start=5",
"self": "http://localhost:8080/confluence/rest/api/space/ds/content/page"
},
"limit": 5,
"results": [ ], // results
"size": 5,
"start": 0
} ElasticsearchQuery parameters: {
"hits" : {
"total" : {
"value" : 1
},
"hits" : [ ] // results
}
} OpenStackQuery parameters: {
"items": [ ], // results
"links": [
{
"rel": "self",
"href": "http://example.com/app/items?limit=30&marker=752b0b9997f24be49e5a1d89d1c53279",
},
{
"rel": "first",
"href": "http://example.com/app/items?limit=30",
},
{
"rel": "prev",
"href": "http://example.com/app/items?limit=30&marker=eff79f5b4f8743caa1f775846302c1d5",
},
{
"rel": "next",
"href": "http://example.com/app/items?limit=30&marker=08ec231f6d9a43dda97d4b950c3393df",
},
{
"rel": "last",
"href": "http://example.com/app/items?limit=30&marker=6835afb7ea29491bb2722c6c43f1f070",
}
]
} Azure Data FactoryQuery parameters: {
"data": [ ], // results
"paging": {
"cursors": {
"after": "MTAxNTExOTQ1MjAwNzI5NDE=",
"before": "NDMyNzQyODI3OTQw"
},
"previous": "https://graph.facebook.com/me/albums?limit=25&before=NDMyNzQyODI3OTQw",
"next": "https://graph.facebook.com/me/albums?limit=25&after=MTAxNTExOTQ1MjAwNzI5NDE="
}
} CouchDBQuery parameters: {
"total_rows":11,
"offset":0,
"rows":[ ] // results
} Google Calendar APIQuery parameters:
W3C HyrdaQuery parameters: {
"@id": "http://api.example.com/an-issue/comments?page=3",
"@type": "PagedCollection",
"firstPage": "/an-issue/comments",
"previousPage": "/an-issue/comments?page=2",
"nextPage": "/an-issue/comments?page=4",
"lastPage": "/an-issue/comments?page=498",
"member": [ ... ]
} |
We could also use the query language to navigate through resources. E.g.: This even enables navigation inside individual TDs. E.g. Edge cases to consider if we depend on query language for pagination:
|
The most recent WoT Discovery spec recommends the use of arrays as payload for listing of TDs: https://w3c.github.io/wot-discovery/#exploration-directory-api-registration-listing |
Implemented at |
The current API returns paginated catalog responses in paginated envelope with array of response items inside a JSON-LD object:
The pagination attributes are passed as
page
andper_page
query arguments defaulting topage=1
andper_page=100
. The maximum allowedper_page
value is set to 100 to reduce the load on server.We need to see if this needs improvements.
Some useful relevant specs / standards:
Parallel discussion in WoT Discovery: w3c/wot-discovery#16
The text was updated successfully, but these errors were encountered: