List all Employees JSON API

Discussion for TimeTrex open source community developers.
Post Reply
tadd
Posts: 16
Joined: Wed Mar 21, 2018 7:24 am

List all Employees JSON API

Post by tadd »

I would like to get a list of employees using API. I am able to get basic information as in JSON API example. I am interested in capturing Employees First name, last name, phone number and status. just like in the employees tab on Desktop version of Timetrex.
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: List all Employees JSON API

Post by shaunw »

Please see more information about our API and even a specific example on obtaining employee (user) records from TimeTrex here:
https://www.timetrex.com/workforce-management-api
tadd
Posts: 16
Joined: Wed Mar 21, 2018 7:24 am

Re: List all Employees JSON API

Post by tadd »

the API only mentions how to get user data when you know something about the user like userid. to get all users you will need to append null.
$user_data = postToURL( buildURL( 'APIUser', 'getUser' ), null);
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: List all Employees JSON API

Post by shaunw »

By default get*() API calls return all data if you don't pass in any arguments. Arguments are only needed if you want to filter the results to reduce what is returned.
gimecoffee
Posts: 17
Joined: Wed Apr 14, 2010 9:38 am

Re: List all Employees JSON API

Post by gimecoffee »

Is there an argument for returning the data sorted by 'last_name', 'first_name', 'middle_name'? I can sort it in PHP but I'm wondering if it would be faster and more streamline for my use if it came already in the order I want to display it.

Rois
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Re: List all Employees JSON API

Post by shaunw »

Yes, I would recommend using the API Tracing functionality described here:
https://www.timetrex.com/workforce-management-api

Then go to Employee -> Employees and create the exact list you want, with the columns and sorting specified, then you can see the API call that is being used and copy that to your own code. Keep in mind you can click on any list column headers in TimeTrex while holding the CTRL button to sort multiple columns at once. Or use the "Saved Search & Layout" tab "Sort By" dropdown box instead.
gimecoffee
Posts: 17
Joined: Wed Apr 14, 2010 9:38 am

Re: List all Employees JSON API

Post by gimecoffee »

Thank you. That was exactly what I needed.
Post Reply