(Unofficial) Simple TSheets node.js API Helper.
Features:
- Support Bearer Token authentication
- Supports pagination
- Supports supplemental data
- List / Add / Update or Delete on (almost) any endpoint
- Based on async/await
/users/groups/jobcodes/jobcode_assignments/timesheets/timesheets_deleted/geolocations/reports/last_modfied/notifications/reminders/schedule_calendars/schedule_events/managed_clients
npm install tsheetsapi --saveAll the endpoints are named exactly like in the TSheets docs.
The .add() and .update() methods need a data field in the parameters object:
{
"data" : [{}, {}, ...]
}Instead, the .list() and .delete() methods do not require a data field, you can just specify your parameters right away.
const TSheetsApi = require('tsheetsapi');
const tapi = new TSheetsApi({
bearerToken : '<your-access-token>'
});let res = await tapi.users().list();
while(res && res.data.length){
console.log(res.data)
console.log(res.supplemental_data)
await res = res.next;
}let res = await tapi.jobcodes().list()
console.log(res.data);const params = {
data : [{
schedule_calendar_id : '<your-id>',
start : '2017-06-12T15:19:21+00:00',
end : '2017-06-13T15:19:21+00:00',
all_day : true
}]
};
let res = await tapi.schedule_events.add(params);
console.log(res.data);