These are parameters sent within the URL itself. Essentially each call you make will have a different URL as its endpoint, depending on what you are trying to do.
/* Example URL To fetch a list of system administrators. */
$url = 'https://www.alphatouch.info/v1/administrator/list';
/* Example URL To fetch a specific resident by their ID. */
$url = 'https://www.alphatouch.info/v1/resident/get/RESIDENT_ID';
These are parameters sent via the header of the request. Essentially only the API Key is sent through the Header Parameters.
curl_setopt($ch, CURLOPT_HTTPHEADER, array (
"api-key: UNIQUE_API_KEY"
"accept: application/json",
));
In some cases, large amounts of data need to be sent to the API in relation to the action taken. For example, if you are updating an entity, you'd pass the entity data through the POST parameters as JSON.
curl_setopt($ch, CURLOPT_POSTFIELDS, {"title":"New Panel Title"});
curl_setopt($ch, CURLOPT_POST, 1);
The Objects & APIs pages within this documentation each have a sandboxing area where you can explore the API Calls provided for them. You can also select the installation you are working with in these sandboxing areas.
Each installation is also equipped with a sandboxing area where you can explore all of the various API Calls using the Installation's Data.
Below is a PHP example that utilizes all three parameter types.
Please view the SANDBOX area of the API Settings in your installation(s) for examples in other programming languages.
/////////////////////////////////////////////////////////////////////
// INITIALIZE REQUEST AND SET URL PARAMETERS
/////////////////////////////////////////////////////////////////////
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://www.alphatouch.info/v1/panel/update/PANEL_ID");
/////////////////////////////////////////////////////////////////////
// SET HEADER PARAMETERS
/////////////////////////////////////////////////////////////////////
curl_setopt($ch, CURLOPT_HTTPHEADER, array (
"api-key: UNIQUE_API_KEY",
"accept: application/json"
));
/////////////////////////////////////////////////////////////////////
// SET POST DATA
/////////////////////////////////////////////////////////////////////
curl_setopt($ch, CURLOPT_POSTFIELDS, {"title":"New Panel Title"});
curl_setopt($ch, CURLOPT_POST, 1);
/////////////////////////////////////////////////////////////////////
// FETCH AND PROCESS RETURNED DATA
/////////////////////////////////////////////////////////////////////
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
Below is an example of a success response. It consists of 3 top-level objects.
- success: Boolean value which is always true for success responses
- data: Object containing the requested payload
- meta: Object containing information about the request/response itself such as result time and request/server IP Addresses
{
"data": {
"admin_type": "admin",
"email": "fakeadmin@alphatouch.info",
"email_id": 4530,
"id": "admin_4530",
"profile_photo": "https://www.alphatouch.info/user_photos/profile_blank.jpg",
"title": "Fake Admin"
},
"meta": {
"remote_address": "000.000.000.000",
"local_address": "111.111.111.111",
"result_time": 0.084688901901245
},
"success": true
}
Below is an example of a success response. It consists of 2 top-level objects.
- success: Boolean value which is always false for error responses
- error: Object containing information about the error
{
"error": {
"description": "IP Address 123.123.123.123 not Whitelisted"
},
"success": false
}