TSheets Javascript SDK
Simple client for full access to TSheets REST API.
Authentication
Set the environment variable TSHEETS_TOKEN
to a TSheets access token.
Usage
ES6
// Top level import// or destructured
API
Reports
reports.getPayrollReport(params)
Retrieves a payroll report, with filters to narrow down the results.
Example
Params
Parameter | Description | Type | Required |
---|---|---|---|
start_date | YYYY-MM-DD for the starting date. |
string | Yes |
end_date | YYYY-MM-DD for the end date. |
string | No |
user_ids | Array of TSheets user IDs to get time for. | number[] | No |
page | Page number for timesheets (max 50 per page). | number | No |
reports.getProjectReport(params)
Retrieves a project report, with filters to narrow down the results.
Example
Params
Parameter | Description | Type | Required |
---|---|---|---|
start_date | YYYY-MM-DD for the starting date. |
string | Yes |
end_date | YYYY-MM-DD for the end date. |
string | No |
user_ids | Array of TSheets user IDs to get time for. | number[] | No |
page | Page number for timesheets (max 50 per page). | number | No |
reports.getCurrentTotalsReport(params)
Retrieves a current totals report, with filters to narrow down the results.
Example
Params
Parameter | Description | Type | Required |
---|---|---|---|
start_date | YYYY-MM-DD for the starting date. |
string | Yes |
end_date | YYYY-MM-DD for the end date. |
string | No |
user_ids | Array of TSheets user IDs to get time for. | number[] | No |
page | Page number for timesheets (max 50 per page). | number | No |
Timesheets
timesheets.get(params)
Gets timesheets for the specified user(s) for the provided time period.
Example
// Can be imported from top level as well// import Tsheets from 'tsheets-sdk'// const { timesheets } = Tsheets
Params
Parameter | Description | Type | Required |
---|---|---|---|
start_date | YYYY-MM-DD for the starting date. |
string | Yes |
end_date | YYYY-MM-DD for the end date. |
string | Yes |
user_ids | Array of TSheets user IDs to get timesheets for. | number[] | No |
page | Page number for timesheets (max 50 per page). | number | No |
Jobcodes
jobcodes.get(params)
Gets jobcodes for the specified user(s) for the provided time period.
Example
Params
Parameter | Description | Type | Required |
---|---|---|---|
start_date | YYYY-MM-DD for the starting date. |
string | Yes |
end_date | YYYY-MM-DD for the end date. |
string | Yes |
user_ids | Array of TSheets user IDs to get jobcodes for. | number[] | No |
page | Page number for jobcodes (max 50 per page). | number | No |
Users
users.get(params)
Gets users for the specified filters.
Example
const start_date = '2016-01-01'
Params
Parameter | Description | Type | Required |
---|---|---|---|
start_date | YYYY-MM-DD for the starting date. |
string | Yes |
end_date | YYYY-MM-DD for the end date. |
string | Yes |
user_ids | Array of TSheets user IDs to get users for. | number[] | No |
page | Page number for users (max 50 per page). | number | No |
Groups
groups.get(params)
Gets groups based on filters.
Example
const start_date = '2016-01-01'
Params
Parameter | Description | Type | Required |
---|---|---|---|
start_date | YYYY-MM-DD for the starting date. |
string | Yes |
end_date | YYYY-MM-DD for the end date. |
string | Yes |
user_ids | Array of TSheets user IDs to get groups for. | number[] | No |
page | Page number for groups (max 50 per page). | number | No |
Contribution
Note: Make sure you set the environment variable TSHEETS_TOKEN
as described above or tests will not run.
- Install dependencies:
npm install
- Check/Remove lint using:
npm run lint:fix
- Run tests using:
npm run test
- Create a Pull Request with your changes
License
MIT © Scott Prue