Skip to main content
Version: 5.1

Installation

The TimePunch API will be installed and delivered with the TimePunch Application Server.

Access

Within the Server the exported services can be accessed with a click to the menu “API”. The API page contains the URLs to the exported services.

Service-Formats

The TimePunch API has been implemented with the Windows Communication Foundation (WCF). The Services can be accessed via the WS and SOAP Binding.

A Web API is planned, but yet not available.

WS-http Binding:

The WS-http Binding URL equals the address that is listed in the TimePunch Server.
E.g. z.B. http://tpServer/TimePunch/API/TpAuth.svc

Basic-http Binding (SOAP Binding):

The address for the Basic-http Binding, or SOAP Binding, equals the address of the WS-http binding with a SOAP postfix. e.g. http://tpServer/TimePunch/API/TpAuth.svc/soap

Access via the TimePunch Web API package

Since version 4.8 TimePunch offers a TimePunch Web API Nuget package for easy accessing the TimePunch web services.

It can be installed with the name: TpWebWcf

NuGet Gallery | TpWebWcf

And is compatible with all .net frameworks due to the netStandard2.0 compliance.

Connecting to a TimePunch Application Server

To connect to a TimePunch Application Server a new TimePunchInstance object needs to be created.

// Connect to the TimePunch Server

var timePunchInstance
= new TimePunchInstance(new Uri("https://demo.timepunch-hub.com/TimePunch"));

Authenticate the user

To ensure that the user is allowed to access the TimePunch instance, an authentication object needs to be created.

// Create an authentication object

var adminAuthentication
= TimePunchInstance.CreateAuthentication("{user}", "{pwd}");

Hint: The identity parameter (third parameter) can be used to access a different TimePunch User profile, with the rights of the principal, which is the logon user (first parameter).

Create a service connection

Next step is to create a service connection. This could be the project service as in the example, or any other service that TimePunch offers.

// Create the project service

var projectService = timePunchInstance.CreateProjectService();

Execute a service call

Finally, we can execute the service call and validate the response.

// Execute Project search

var spr = new SearchProjectsRequest(adminAuthentication, new ProjectSearchDto());

var response = projectService.SearchProjects(spr);

// Output projects

if (response.fault != null)

{

Console.WriteLine("Error: " + response.fault.Message);

return;

}

response.SearchProjectsResult
.ForEach(p => Console.WriteLine(\$"--> {p.ProjectName}"));