Episode #4

APIs On Rails: Add pagination to a JSON REST API

Published on: Feb 03, 2017 | Video length: 12 minutes

Show Notes

In this episode I will show you how to add pagination to an index API in the api-only Rails application that we created in Episode #3 . Also, the application will be run on docker using docker compose. I will be using Kaminari gem to implement pagination.

There are two approaches to add pagination data in the API response - first is to add the pagination metadata (total count, links to the next, previous, first, last page etc) in the JSON response body and the second approach using http response headers. My preference is http response header which is explained in this video.