Page 1 of 1

List all Employees JSON API

Posted: Tue Jan 28, 2020 2:58 pm
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.

Re: List all Employees JSON API

Posted: Tue Jan 28, 2020 3:10 pm
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

Re: List all Employees JSON API

Posted: Tue Jan 28, 2020 3:34 pm
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);

Re: List all Employees JSON API

Posted: Tue Jan 28, 2020 4:19 pm
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.

Re: List all Employees JSON API

Posted: Wed Nov 16, 2022 5:08 pm
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

Re: List all Employees JSON API

Posted: Thu Nov 17, 2022 12:22 pm
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.

Re: List all Employees JSON API

Posted: Thu Nov 17, 2022 1:02 pm
by gimecoffee
Thank you. That was exactly what I needed.