Skip to content

geekahmed/API-Design-Patterns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

This is my summary of the API design patterns, by JJ Geewax. Contributions: Issues, comments and pull requests are super welcome 😃

Table of Contents

Chapter 21. Pagination

Summary

  • Pagination allows large collections of results (or large single resources) to be consumed in a series of bite-sized chunks rather than as a single large API response using three special fields: maxPageSize , pageToken , and nextPageToken .
  • If there are more pages, a response will include a nextPageToken value, which can be provided in the pageToken field of a subsequent request to get the next page.
  • We rely on a maximum page size rather than an exact page size as we don’t know how long it will take to fill a page exactly and must reserve the ability to return even before a page of results is fully populated.
  • Paging is complete when a response has no value for the next page token (not when the results field is empty).

Exercises

  • Why is it important to use a maximum page size rather than an exact page size?
  • What should happen if the page size field is left blank on a request? What if it’s negative? What about zero? What about a gigantic number?
  • How does a user know that pagination is complete?
  • Is it reasonable for page tokens for some resource types to have different expirations than those from other resource types?
  • Why is it important that page tokens are completely opaque to users? What’s a good mechanism to enforce this?

About

API Design Patterns Book by JJ Geewax. Notes and solutions to exercises.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published