Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including tsheets-sdk with all npm packages installed. Try it out:

var tsheetsSdk = require("tsheets-sdk")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

tsheets-sdk v1.0.0

TSheets JS SDK for full API access.

TSheets Javascript SDK

NPM version NPM downloads Build Status Dependency Status Code Coverage Code Climate License Code Style

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
import TSheets from 'tsheets-sdk'
// or destructured
import { reports, timesheets, groups, jobcodes } from 'tsheets-sdk'

API

Reports

reports.getPayrollReport(params)

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

ParameterDescriptionTypeRequired
start_dateYYYY-MM-DD for the starting date.stringYes
end_dateYYYY-MM-DD for the end date.stringNo
user_idsArray of TSheets user IDs to get time for.number[]No
pagePage number for timesheets (max 50 per page).numberNo

reports.getProjectReport(params)

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

ParameterDescriptionTypeRequired
start_dateYYYY-MM-DD for the starting date.stringYes
end_dateYYYY-MM-DD for the end date.stringNo
user_idsArray of TSheets user IDs to get time for.number[]No
pagePage number for timesheets (max 50 per page).numberNo

reports.getCurrentTotalsReport(params)

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

ParameterDescriptionTypeRequired
start_dateYYYY-MM-DD for the starting date.stringYes
end_dateYYYY-MM-DD for the end date.stringNo
user_idsArray of TSheets user IDs to get time for.number[]No
pagePage number for timesheets (max 50 per page).numberNo

Timesheets

timesheets.get(params)

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

ParameterDescriptionTypeRequired
start_dateYYYY-MM-DD for the starting date.stringYes
end_dateYYYY-MM-DD for the end date.stringYes
user_idsArray of TSheets user IDs to get timesheets for.number[]No
pagePage number for timesheets (max 50 per page).numberNo

Jobcodes

jobcodes.get(params)

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

ParameterDescriptionTypeRequired
start_dateYYYY-MM-DD for the starting date.stringYes
end_dateYYYY-MM-DD for the end date.stringYes
user_idsArray of TSheets user IDs to get jobcodes for.number[]No
pagePage number for jobcodes (max 50 per page).numberNo

Users

users.get(params)

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

ParameterDescriptionTypeRequired
start_dateYYYY-MM-DD for the starting date.stringYes
end_dateYYYY-MM-DD for the end date.stringYes
user_idsArray of TSheets user IDs to get users for.number[]No
pagePage number for users (max 50 per page).numberNo

Groups

groups.get(params)

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

ParameterDescriptionTypeRequired
start_dateYYYY-MM-DD for the starting date.stringYes
end_dateYYYY-MM-DD for the end date.stringYes
user_idsArray of TSheets user IDs to get groups for.number[]No
pagePage number for groups (max 50 per page).numberNo

Contribution

Note: Make sure you set the environment variable TSHEETS_TOKEN as described above or tests will not run.

  1. Install dependencies: npm install
  2. Check/Remove lint using: npm run lint:fix
  3. Run tests using: npm run test
  4. Create a Pull Request with your changes

License

MIT © Scott Prue

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free