Skip to main content
Version: 5.1

Rest-API

The TimePunch Rest API can be used to easily connect to third-party systems. TimePunch offers extensive possibilities for data analysis via the Rest-API interface.

Example in PHP

Here is a simple example of how the Rest API interface in PHP can be used to load the monthly analyses.

<?php  

// Method: POST, PUT, GET etc
// Data: array("param" => "value") ==> index.php?param=value

function CallAPI(\$url, \$data = false, \$username, \$password)
{
\$curl = curl_init();
if (\$data)
\$url = sprintf("%s?%s", \$url, http_build_query(\$data));

// Optional Authentication:
curl_setopt(\$curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt(\$curl, CURLOPT_USERPWD, "\$username:\$password");

curl_setopt(\$curl, CURLOPT_URL, \$url);
curl_setopt(\$curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt(\$curl, CURLOPT_SSL_VERIFYPEER, false);

\$result = curl_exec(\$curl);

curl_close(\$curl);

return json_decode(\$result);
}


// Get data from the API
\$username = "ralf.herrmann";
\$password = "tpdemo";

\$data = CallAPI("https://demo.timepunch-hub.com/bi/api/MonthlySummaries", array(
"users" => "svenja.rabe"
), \$username, \$password);

var_dump(\$data);
?>

API Reference

TimePunch provides the following API commands.

Get api/ProjectTimes

Returns all time entries related to a specific project or to selected projects.

Request Information

GET api/ProjectTimes?users={users}&projects={projects}&customers={customers}&logon={logon}&logoff={logoff}&important={important}&onsite={onsite}¬Invoiced={notInvoiced}

NameDescriptionType
userssearch for users that are connected by a + signstring
projectssearch for projects that are connected by a + signstring
customerssearch for customers that are connected by a + signstring
logonfirst date that is returnedstring
logofflast date that is returnedstring
importantif set to true, only important entries will be returnedboolean
onsiteif set to true, only on-site entries will be returnedboolean
notInvoicedif set to true, only not invoiced entries will be returnedboolean

RESPONSE Information

This method returns objects of type ReportTimeEntryDto.

Get api/UserTimes

Returns all time entries related to specific users or to the selected users.

Request Information

GET api/UserTimes?users={users}&projects={projects}&customers={customers}&logon={logon}&logoff={logoff}&important={important}&onsite={onsite}¬Invoiced={notInvoiced}&showWorkingTime={showWorkingTime}&showBreaks={showBreaks}&showPublicHolidays={showPublicHolidays}&showWeekends={showWeekends}&showMissingdays={showMissingdays}&showWeekdays={showWeekdays}

NameDescriptionType
userssearch for users that are connected by a + signstring
projectssearch for projects that are connected by a + signstring
customerssearch for customers that are connected by a + signstring
logonfirst date that is returnedstring
logofflast date that is returnedstring
importantif set to true, only important entries will be returnedboolean
onsiteif set to true, only on-site entries will be returnedboolean
notInvoicedif set to true, only not invoiced entries will be returnedboolean
showWorkingTimeif set to true, working times are returned (default is true)boolean
showBreaksif set to true, break times are returned (default is true)boolean
showPublicHolidaysif set to true, public holiday are returned (default is true)boolean
showWeekendsif set to true, weekends are returned (default is false)boolean
showMissingdaysif set to true, missing days are returned (default is false)boolean
showWeekdaysif set to true, weekdays are returned (default is false)boolean

RESPONSE Information

This method returns objects of type ReportTimeEntryDto.

Get api/Users

Returns the master data of one or more selected users.

Request Information

GET api/Users?search={search}&isDeleted={isDeleted}

NameDescriptionType
searchsearch for user names that are connected by a + signstring
isDeletedtrue, if only deleted users shall be searchedboolean

RESPONSE Information

This method returns objects of type ReportUserDTO.

Get api/Projects

Returns the master data of one or more selected projects.

Request Information

NameDescriptionType
searchsearch for projects that are connected by a + signstring
lifeCylcesearch for projects that are in a special state (0 = all, 1 = planning, 2 = active, 4 = done, 8 = deleted)integer
withTaskstrue, if also depending tasks shall be returnedboolean
userDefinedCustomerstrue, if also used defined customers shall be returnedboolean

RESPONSE Information

This method returns objects of type ReportProjectDTO.

Get api/Customers

Returns the master data of one or more selected customers.

Request Information

NameDescriptionType
searchsearch for customer names that are connected by a + signstring
isDeletedtrue, if only deleted customers shall be searchedboolean

RESPONSE Information

This method returns objects of type ReportCustomerDTO.

Get api/DailySummaries

Returns the aggregated daily values of one or more selected employees within a defined time period.

Request Information

NameDescriptionType
userssearch for users that are connected by a + signstring
logonfirst date that is returnedstring
logofflast date that is returnedstring

RESPONSE Information

This method returns objects of type ReportDailySummaryDTO.

Get api/MonthlySummaries

Returns the aggregated monthly values of one or more selected employees within a defined period.

Request Information

NameDescriptionType
userssearch for users that are connected by a + signstring
logonfirst month that is returnedstring
logofflast month that is returnedstring

RESPONSE Information

This method returns objects of type ReportSummaryDTO.

Get api/YearlySummaries

Returns the aggregated annual values of one or more selected employees within a defined period.

Request Information

NameDescriptionType
userssearch for users that are connected by a + signstring
logonfirst year that is returnedstring
logofflast year that is returnedstring

RESPONSE Information

This method returns objects of type ReportYearlySummaryDTO.

Get api/DailyProjectTimes

This method returns the project times aggregated to daily values.

Request Information

NameDescriptionType
searchsearch for projects that are connected by a + signstring
lifeCylcesearch for projects that are in a special state (0 = all, 1 = planning, 2 = active, 4 = done, 8 = deleted)integer

RESPONSE Information

This method returns objects of type ReportProjectTimeDto.