API for Product 2004
API Document, for product 2004
https://www.opentimeclock.com/manual/APIforProduct2004.html
For any question, please contact us: support@opentimeclock.com
https://www.opentimeclock.com
1. Query Time Cards data:
Sample Code in passing parameters in URL:
https://api1.opentimeclock.com/Jun-Inside-VPC?cmd=api/v2004QueryTimeCards&companyId=xxxx&developerToken=xxxx&nextRecord=0&dateTimeFrom=2022-05-01 00:00:00&dateTimeTo=2022-05-15 23:59:59&userFullName=xxxx&departmentName=xxxx
Sample Code in javascript with jQuery POST:
function post(data, handler) {
var url = "https://api1.opentimeclock.com/Jun-Inside-VPC"; //api url
$.post(url, JSON.stringify(data), handler, 'json');
}
function getTimeCards() {
//pass in JSON parameters:
post({
"cmd": "api/v2004QueryTimeCards", //This passed in commmand means query time cards records. We may have add or modify command later.
"companyId": "xxxx", //Find your "Company ID" in company setting page.
"developerToken": "xxxx", //Find "Developer Token" in reports page with admin account
"nextRecord": "0", //Default to "0". If >"0" means query the left data when there are more than 5k records available.
"dateTimeFrom": "2022-05-01 00:00:00", //From Date Time format: 0000-00-00 00:00:00
"dateTimeTo": "2022-05-15 23:59:59", //To Date Time format: 0000-00-00 00:00:00
"userFullName": "xxxx", //sample: Elon Musk; For all users, use "ALL USERS" or ""
"departmentName": "xxxx" //sample: HR Department; For all departments, use "ALL DEPARTMENTS",or ""
}, function (result) {
//sample code to use returned data:
var statusCode = result.statusCode;
var message = result.message;
var nextRecord = result.nextRecord;
var dataSet = result.data;
if(statusCode == 'SUCCESS')
console.log('query data successfully.');
if(statusCode == 'ERROR')
console.log('query data failed. check returned message.');
if(nextRecord == '-1')
console.log('no more data left');
if(nextRecord != '-1')
console.log('there are more data left. pass in nextRecord to query more.');
//use data set like this:
var firstFullName=dataSet[0].userFullName;
});
}
Sample Code in PHP:
header("Content-type:application/json;charset=utf-8");
$url="https://api1.opentimeclock.com/Jun-Inside-VPC";
$param=array(
"cmd" => "api/v2004QueryTimeCards", //This passed in commmand means query time cards records. We may have add or modify command later.
"companyId" => "xxxx", //Find your "Company ID" in company setting page.
"developerToken" => "xxxx", //Find "Developer Token" in reports page with admin account
"nextRecord" => "0", //Default to "0". If >"0" means query the left data when there are more than 5k records available.
"dateTimeFrom" => "2022-05-01 00:00:00", //From Date Time format: 0000-00-00 00:00:00
"dateTimeTo" => "2022-05-15 23:59:59", //To Date Time format: 0000-00-00 00:00:00
"userFullName" => "xxxx", //sample: Elon Musk; For all users, use "ALL USERS" or ""
"departmentName" => "xxxx" //sample: HR Department; For all departments, use "ALL DEPARTMENTS",or ""
);
$data = json_encode($param);
$postdata=str_replace("\\/", "/", $data);
list($return_code, $return_content) = http_post_data($url, $postdata);
print_r($return_content);exit;
function http_post_data($url, $data_string) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json; charset=utf-8",
"Content-Length: " . strlen($data_string))
);
ob_start();
curl_exec($ch);
$return_content = ob_get_contents();
ob_end_clean();
$return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
return array($return_code, $return_content);
}
Sample returned data in JSON:
{
"statusCode": "SUCCESS", //ERROR
"message": "", //Company ID not found. Developer token is not correct. User Full Name not found. Department Name not found.
"nextRecord": "-1", //if ="-1", means no more data left, otherwise please query left data from this number.
"data":
[
{
"userFullName": "Elon Musk",
"employeeNumber": "12345",
"userName": "elonmusk",
"digitId": "123456",
"inDateTime": "2021-05-27 08:49:00", //clock in date time or start date time
"outDateTime": "2021-05-27 18:35:00", //clock out time //not applicable = 0000-00-00 00:00:00
"hours": "0.000", //not applicable if entryType=0 (job)
"entryType":0, //0=job; 1=pto, 2=addition adjustment, 3=deduction adjustment
"jobName": "job 1",
"ptoName": "vacation",
"shiftName": "day shift",
"employeeNote": "",
"employeeNoteIsRead": "",
"managerComment": "",
"managerCommentIsRead": "",
"inIp": "",
"outIp": "",
"inDeviceId": "",
"outDeviceId": "",
"inWifiId": "",
"outWifiId": "",
"inLatitude": "",
"inLongitude": "",
"outLatitude": "",
"outLongitude": "",
"entranceIn": "",
"entranceOut: "",
"approvedByEmployee": 0; //0=NO, 1=YES
"approvedManagerFullName": "", //empty means not approved yet
"createdDateTime": "2021-05-27 08:49:00" //our server time, record first created. Amazon.com aws North Virginia.
},
{
//other records the same format.
}
]
}
Where to find Developer Token:
Created with the Personal Edition of HelpNDoc: Transform Your Documentation Workflow with HelpNDoc's Intuitive UI