'In REST what is the effective approach to design pagination in nested resources? [closed]
Let us imagine we have a domain structure as follows Ledger can have one or more logs, each logs has different types and ledger itself has a type.
Office ----< Department ---< Ledger (name, type) ---- < Logs (message, time)
We need to filter specific type of logs during a time range and return responses grouped by department.
Request parameters (log_type, from_time, to_time)
Possibly the response would look like
Ledger_Statement
Office_id,
Department_id,
Ledger :
[List
(Logs : [List])
]
We can assume that it is possible to load the relevant data by querying only the on logs table and load by page
How can I map the pagination to the response I have mentioned above, What could be the design approach in such a case?
Solution 1:[1]
The Link Relations Registry includes entries for first
, previous
, next
, and last
that can be used to indicate to clients which identifiers to use to navigate the pagination protocol.
The URI spelling doesn't matter at all, but if can be convenient to encode into the identifier the parameters that the server will need to generate the correct page.
If your "pages" of information are something like a timeline, then the Twitter timeline documentation may offer you insights into how you might prefer to organize the information and which parameters you need to acquire the desired page of data.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |