Simple client for full access to TSheets REST API.
Set the environment variable TSHEETS_TOKEN
to a TSheets access token.
// Top level import
import TSheets from 'tsheets-sdk'
// or destructured
import { reports, timesheets, groups, jobcodes } from 'tsheets-sdk'
Retrieves a payroll report, with filters to narrow down the results.
Example
import { reports } from 'tsheets-sdk'
reports().getPayrollReport()
.then(report => console.log('report:', report))
.catch(error => console.error('error getting report:', error))
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 |
Retrieves a project report, with filters to narrow down the results.
Example
import { reports } from 'tsheets-sdk'
reports().getProjectReport()
.then(report => console.log('report:', report))
.catch(error => console.error('error getting report:', error))
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 |
Retrieves a current totals report, with filters to narrow down the results.
Example
import { reports } from 'tsheets-sdk'
reports().getCurrentTotalsReport()
.then(report => console.log('report:', report))
.catch(error => console.error('error getting report:', error))
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 |
Gets timesheets for the specified user(s) for the provided time period.
Example
import { timesheets } from 'tsheets-sdk'
// Can be imported from top level as well
// import Tsheets from 'tsheets-sdk'
// const { timesheets } = Tsheets
timesheets().get()
.then(report => console.log('timesheets:', timesheets))
.catch(error => console.error('error getting timesheets:', error))
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 |
Gets jobcodes for the specified user(s) for the provided time period.
Example
import { reports } from 'tsheets-sdk'
jobcodes().get()
.then(report => console.log('jobcodes:', jobcodes))
.catch(error => console.error('error getting jobcodes:', error))
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 |
Gets users for the specified filters.
Example
import { reports } from 'tsheets-sdk'
const start_date = '2016-01-01'
users().get({ start_date })
.then(report => console.log('users:', users))
.catch(error => console.error('error getting users:', error))
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 |
Gets groups based on filters.
Example
import { reports } from 'tsheets-sdk'
const start_date = '2016-01-01'
groups().get({ start_date })
.then(report => console.log('groups:', groups))
.catch(error => console.error('error getting groups:', error))
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 |
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
MIT © Scott Prue