<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">btw. GitHub api<a href="https://developer.github.com/guides/traversing-with-pagination/" style="color:#3983C4">1</a> just provide the links and the approach to get number of pages is this:</p>

<p dir="auto"><code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">number_of_pages = last_response.rels[:last].href.match(/page=(\d+).*$/)</code></p>

<p dir="auto">which aren't that bad imo if the <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">page</code> parameter is json spec too.</p>

<p dir="auto"></p></div>
<div style="white-space:pre-wrap"></div>
<blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px">

<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">On 3 Oct 2016, at 14:42, Thomas Mäder wrote:</p>

<p dir="auto"></p></div>
<div style="white-space:pre-wrap"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><div dir="auto">Hi folks,
</div><div dir="auto">
</div><div dir="auto">I'm in the middle of solving <a href="https://github.com/almighty/almighty-core/issues/329" style="color:#777">https://github.com/almighty/almighty-core/issues/329</a> . Jsonapi.org has some recommendations about this: <a href="http://jsonapi.org/format/#fetching-pagination" style="color:#777">http://jsonapi.org/format/#fetching-pagination</a>.
</div><div dir="auto">
</div><div dir="auto">What they recommend is adding "next", "prev" and "last" links to a "links" object on the top level of the response document.
</div></blockquote></div>
<div style="white-space:normal">

<p dir="auto">This sounds right. Makes it easy to make iteration of json docs until there are no "next" links more.</p>

<p dir="auto"></p></div>
<div style="white-space:pre-wrap"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><div dir="auto">The client then must compute how many pages there are and the size of the pages by parsing the uri's.
</div></blockquote></div>
<div style="white-space:normal">

<p dir="auto">Do we have a requirement for knowing the exact number of pages ?</p>

<p dir="auto"></p></div>
<div style="white-space:pre-wrap"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><div dir="auto">This seems wrong to me: I expect the front end to always limit the result set anyway. In this case, returning the total count seems much simpler to me for both the back end and clients. The count could be returned as a header or as a filed in the result json object.
</div></blockquote></div>
<div style="white-space:normal">

<p dir="auto">I see that on <a href="http://jsonapi.org/examples/#pagination" style="color:#3983C4">http://jsonapi.org/examples/#pagination</a> they mention using a <code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0 0.4em" bgcolor="#F7F7F7">total-pages</code> meta attribute. <br>
That is not by api but implementation specific - but sounds as good approach. UI just shouldn't rely on it always being there.</p>

<p dir="auto"></p></div>
<div style="white-space:pre-wrap"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><div dir="auto">Opinions (especially of our consumers) would be appreciated.
</div></blockquote></div>
<div style="white-space:normal">

<p dir="auto">The only place I can think of it being relevant is in the UI to be able to show a "page navigation" bar or something similar. </p>

<p dir="auto">/max<br>
<a href="http://about.me/maxandersen" style="color:#3983C4">http://about.me/maxandersen</a></p>
</div>
</div></blockquote>
<div style="white-space:normal">
</div>
<div style="white-space:normal">

<p dir="auto">/max<br>
<a href="http://about.me/maxandersen" style="color:#3983C4">http://about.me/maxandersen</a></p>
</div>
</div>
</body>
</html>