0% found this document useful (0 votes)
55 views17 pages

Stellar API

Uploaded by

vepisab634
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views17 pages

Stellar API

Uploaded by

vepisab634
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

API Documentation

API:
Please create an account first a rumytechnologies.com/rams
Contact the manufacturer to get the secret auth_code for the account. This code is required
during any API request.

All API calls must be made using POST method to


https://rumytechnologies.com/rams/json_api. Please see the sample code section for more
detail.

Following https://rumytechnologies.com/rams/json_api operations are supported:

add_user
remove_user_from_device
delete_user_permanently
fetch_user_list
fetch_user_in_device_list
fetch_device_detail
fetch_unsent_log
fetch_log
set_user_registration_mode

Following https://rumytechnologies.com/rams/service/get_gps_log operations are supported:


fetch_gps_log

Parameter Details:

operation Type of operation

username Unique username of the user to add/delete (for add_user &


remove_user_from_device)

signature Unique signature of the user which is to be added/removed/updated (for


add_user)

device_id ID of the device which the user is added to or removed from (for add_user
& remove_user_from_device)
API Documentation
device_name Not Used
auth_user Username of your client account
auth_code Contact the device manufacturer to get yours
start_date Date since which user logs to be obtained, format: YYYY-mm-dd (fetch_log)
end_date Date until which user logs to be obtained, format: YYYY-mm-dd (fetch_log)
access_id Unique access log ID till that user logs already obtained, format:
777333(fetch_log)
API Documentation
Example

1. {
"operation":"remove_user_from_device",
"auth_user":"John_Smith",
"auth_code":"xxxxxxxxxxxxxxxx",
"username": "asasde",
"device_id": "EM1474150"
}

2. {
"operation":"delete_permanently",
"auth_user":"John_Smith",
"auth_code":"xxxxxxxxxxxxxxxx",
"username": "asasde",
}

3. {
"operation":"fetch_user_list",
"auth_user":"John_Smith",
"auth_code":"xxxxxxxxxxxxxxxx",
}

4. {
"operation":"fetch_user_in_device_list",
"auth_user":"John_Smith",
"auth_code":"xxxxxxxxxxxxxxxx",
}

5. {
"operation":"fetch_device_detail",
"auth_user":"John_Smith",
"auth_code":"xxxxxxxxxxxxxxxx",
}

6. {
"operation":"fetch_unsent_log",
"auth_code":"xxxxxxxxxxxxxxxx"
}
API Documentation

7. {
"operation":"fetch_log",
"auth_user":"John_Smith",
"auth_code":"xxxxxxxxxxxxxxxx",
"start_date":"2022-08-28",
"end_date":"2022-08-28",
"start_time":"10:49:09",
"end_time":"11:49:09",
"access_id":"27774600"
}

8. {
"operation":"set_user_registration_mode",
"auth_user":"John_Smith",
"auth_code":"xxxxxxxxxxxxxxxx",
"device_id": "FPxxxxxx"
}

9. {
"operation":"fetch_gps_log",
"auth_user":"John_Smith",
"auth_code":"xxxxxxxxxxxxxxxx",
"start_date":"2022-01-01",
"end_date":"2022-01-01",
"start_time":"10:49:09",
"end_time":"12:49:09",
"access_id":"39180"
}

Return

1. remove_user_from_device
○ Successfully removed from device > The user has been removed successfully
from the device.
○ Error finding user in device > Please check username and/or device id.
2. delete_permanently
○ User Successfully Deleted > User has been deleted.
API Documentation
○ Failed to delete > Please check username and/or device id.
3. fetch_user_list
○ Roll No, RFID Card no, Mifare card no, fingerprint (type - list).
○ {"user_list": [{"username": "Mr. Roy", "registraton_id": “roy123"}, {"username": "Mr. Sohel ",
"registraton_id": "sohel123"}]}


○ Examples show how the signature of two users are returned.
4. fetch_user_in_device_list
○ Registration ID, Device id
○ {"device_user": [{"registraton_id": "roll123", "device_id": "DS111111"}, {"registraton_id": "roll124",
"device_id": "DS111111"}]}


○ Example shows how the device id of all the users are returned (type - list).
5. fetch_device_detail
○ Returns a list of all registered devices with device id,device name, last connected
date & time
○ {"0": {"device_name": "First Device", "last_connected": "2022-11-27 13:14:45", "device_id":
"DS111111"}}


○ Example shows how the devices registered to the user are returned (type - list).

6. fetch_unsent_log/fetch_log/fetch_gps_log
○ In fetch gps log all the returns are like below, you will get an extra key named
“location”.
○ Device Name, Username, Access time, Access date, Name, Signature,Access id
○ {
"log": [
{
"unit_name": "RFID DEVICE 2",
○ "unit_id": "DS330002",
"registration_id": "xxxxxxx",
"access_time": "6:01:41",
"access_date": "2017-11-01",
API Documentation
"user_name": "John Doe",
"card": "None",
○ "access_id":"6639915"
},
{
"unit_name": "RFID DEVICE 2",
"unit_id": "DS330002",
"registration_id": "xxxxxxxx",
"access_time": "6:17:29",
"access_date": "2017-11-01",
"user_name": " Jane Doe",
"card": "None",
"access_id":"6639916"
}]}
○ Example shows how the logs are returned (type - dictionary)
7. set_user_registration_mode
○ Success > Device successfully sent to user registration mode.
○ Failed > Error in format

Sample Codes
API Documentation

Python:
import requests
url = "https://rumytechnologies.com/rams/json_api"
data = {
"operation":"fetch_log",
"auth_user":"Account_Name",
"auth_code":"xxxxxxxxxxxxxxxxxxxxxxxxxx",
"start_date":"2018-01-13",
"end_date":"2018-01-29",
"start_time":"05:49:09",
"end_time":"05:49:09",
"access_id":"32559874"
}

post = requests.post(url, json=data)


API Documentation
JavaScript

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>API</title>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<div>
<button type="submit" onclick="get_data()">Get Data</button>
</div>

<script type="text/javascript">
function get_data(){
var post_data = {
"operation":"fetch_log",
"auth_user": "username",
"auth_code":"xxxxxxxxxxxxxxxxxxxx",
"start_date":"2022-02-28",
"end_date":"2022-02-28",
"start_time":"06:49:09",
"end_time":"14:59:59"
};
$.ajax({
type: "POST",
url: "https://rumytechnologies.com/rams/json_api",
data: JSON.stringify(post_data),
dataType: "html",
success: function (result) {
console.log(result);
}
});

}
</script>

</body>
</html>
API Documentation
PHP:
<?php
$data = array("operation" => "fetch_log","auth_user" => "xyz","auth_code"
=> "xxxxxxxxxxxxxxxxxx","start_date" => "2018-10-21","end_date" =>
"2018-10-21","start_time" => "08:49:09",
"end_time" => "15:49:09");

$datapayload = json_encode($data);
$api_request = curl_init('https://rumytechnologies.com/rams/json_api');
curl_setopt($api_request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($api_request, CURLINFO_HEADER_OUT, true);
curl_setopt($api_request, CURLOPT_POST, true);
curl_setopt($api_request, CURLOPT_POSTFIELDS, $datapayload);
curl_setopt($api_request, CURLOPT_HTTPHEADER, array('Content-Type:
application/json','Content-Length: ' . strlen($datapayload)));
$result = curl_exec($api_request);
$replace_syntax = str_replace('{"log":',"",$result);
print_r($replace_syntax);
$replace_syntax = substr($replace_syntax, 0, -1);
print_r($replace_syntax);
$json_data = json_decode($replace_syntax);
foreach ($json_data as $data) {
print_r($data->access_date);
}

?>
<html>
<body>
<?php echo $replace_syntax; ?>
</body>
</html>
API Documentation
C#:

public class SearchResult


{
public string Unit_name { get; set; }
public string Registration_id { get; set; }
public string Access_time { get; set; }
public string Access_date { get; set; }
}

public ActionResult DownloadData()


{
var url = "https://rumytechnologies.com/rams/json_api";

var httpRequest = (HttpWebRequest)WebRequest.Create(url);


httpRequest.Method = "POST";

httpRequest.Accept = "application/json";
httpRequest.ContentType = "application/json";

var data = @"{


""operation"":""fetch_log"",
""auth_user"":""auth_user_name"",
""auth_code"":""xxxxxxxxxxxxxxxxxxx"",
""start_date"":""2022-01-01"",
""end_date"":""2022-01-01"",
""start_time"":""1:00:01"",
""end_time"":""23:59:01""
}";

using (var streamWriter = new StreamWriter(httpRequest.GetRequestStream()))


{
streamWriter.Write(data);
}

string stresult;
var httpResponse = (HttpWebResponse)httpRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
API Documentation
stresult = streamReader.ReadToEnd();
}

JObject search = JObject.Parse(stresult);

// get JSON result objects into a list


IList<JToken> results =search["log"].Children().ToList();
IList<SearchResult> searchResults = new List<SearchResult>();

foreach (JToken result in results)


{
// JToken.ToObject is a helper method that uses JsonSerializer internally
SearchResult searchResult = result.ToObject<SearchResult>();

//Now you have searchResult.Registration_id, searchResult.Access_date+" "+


searchResult.Access_time, searchResult.Unit_name
//Save these data in your database
db.ImportData(searchResult.Registration_id, searchResult.Access_date+" "+
searchResult.Access_time, searchResult.Unit_name);
}
}
API Documentation
Oracle

create or replace PROCEDURE sync_stellar


IS
--l_json_text VARCHAR2(32767);
l_json_values apex_json.t_values;
l_name VARCHAR2(200) ;
l_count number;
vResult clob;--v_varchar2 varchar2(32767);
l_unit_id VARCHAR2(200) ;
l_registration_id VARCHAR2(200) ;
l_event_time date ;
l_access_date VARCHAR2(200) ;
l_access_time VARCHAR2(200) ;
l_unit_name VARCHAR2(200) ;
l_access_id VARCHAR2(200) ;
l_department VARCHAR2(200) ;
l_user_name VARCHAR2(200) ;
l_card VARCHAR2(200) ;
l_from_date varchar2(20) := to_char(sysdate-30,'yyyy-mm-dd');
l_to_date varchar2(20) := to_char(sysdate,'yyyy-mm-dd');
v_max_acess_id number;
BEGIN
begin
select max(ACCESS_ID) into v_max_acess_id from stellar_data;
exception when others then
v_max_acess_id :=0;
end;

vResult := APEX_WEB_SERVICE.make_rest_request(
p_url =>
'https://stellarbd.com/stellar_rams_test/service/get_logs?operation=fetch_log&auth_code=283948394923
433434&access_id='||v_max_acess_id||'&start_date='|| l_from_date ||'&end_date='|| l_to_date
||'&start_time=00:00:00&end_time=23:59:59'
,p_http_method => 'GET'
,p_wallet_path => 'file:/u02/app/oracle/wallets/ssl_wallet'
,p_wallet_pwd => ''
);
--vResult :=
utl_http.request('https://stellarbd.com/stellar_rams_test/service/get_logs?operation=fetch_log&auth_code
=09384092834092394893&access_id=16632189&start_date=2022-05-12&end_date=2022-05-12&start_t
ime=08:00:00&end_time=08:01:00',null, 'file:/u02/app/oracle/wallets/ssl_wallet', '');
API Documentation
--l_json_text := '{"data":[{"unit_name": "device1", "registration_id": "10001", "access_id": "229196763",
"department": "None", "access_time": "08:00:29", "access_date": "2022-05-12", "user_name": "Mrx",
"unit_id": "DS11111", "card": "abcdea"}, {"unit_name": "device1", "registration_id": "11100", "access_id":
229196764", "department": "None", "access_time": "08:00:19", "access_date": "2022-05-12",
"user_name": "Mry", "unit_id": "DS11111", "card": "bcdaae"}]}';
--htp.p(vResult);

apex_json.parse(
p_values => l_json_values,
p_source => vResult
);
--htp.p(l_json_values);
l_count := 1;-- apex_json.get_count (p_path => 'log.registration_id'); -- l_count := apex_json.get_count
(p_path => 'RAW.LEVEL_1_ARRAY');
l_registration_id := apex_json.get_varchar2(p_path => 'log[%d].registration_id', p0 => l_count, p_values
=> l_json_values);
WHILE l_registration_id is not null
LOOP
l_count := l_count + 1;
l_unit_id := apex_json.get_varchar2(p_path => 'log[%d].unit_id', p0 => l_count, p_values =>
l_json_values);
l_registration_id := apex_json.get_varchar2(p_path => 'log[%d].registration_id', p0 => l_count,
p_values => l_json_values);
l_access_date := apex_json.get_varchar2(p_path => 'log[%d].access_date', p0 => l_count, p_values
=> l_json_values);
l_access_time := apex_json.get_varchar2(p_path => 'log[%d].access_time', p0 => l_count, p_values
=> l_json_values);
l_unit_name := apex_json.get_varchar2(p_path => 'log[%d].unit_name', p0 => l_count, p_values =>
l_json_values);
l_access_id := apex_json.get_varchar2(p_path => 'log[%d].access_id', p0 => l_count, p_values =>
l_json_values);
l_department := apex_json.get_varchar2(p_path => 'log[%d].department', p0 => l_count, p_values =>
l_json_values);
l_user_name := apex_json.get_varchar2(p_path => 'log[%d].user_name', p0 => l_count, p_values =>
l_json_values);
l_card := apex_json.get_varchar2(p_path => 'log[%d].card', p0 => l_count, p_values => l_json_values);

begin
l_event_time := to_date(l_access_date || ' ' || l_access_time, 'yyyy-mm-dd hh24:mi:ss');
exception when others then
l_event_time := null;
end;
begin
insert into stellar_data (
API Documentation
unit_id,
registration_id,
event_time,
access_date,
access_time,
unit_name,
access_id,
department,
user_name,
card
) values
(
l_unit_id,
l_registration_id,
l_event_time,
l_access_date,
l_access_time,
l_unit_name,
to_number(l_access_id),
l_department,
l_user_name,
l_card
);
exception when others then
null;
end;
-- DBMS_OUTPUT.put_line('"User.name":'||l_name);
END LOOP;
htp.p('Total Count: ' || l_count);
COMMIT;
END;
API Documentation

Live access log:

One can use the following instruction to create a front page that will display a user’s information,
as soon as the user scans his finger or card. Please note that the devices are set to send data
when idle for a minute by default. If live data is needed, “Live Data” option must be turned on
from the device detail page. You can go to the device detail page by clicking on the desired
device ID from the home page.

1. Download and unzip the file (https://rumytechnologies.com/rams/static/stellar.zip).


Alternatively use the following links.
○ https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
○ https://rumytechnologies.com/rams/static/js/paho-mqtt-min.js
○ https://rumytechnologies.com/rams/static/js/stellar.min.js
2. Make sure that jquery is already included in your page.
3. Include the mqttws31.min.js right below the jquery. E.g.
<script src="js/paho-mqtt-min.js"/>

4. Include the stellar.js below the mqttws31.min.js.


<script src="js/stellar.min.js"/>

5. With everything included, your page should look similar to the following:
<script src="js/jquery.min.js"/>
<script src="js/paho-mqtt-min.js"/>
<script src="js/stellar.min.js"/>

6. Finally add the following code segment to start receiving accesslog (remember to
replace #html_element_id with the id or class of the html element where you want to
show the access log. Also replace example_client_id with your client login id.
<script>
var operation = “accessLog”;
var html_id = "#html_element_id";
var client_id = "example_client_id";
stellar_mqtt(operation, html_id, client_id);
</script>
API Documentation

Demo HTML page for live access log:


<!doctype html>
<html>
<head>

</head>
<body>

<!-- When new message arrives, it will be inserted into the HTML element with
id "user_signature". Example use case, HTML form field with id
"user_signature" -->
<div id="user_signature"></div>

<!-- StartInclude - If jQuery is not already available in you page.


If jQuery is already available, please delete this segment -->
<script src="js/jquery.min.js"></script>
<!-- EndInclude -->

<!-- The following scripts establishes the connection, don't remove it -->
<script src="js/paho-mqtt-min.js"/>
<script src="js/stellar.min.js"/>

<!-- Configuration -->


<script>
var operation = “accessLog”;
var html_id = "#user_signature";
var client _id = "reza";
stellar_mqtt(operation, html_id, client_id);
</script>
</body>
</html>
API Documentation
Signature from user_registration_mode:
1. Follow steps 1-5 from above. On the 6th step, replace the var operation = “accessLog”;
with var operation = “template”;.

<script>
var operation = “template”;
var html_id = "#html_element_id";
var client_id = "example_client_id";
stellar_mqtt(operation, html_id, client_id);
</script>

You might also like