How to optimize the API response package

  • Paginate responses into batches of content that are easily browsable, because they are segmented into set numbers (10 per page, 20 per page, etc), limited (say only the first 1,000 entries are paginated), and standardized (using ‘next’, ‘last’ etc for cursor navigation).
  • Offer filtering of results according to parameters specified by the requester. This reduces the calls made and results displayed as well as limits the resources fed to the user, resulting in tangible optimization and better user experience. Do this while keeping in mind that overly complex filtering can work against optimization.
  • Use ranges to restrict results based on a user-specified structure, so that only specific elements within the range are considered applicable for the request to execute. This lets you offload data processing from the client-side to the server.
  • Avoid over-fetching and under-fetching, which can result from poorly formed requests or badly implemented scaling techniques.

Full post here, 12 mins read