I am defining a simple REST API to run a query and get the results with *pagination*. I would like to make both client and server stateless if possible.

The client sends the query, `offset` and `length`. The server returns the results. For example, if there are 1000 results and client sends `offset` = 10 and `length` = 20, the server either returns 20 results since #10 till #29 if the total number of the results >= 30 or all results since #10 if the total < 30.

Client also needs to know to the total number of the results. Since I would like to keep both client and server stateless the server will always return `total` with the results.

So the protocol looks like following:

```
Client: query, offset, length ----------->
                               <----------- Server: total, results

```

The `offset` and `length` can be defined *optional*. If `offset` is missing the server assumes it is 0. If `length` is missing the server returns all the results.

Does it make sense ? How would you suggest define such a protocol ?