RESTp - GET request example Rest API to perform GET operation

This request is used to get a resource from a server e.g. list of records from table or a particular record. If you perform a `GET` request (basically Read request), the server looks for the data you requested and sends it back to you. Using RESTp, you can easily get data from a particular table or a particular record from table by specifying the where conditions. You can easily pass multiple parameters of different types, like where condition, group by, order by, pagination etc. to get required resource. RESTp select function provides a simplest way to select the data into database by passing the data in form of associative array. You need to pass table name and array of data and operation name in a particular format and rest will be managed by the script. On success, it returns the primary key value of record selected.

Example request URIs

  1. // Get all records from table
    GET http://pdocrud.com/RESTP/api/{table_name}/
  2. // Get record from table with primary key value
    GET http://pdocrud.com/RESTP/api/{table_name}/{pk_value}
  3. // Get records from table with column name and value
    GET http://pdocrud.com/RESTP/api/{table_name}/{col_name}/{col_value}
  4. // Get records from table with various parameter like order by, group by etc.
    GET http://pdocrud.com/RESTP/api/{table_name}/?orderby={colname+desc}&groupby={colname}&limit=0,10
  5. // Get records from table with where condition.
    GET curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/?where={colname},{val},{operator},{and_or},{brackets)");
  6. // Get records from table with complex set of parameters
    // You can pass complex set of data directly as parameters in url get parameter
    // or you can use http_build_query() function to generate url encoded string
    // $data = array("where" => array(array("operartor" => "=", "ID" => 42)), "orderby" => array("order_amount asc", "order_status desc"), "groupby" => array("order_status")); $data = http_build_query($data);
    GET http://pdocrud.com/RESTP/api/{table_name}/?$data

  
                            //init curl
                            $ch = curl_init();
                             //set http headers
                            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

                            // URL to be called i.e. end point to access resource. 
                            // Example 1
                            curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/");
                            // Example 2
                            //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/39");
                            // Example 3
                            //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/order_no/578");
                            // Example 4 - both are valid format
                            //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders?orderby[]=order_no+desc&groupby[]=order_status&limit=0,10");
                            //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders?orderby=order_no+desc&groupby=order_status&limit=0,10");
                            // Example 5
                            //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/?where=order_no,2222");
                            //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/?where=order_no,2222,eq");
                            //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/?where[]=order_no,2222:76778,bt");
                            //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders/?where[]=order_no,2222,eq,and,(&where[]=order_no,76778,eq,or&where[]=order_no,2222,eq,,)");
                            // Example 6

                            //$data = array("where" => array('order_no,2222,"eq"'),
                            //  "orderby" => array("order_amount asc", "order_status desc"),
                            //   "groupby" => array("order_status"));
                            //$data = http_build_query($data);

                            //curl_setopt($ch, CURLOPT_URL, "http://pdocrud.com/RESTP/api/orders?".$data);
                            //return as output instead of printing it
                            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                            //execute curl request
                            $result = curl_exec($ch);
                            //close curl connection
                            curl_close($ch);
                            //print result
                            print_r($result);
                        
{"message":"Operation done successfully","error":null,"data":[{"ID":"162","order_no":"0","order_date":"0000-00-00","customer_name":"Cooper Jensen test","order_amount":"0","order_status":"1"},{"ID":"172","order_no":"20","order_date":"2025-08-20","customer_name":"Testing Testing","order_amount":"5","order_status":"6"},{"ID":"173","order_no":"33","order_date":"2025-09-02","customer_name":"Deacon Tyson","order_amount":"111","order_status":"Completed"},{"ID":"174","order_no":"0","order_date":"0000-00-00","customer_name":"Cooper Jensen","order_amount":"0","order_status":""},{"ID":"175","order_no":"25","order_date":"2025-09-17","customer_name":"Xenos Clarke","order_amount":"111","order_status":"ok"},{"ID":"176","order_no":"0","order_date":"0000-00-00","customer_name":"","order_amount":"0","order_status":""},{"ID":"177","order_no":"122","order_date":"2025-09-03","customer_name":"OIU","order_amount":"100","order_status":"OK"},{"ID":"178","order_no":"33","order_date":"2025-09-02","customer_name":"Deacon Tyson","order_amount":"111","order_status":"ok"},{"ID":"179","order_no":"33","order_date":"2025-09-02","customer_name":"Deacon Tyson","order_amount":"111","order_status":"ok"},{"ID":"180","order_no":"1","order_date":"2025-07-01","customer_name":"Xenos Clarke","order_amount":"82325","order_status":"Pending"},{"ID":"181","order_no":"1","order_date":"2025-07-01","customer_name":"Xenos Clarke","order_amount":"82325","order_status":"Pending"},{"ID":"182","order_no":"1","order_date":"2025-07-01","customer_name":"Xenos Clarke","order_amount":"82325","order_status":"Pending"},{"ID":"183","order_no":"2000","order_date":"2025-09-24","customer_name":"CLOUDS","order_amount":"100","order_status":"Placed"},{"ID":"184","order_no":"576749678","order_date":"2025-09-03","customer_name":"asdas","order_amount":"798797","order_status":"asdas"}]}