This document provides a detailed explanation of all features and their usage in the Timing API Client.
Before using any API functions, you need to initialize the client with your API key.
import { TimingClient } from "timing-api-client";
// Basic initialization
const client = new TimingClient({
apiKey: "YOUR_API_KEY", // Required
});
// Advanced initialization with options
const clientWithOptions = new TimingClient({
apiKey: "YOUR_API_KEY",
baseURL: "https://web.timingapp.com/api/v1", // Optional, this is the default
timeout: 30000, // Optional, timeout in milliseconds (default is 10000)
});Start a new running timer.
const timer = await client.timeEntries.start({
project: "/projects/123", // Required - reference to a project
title: "Working on feature X", // Optional
notes: "Implementing the login system", // Optional
startDate: "2023-01-01T10:00:00+00:00", // Optional, defaults to now
replaceExisting: false, // Optional, defaults to false
});| Name | Type | Required | Description |
|---|---|---|---|
| project | string | Yes | Reference to a project (format: '/projects/{id}') |
| title | string | No | Title of the time entry |
| notes | string | No | Notes for the time entry |
| startDate | string | No | Start date in ISO 8601 format. Defaults to the current time |
| replaceExisting | boolean | No | If true, overlapping time entries will be adjusted or deleted |
A TimeEntry object with the newly created timer.
Stop the currently running timer.
const stoppedTimer = await client.timeEntries.stop();A TimeEntry object with the stopped timer.
Create a new time entry for a specific time range.
const timeEntry = await client.timeEntries.create({
project: "/projects/123", // Required - reference to a project
startDate: "2023-01-01T10:00:00+00:00", // Required
endDate: "2023-01-01T12:00:00+00:00", // Required
title: "Meeting with team", // Optional
notes: "Weekly planning meeting", // Optional
replaceExisting: false, // Optional, defaults to false
});| Name | Type | Required | Description |
|---|---|---|---|
| project | string | Yes | Reference to a project (format: '/projects/{id}') |
| startDate | string | Yes | Start date in ISO 8601 format |
| endDate | string | Yes | End date in ISO 8601 format |
| title | string | No | Title of the time entry |
| notes | string | No | Notes for the time entry |
| replaceExisting | boolean | No | If true, overlapping time entries will be adjusted or deleted |
A TimeEntry object with the newly created time entry.
Get a list of time entries.
// Get all time entries
const allEntries = await client.timeEntries.list();
// Get time entries with filter
const filteredEntries = await client.timeEntries.list({
from: "2023-01-01",
to: "2023-01-31",
project: "/projects/123",
});| Name | Type | Required | Description |
|---|---|---|---|
| query | object | No | Query parameters to filter the results |
An array of TimeEntry objects.
Get a specific time entry by ID.
const timeEntry = await client.timeEntries.get("123");| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | ID of the time entry to get |
A TimeEntry object.
Update a specific time entry.
const updatedEntry = await client.timeEntries.update("123", {
title: "Updated title",
notes: "Updated notes",
});| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | ID of the time entry to update |
| data | object | Yes | Data to update. You can update any properties of a time entry |
A TimeEntry object with the updated data.
Delete a specific time entry.
await client.timeEntries.delete("123");| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | ID of the time entry to delete |
Void.
Get a list of projects.
// Get all projects
const allProjects = await client.projects.list();
// Get projects with filter
const filteredProjects = await client.projects.list({
parentId: "123",
});| Name | Type | Required | Description |
|---|---|---|---|
| query | object | No | Query parameters to filter the results |
An array of Project objects.
Get a specific project by ID.
const project = await client.projects.get("123");| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | ID of the project to get |
A Project object.
Create a new project.
const project = await client.projects.create({
title: "New Project", // Required
color: "#FF0000", // Optional
parent: "/projects/123", // Optional
notes: "Project notes", // Optional
customFields: {
// Optional
clientId: "456",
department: "Engineering",
},
});| Name | Type | Required | Description |
|---|---|---|---|
| title | string | Yes | Project title |
| color | string | No | Hex color code for the project |
| parent | string | No | Reference to a parent project |
| notes | string | No | Project notes |
| rate | number | No | Project billing rate |
| customFields | object | No | Custom fields for the project |
A Project object with the newly created project.
Update a specific project.
const updatedProject = await client.projects.update("123", {
title: "Updated Project",
notes: "Updated notes",
});| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | ID of the project to update |
| data | object | Yes | Data to update. You can update any properties of a project |
A Project object with the updated data.
Delete a specific project.
await client.projects.delete("123");| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | ID of the project to delete |
Void.
Get time entries for a specific project.
// Get all time entries for a project
const projectEntries = await client.projects.getTimeEntries("123");
// Get time entries with filter
const filteredProjectEntries = await client.projects.getTimeEntries("123", {
from: "2023-01-01",
to: "2023-01-31",
});| Name | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | ID of the project |
| query | object | No | Query parameters to filter the results |
An array of TimeEntry objects associated with the project.
The client throws an ApiError for API-related errors. You can handle these errors to get more details about what went wrong.
try {
const projects = await client.projects.list();
} catch (error) {
if (error.status === 401) {
console.error("Authentication error:", error.message);
} else if (error.status === 404) {
console.error("Resource not found:", error.message);
} else {
console.error("An error occurred:", error.message);
}
}If you need to make a request that isn't covered by the provided resources, you can use the request method on the client directly.
// Custom GET request
const data = await client.request({
method: "get",
url: "/custom-endpoint",
params: { query: "value" },
});
// Custom POST request
const result = await client.request({
method: "post",
url: "/custom-endpoint",
data: { key: "value" },
});