23.5.1 • Published 5 months ago

clockodo v23.5.1

Weekly downloads
16
License
MIT
Repository
github
Last release
5 months ago

Clockodo

Unofficial JavaScript/TypeScript SDK for Clockodo.

Version on NPM Semantically released Monthly downloads on NPM NPM Bundle size minified NPM Bundle size minified and gzipped License

Installation and usage

npm install clockodo

For the constructor arguments, you must get the user (email) and clockodo API key from the "My area" section of Clockodo's website.

import { Clockodo } from "clockodo";

const clockodo = new Clockodo({
  client: {
    // You need to add some information about yourself that will be
    // sent along every request,
    // see https://www.clockodo.com/en/api/ "Client identification"
    // PLEASE NOTE: name + ";" + email must not be longer than 50 characters.
    name: "Your application/company",
    email: "technical-contact@your-company.com",
  },
  authentication: {
    user: "test-user@example.com",
    // You can get your API key from https://my.clockodo.com/en/users/editself
    apiKey: "kjfdskj643fgnlksf343kdslm",
  },
});

Config

  • client: Specify a name and an email for the X-Clockodo-External-Application header
  • authentication: Specify a user and an apiKey to authenticate every request
  • baseUrl: Points to the Clockodo API. Defaults to https://my.clockodo.com/api

You can update the configuration later like this:

clockodo.api.config({
  authentication: {
    /* ... */
  },
});

API

We have provided methods for each of the endpoints available by the Clockodo API. In order to provide a seamless API to JavaScript, we renamed the request and response object keys from what you will see in the Clockodo docs by removing special characters and converting to camel casing. If you are interested, you can find the mappings in the mappings.ts file.

For any questions about the different properties please consult the official Clockodo-API.

Some constants are also available for import:

import { EntryType, Billability, AbsenceStatus, AbsenceType } from "clockodo";

console.log(EntryType.Time); // 1
console.log(EntryType.LumpsumValue); // 2
console.log(EntryType.LumpsumService); // 3

console.log(Billability.NotBillable); // 0
console.log(Billability.Billable); // 1
console.log(Billability.Billed); // 2

Checkout models for more constants and TypeScript types.


Get Methods

getAbsence()

Gets a selected absence by its ID.

Example:

await clockodo.getAbsence({ id: 7 });

getUsersAccessCustomersProjects()

Gets a user's (readonly) access rights for customers and projects.

Example:

await clockodo.getUsersAccessCustomersProjects({ usersId: 67325 });

getUsersAccessServices()

Gets a user's (readonly) access rights for services.

Example:

await clockodo.getUsersAccessServices({ usersId: 67325 });

getAbsences()

Gets a list of absences in the provided year

Example:

await clockodo.getAbsences({ year: 2018 });

getClock()

Get currently running entry for the credentials attached to Clockodo object.

Example:

await clockodo.getClock();

getCustomer()

Get specific customer by ID

Example:

await clockodo.getCustomer({ id: 777 });

getCustomers()

Get all customers from all pages.

Example:

await clockodo.getCustomers();
// or
await clockodo.getCustomers({
  // Filter by active flag
  filterActive: true,
});

getCustomersPage()

Get all customers from a specific page.

Example:

await clockodo.getCustomersPage({ page: 2 });

getEntry()

Get an entry by its ID.

Example:

await clockodo.getEntry({ id: 4 });

getEntries()

Get all entries from all pages.

Example:

import { Billability } from "clockodo";

await clockodo.getEntries({
  // timeSince and timeUntil are required
  timeSince: "2017-08-18T00:00:00Z",
  timeUntil: "2018-02-09T00:00:00Z",
  // You can also add additional filters here
  filterBillable: Billability.Billed,
});

getEntriesPage()

Get all entries from a specific page

Example:

await clockodo.getEntriesPage({
  timeSince: "2017-08-18T00:00:00Z",
  timeUntil: "2018-02-09T00:00:00Z",
  page: 2,
});

getEntryGroups()

Get a group of entries defined by your criteria.

Example:

await clockodo.getEntryGroups({
  timeSince: "2017-08-18T00:00:00Z",
  timeUntil: "2018-02-09T00:00:00Z",
  grouping: ["customersId", "projectsId"],
  roundToMinutes: 15,
});

getEntriesTexts()

Retreive all descriptions (and no additional info) entered for time and lump sum entries from all pages.

Example:

await clockodo.getEntriesTexts({ text: "meeting with client" });

getEntriesTextsPage()

Retreive all descriptions from a specific page.

Example:

await clockodo.getEntriesTextsPage({ text: "meeting with client", page: 2 });

getProject()

Get a project by its ID.

Example:

await clockodo.getProject({ id: 1985 });

getProjects()

Get all projects from all pages.

Example:

await clockodo.getProjects();
// or
await clockodo.getProjects({
  // Filter by a specific customer id
  filterCustomersId: 123,
  // Filter by active flag
  filterActive: true,
});

getProjectsPage()

Get all projects from a specific page.

Example:

await clockodo.getProjectsPage({ page: 2 });

getService()

Get a service by its ID.

Example:

await clockodo.getService({ id: 10 });

getServices()

Get list of all services

Example:

await clockodo.getServices();

getTeam()

Get team by id.

Example:

await clockodo.getTeam({ id: 10 });

getTeams()

Get list of all teams.

Example:

await clockodo.getTeams();

getLumpSumService()

Get a lumpsum service by its ID.

Example:

await clockodo.getLumpSumService({ id: 10 });

getLumpSumServices()

Get a list of all lumpsum services

Example:

await clockodo.getLumpSumServices();

getTargethoursRow()

Get a specific target hour period for a specific user by its ID (not the ID of the user)

Example:

await clockodo.getTargethoursRow({ id: 1234 });

getTargethours()

Get list of target hours for all users, with option to pass an object with an usersId to filter the history of target hours to a specific user.

Example:

await clockodo.getTargethours();
// or
await clockodo.getTargethours({ usersId: 346923 });

getUser()

Get a co-worker by their ID.

Example:

await clockodo.getUser({ id: 1263 });

getUsers()

Get list of users

Example:

await clockodo.getUsers();

getUserReport()

Get a co-worker by their ID.

Example:

await clockodo.getUserReport({ usersId: 1263, year: 2017 });

getUserReports()

Get an employee/user's report, which contains data such as hours worked and holidays taken.

Example:

await clockodo.getUserReports({ year: 2017, type: 1 });

getNonbusinessGroups()

With this resource you can read all nonbusiness groups. The editing and adding of nonbusiness groups is currently not possible.

Example:

await clockodo.getNonbusinessGroups();

getNonbusinessDays()

With this resource you can read all nonbusiness days. The editing and adding of nonbusiness days is currently not possible.

Example:

await clockodo.getNonbusinessDays({
  nonbusinessgroupsId: 123,
  year: 2021,
});

getAggregatesUsersMe()

With this resource you can read user and company seetings for the logged in user. Editing is currently not possible.

Example:

await clockodo.getAggregatesUsersMe();

Post Methods

addAbsence()

Default behavior adds an absence for the user attached to the credentials given to the clockodo object. To add the absence for another user you can use the usersId option if you have the permissions.

Example:

import { AbsenceType } from "clockodo";

await clockodo.addAbsence({
  dateSince: "2017-08-18T00:00:00Z",
  dateUntil: "2018-02-09T00:00:00Z",
  type: AbsenceType.SpecialLeave,
  note: "elternzeit",
  usersId: 12321,
});

addCustomer()

Adds a customer to the organization.

Example:

await clockodo.addCustomer({ name: "Weyland-Yutani" });

addEntry()

Creates an entry for either the user attached to the Clockodo instance or the passed in usersId. Depending on the type of entry different properties are required:

Type of entryRequired properties
Manual time entrycustomersId, servicesId, billable, timeSince, timeUntil
Lumpsum value entrycustomersId, servicesId, billable, timeSince, lumpsum
Lumpsum service entrycustomersId, lumpsumServicesAmount, lumpsumServicesId, billable, timeSince

Example:

import { Billability } from "clockodo";

await clockodo.addEntry({
  customersId: 1,
  servicesId: 2,
  billable: Billability.Billable,
  timeSince: "2018-10-01T00:00:00Z",
  timeUntil: "2018-10-01T03:00:00Z",
});

addProject()

Creates a project for an existing customer.

Example:

await clockodo.addProject({ name: "Clockodo Api Wrapper", customersId: 1 });

addService()

Adds to the list of services offered by your organization.

Example:

await clockodo.addService({ name: "Thinking" });

addTeam()

Creates a new team under your organization.

Example:

await clockodo.addTeam({ name: "Gold Team" });

addUser()

Creates new user in organization.

Example:

import { UserRole } from "clockodo";

await clockodo.addUser({
  name: "Merkel",
  number: "08",
  email: "angela@eu.eu",
  role: UserRole.Owner,
});

startClock()

Start a new running clockodo entry.

Example:

import { Billability } from "clockodo";

await clockodo.startClock({
  customersId: 24,
  servicesId: 7,
  projectsId: 365,
  billable: Billability.Billable,
});

Put methods

changeClockDuration()

Changes the duration of an entry. Because the ID returned by clock methods is just the entry ID, and this function can only be used after an entry is finished, there seems to be no difference from using editEntry().

Example:

await clockodo.changeClockDuration({
  entriesId: 7082,
  duration: 540,
  durationBefore: 300,
});

editAbsence()

Edit existing Clockodo absence.

Example:

await clockodo.editAbsence({ id: 74, note: "I know what he did last summer" });

editCustomer()

Edit existing Clockodo customer.

Example:

await clockodo.editCustomer({ id: 15, name: "The Mystery Gang" });

editEntry()

Changes the values of a Clockodo entry. Unlike changeClockDuration(), editEntry() can seemingly mutate any of the accepted parameters even when the entry is running.

Example:

await clockodo.editEntry({ id: 365, duration: 540 });

editEntryGroup()

Allows for mass edit of entries based on a set of filters.

Example:

import { Billability } from "clockodo";

await clockodo.editEntryGroup({
  timeSince: "2017-08-18T00:00:00Z",
  timeUntil: "2018-02-09T00:00:00Z",
  filterText: "Browsing Reddit",
  billable: Billability.NotBillable,
});

editProject()

Edit existing project.

Example:

await clockodo.editProject({ id: 20, name: "Awesome new project" });

editService()

Edit existing service.

Example:

await clockodo.editService({ id: 23, name: "Room Service" });

editTeam()

Edit existing team.

Example:

await clockodo.editTeam({ id: 6324, name: "New Team Name" });

editUser()

Edit existing user.

Example:

await clockodo.editUser({ id: 33, name: "Moalo Loco" });

Delete methods

deleteCustomer()

Deletes the customer.

Example:

await clockodo.deleteCustomer({ id: 343 });

deleteProject()

Deletes the project.

Example:

await clockodo.deleteProject({ id: 8 });

deleteService()

Deletes the service.

Example:

await clockodo.deleteService({ id: 94 });

deleteUser()

Deletes user.

Example:

await clockodo.deleteUser({ id: 7 });

deleteAbsence()

Deletes absence (go figure).

Example:

await clockodo.deleteAbsence({ id: 31 });

deleteEntry()

Deletes a single entry by ID

Example:

await clockodo.deleteEntry({ id: 543512 });

deleteTeam()

Deletes a team by ID

Example:

await clockodo.deleteTeam({ id: 764 });

deleteEntryGroup()

Deletes one or more entries based on a series of filters that builds an "entry group".

Example:

await clockodo.deleteEntryGroup({
  timeSince: "2017-08-18T00:00:00Z",
  timeUntil: "2018-02-09T00:00:00Z",
  text: "chilin everyday",
});

register()

Creates a new clockodo account.

Example:

await clockodo.register({
  companiesName: "Acme Corporation",
  name: "Road Runner",
  email: "runner@acme.com",
});

stopClock()

Stops a running clock/entry.

Example for self:

await clockodo.stopClock({ entriesId: 7082 });

Example for another user (needs requesting user to be owner):

await clockodo.stopClock({ entriesId: 7082, usersId: 123 });

Development

To run integration tests you need to create an .env by copying the .env.example and entering credentials of a dev-user, as you don't want to mess up your real clockodo data.

License

MIT

Sponsors

23.5.1

5 months ago

23.4.0

5 months ago

23.0.0

5 months ago

22.2.0

6 months ago

21.4.0

10 months ago

21.8.0

8 months ago

21.12.0

7 months ago

23.5.0

5 months ago

23.1.0

5 months ago

21.9.0

8 months ago

21.5.1

9 months ago

21.5.0

10 months ago

21.13.0

6 months ago

23.2.0

5 months ago

22.0.0

6 months ago

21.6.0

9 months ago

21.10.3

8 months ago

21.10.2

8 months ago

21.10.1

8 months ago

21.10.0

8 months ago

21.14.0

6 months ago

21.10.4

7 months ago

23.3.0

5 months ago

22.1.0

6 months ago

21.3.0

10 months ago

21.7.0

9 months ago

21.11.0

7 months ago

21.15.0

6 months ago

21.1.0-beta.1

11 months ago

21.1.0

11 months ago

21.2.0

11 months ago

21.0.1

1 year ago

21.0.0

1 year ago

21.0.0-beta.1

1 year ago

20.0.0

1 year ago

20.0.0-beta.9

1 year ago

20.0.0-beta.8

1 year ago

20.0.0-beta.7

1 year ago

20.0.0-beta.6

1 year ago

20.0.0-beta.5

1 year ago

20.0.0-beta.4

1 year ago

20.0.0-beta.10

1 year ago

20.0.0-beta.11

1 year ago

20.0.0-beta.3

1 year ago

19.2.0-beta.3

1 year ago

19.2.0-beta.4

1 year ago

19.2.0-beta.5

1 year ago

19.2.0-beta.6

1 year ago

20.0.0-beta.2

1 year ago

20.0.0-beta.1

1 year ago

19.1.1-beta.1

1 year ago

19.2.0-beta.1

1 year ago

19.2.0-beta.2

1 year ago

19.1.0

1 year ago

19.1.2

1 year ago

19.0.0

1 year ago

18.2.0

1 year ago

18.3.0-beta.1

1 year ago

18.1.1-beta.1

2 years ago

18.1.0

2 years ago

18.1.0-beta.2

2 years ago

18.1.0-beta.1

2 years ago

18.0.0-beta.1

2 years ago

15.0.0

2 years ago

17.0.0

2 years ago

13.1.0

2 years ago

18.0.0

2 years ago

14.0.0

2 years ago

14.0.1

2 years ago

16.0.0

2 years ago

13.0.0-beta.1

2 years ago

13.0.0

2 years ago

12.0.0

2 years ago

12.1.0

2 years ago

12.0.0-beta.1

2 years ago

10.2.0

2 years ago

11.0.0

2 years ago

10.1.4

2 years ago

10.1.5

2 years ago

10.1.6

2 years ago

10.1.1

2 years ago

10.3.0

2 years ago

10.1.2

2 years ago

10.3.1

2 years ago

10.1.3

2 years ago

10.0.0

2 years ago

9.7.2

2 years ago

9.7.1

2 years ago

10.1.0

2 years ago

10.0.0-beta.2

2 years ago

10.0.0-beta.3

2 years ago

10.0.0-beta.1

2 years ago

9.6.1

2 years ago

9.7.0

2 years ago

9.6.0

2 years ago

9.5.2

3 years ago

9.4.0

3 years ago

9.5.1

3 years ago

9.5.0

3 years ago

9.3.0

3 years ago

9.2.0

3 years ago

9.1.1

3 years ago

9.1.0

3 years ago

9.0.0-beta.2

3 years ago

9.0.0-beta.1

3 years ago

9.0.0

3 years ago

8.1.0-beta.14

3 years ago

8.1.0-beta.13

3 years ago

8.1.0-beta.10

3 years ago

8.1.0-beta.12

3 years ago

8.1.0-beta.11

3 years ago

8.1.0-beta.9

3 years ago

8.1.0-beta.8

3 years ago

8.1.0-beta.7

3 years ago

8.1.0-beta.6

3 years ago

8.1.0-beta.5

3 years ago

8.1.0-beta.4

3 years ago

8.1.0-beta.3

3 years ago

8.1.0-beta.2

3 years ago

8.1.0-beta.1

3 years ago

8.0.7

3 years ago

8.0.6

3 years ago

8.0.5

3 years ago

8.0.4

3 years ago

8.0.3

3 years ago

8.0.1

3 years ago

8.0.0

3 years ago

8.0.2

3 years ago

7.0.0

3 years ago

7.0.0-beta.8

3 years ago

7.0.0-beta.7

4 years ago

7.0.0-beta.6

4 years ago

7.0.0-beta.4

4 years ago

7.0.0-beta.5

4 years ago

7.0.0-beta.2

4 years ago

7.0.0-beta.3

4 years ago

7.0.0-beta.1

4 years ago

6.0.2

4 years ago

6.0.2-beta.1

4 years ago

6.0.1

4 years ago

5.0.0

4 years ago

6.0.0

4 years ago

4.1.0

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

3.2.0

4 years ago

3.1.6

5 years ago

3.1.5

5 years ago

3.1.4

5 years ago

3.1.3

5 years ago

3.1.2

5 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.0

6 years ago

2.0.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago