G
G
GaserV2017-04-09 02:13:19
API
GaserV, 2017-04-09 02:13:19

Is it possible to implement pagination for API?

Hi all! I came across an interesting thing. What if the number of, say, news returned from the API will be more than 1000 for example? From the point of view of optimization, it would probably be more correct to give 20-30 of which, for example, per request. So. Is it possible and if so, how to implement such a feature so that 100500 news items are not returned at once, but are returned in small parts. And how in this case to implement the front? When flipping pages, send a request for the next batch of news or what?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
entermix, 2017-04-09
@entermix

Is it possible and if so, how to implement such a feature so that 100500 news items are not returned at once, but are returned in small parts.

Use the LIMIT statement:
The query will return 5 records (5-10 inclusive)
Yes

I
index0h, 2017-04-09
@index0h

What you are looking for is called pagination. Take two optional parameters: uint page and uint perPage. In the first page number, in the second - the number of records per page, respectively. Don't forget about validation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question