how to do pagination in RESTFUL API in a effective way?
<p>I want to support pagination in my RESTful API.</p>

<p>My API method should return a JSON list of product via <a href="http://localhost/products/v1/getproductsbycategory" rel="nofollow">http://localhost/products/v1/getproductsbycategory</a>, there are potentially thousands of products, and I want to page through them, so my request should look something like this:</p>

<pre><code>public function getProductsByCategory($product_id,$page){
                $perPage=5;
                $start=($page-1)*$perPage;
                $stmt=$this-&gt;conn-&gt;prepare("SELECT id,product,description,destination_url,expiry_type,savings,expiry,title,last_updated_on  FROM products   WHERE product_id=?   ORDER BY  last_updted_on DESC LIMIT $start ,$perPage");
                $stmt-&gt;bind_param('i',$category_id);
                $stmt-&gt;execute();
                $productbycategory=$stmt-&gt;get_result();
                $stmt-&gt;close();
                return $productbycategory;
      }

      }
</code></pre>