Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > ASPRunner.NET's REST API

REST API: list

Scroll Prev Next More

 

Returns a list of records via GET request.
 

Arguments
 

table

the table name.

action

list

records

 

how many records to return

Example: show me first 10 customers.

 

http://localhost:8086/api/v1?table=customers&action=list&records=10

 

skip

 

how many records to skip (pagination)

Example: show me customers all customers starting with number 11.

 

http://localhost:8086/api/v1?table=customers&action=list&skip=10

 

q

 

search

Example: show me all customers from Germany.

 

http://localhost:8086/api/v1?table=customers&action=list&q=(Country~equals~Germany)

 

To figure out the correct syntax create a simple app in ASPRunner.NET pointing to the same table. Proceed to the Advanced Search page and run the required search. Notice the q parameter in the URL, use the same parameter value in your list operation REST request to filter data.

 

qs

 

all fields search

Example: show me all customers where any field contains Allen.

 

http://localhost:8086/api/v1?table=customers&action=list&records=10&skip=10&qs=Allen

 

Sample request URL

 

curl "http://localhost:8086/api/v1?table=customers&action=list"  

 

Sample response

 

{  
"data": [  
   {  
    "CustomerID": "ANATR",  
    "CompanyName": "",  
    "ContactName": "Morris H Deutsch",  
    "ContactTitle": "",  
    "Address": "8799 Knollwood dr",  
    "City": "Eden Prairie",  
    "Region": "MN",  
    "PostalCode": "55347",  
    "Country": "United States",  
    "Phone": "2027280820",  
    "Fax": "(5) 555-3745",  
    "Lat": "44.8436452000",  
    "Lng": "-93.4535225000"  
   },  
   {  
    "CustomerID": "ANTON",  
    "CompanyName": "Antonio Moreno Taqueria",  
    "ContactName": "Antonio Moreno",  
    "ContactTitle": "Owner",  
    "Address": "Mataderos 2312",  
    "City": "Mexico",  
    "Region": "",  
    "PostalCode": "33333",  
    "Country": "Mexico",  
    "Phone": "(5) 555-3932",  
    "Fax": "",  
    "Lat": "32.5053534000",  
    "Lng": "-117.0668113000"  
   }  
],  
"success": true  
 
}  

 

Sample code

 

This code connects to the REST API, retrieves all records from the customers table and displays results.

 

PHP:

 

<?php

$curl = curl_init();
curl_setopt_array($curl, array(
 CURLOPT_URL => "http://localhost:8086/api/v1.php?table=customers&action=list",
 CURLOPT_RETURNTRANSFER => true,
 CURLOPT_ENCODING => "",
 CURLOPT_MAXREDIRS => 10,
 CURLOPT_TIMEOUT => 0,
 CURLOPT_FOLLOWLOCATION => true,
 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
 CURLOPT_CUSTOMREQUEST => "GET",
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>

 

C# (RestSharp):

 

var client = new RestClient("http://localhost:8086/api/v1.php?table=customers&action=list");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

 

JavaScript (jQuery):

 

var settings = {
"url": "http://localhost:8086/api/v1.php?table=customers&action=list",
"method": "GET",
"timeout": 0,
};
 
$.ajax(settings).done(function (response) {
 console.log(response);
});