Restful API - handling large amounts of data

Viewed 89721

I have written my own Restful API and am wondering about the best way to deal with large amounts of records returned from the API.

For example, if I use GET method to myapi.co.uk/messages/ this will bring back the XML for all message records, which in some cases could be 1000's. This makes using the API very sluggish.

Can anyone suggest the best way of dealing with this? Is it standard to return results in batches and to specify batch size in the request?

3 Answers

There are different ways in general by which one can improve the API performance including for large API sizes. Each of these topics can be explored in depth.

  • Reduce Size Pagination
  • Organizing Using Hypermedia
  • Exactly What a User Need With Schema Filtering
  • Defining Specific Responses Using The Prefer Header
  • Using Caching To Make Response
  • More Efficient More Efficiency Through Compression
  • Breaking Things Down With Chunked Responses
  • Switch To Providing More Streaming Responses
  • Moving Forward With HTTP/2

Source: https://apievangelist.com/2018/04/20/delivering-large-api-responses-as-efficiently-as-possible/

if you are using .net core you have to try this magic package

Microsoft.AspNetCore.ResponseCompression

then use this line in configureservices in startup file

services.AddResponseCompression();

then in configure function

app.UseResponseCompression();

Related