Skip to content

A community developed Typescript API wrapper around the Teamleader Focus V2 API.

Notifications You must be signed in to change notification settings

Coachall/teamleader-node-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Teamleader Node Client

A community developed API wrapper around the V2 Teamleader Focus API. This package is completely written in Typescript and uses Zod for schema validation and Axios for requests.

WARNING: This package is currently marked as 'experimental' and 'in development' and should be used at your own risk.

Endpoints wille be added whenever I need them in production / have some spare time. You can help speed up development by submitting a pull request

Available endpoints

  • General âś…
    • âś… Departments (list, info)
    • âś… Users (me, list, info)
    • âś… Teams (list)
    • âś… Custom Fields (list, info)
    • âś… Work Types (list)
  • CRM 👷‍♂️
    • âś… Contacts (list, info, add, update, delete, tag, untag, linkToCompany, unlinkFromCompany, updateCompanyLink)
    • âś… Companies (list, info, add, update, delete, tag, untag)
    • 👷‍♂️ Business Types
    • 👷‍♂️ Tags
    • 👷‍♂️ Addresses
  • Deals 👷‍♂️
    • 👷‍♂️ Deals (list, info, create, update, move, win, lose, delete, lostReasonsList )
    • 👷‍♂️ Quotations (list, info, download, create, send, update, accept, delete )
  • Calendar 👷‍♂️
    • 👷‍♂️ Events (list, info, create, update, cancel )
    • Activity Types
  • Invoicing 👷‍♂️
    • âś… Tax Rates (list)
  • Products âś… (list, info, add)
  • Projects
  • Tasks
  • Time Tracking
  • Files
  • Other 👷‍♂️
    • 👷‍♂️ Migrate (id, taxRate, ActivityType )
    • âś… Webhooks (register, list, unregister)

Installation

npm i @coachall/teamleader-node-client
yarn add @coachall/teamleader-node-client

Initialize the client:

import TLclient from "@coachall/teamleader-node-client";

/*
The initial configuration of the client.
You will need to manage refresh and access tokens yourself with the callback function.
It is advised to use a lightweight database to store these (eg: Lowdb, SQLite)
*/

const config = {
  client_id: string,
  client_secret: string,
  refresh_token: string,
  access_token: string,
  redirect_uri: string,
  //callback function fires when a new token pair is requested. Use the results to overwrite the refresh_token and access_token above
  callback: (e) => {
    e.access_token: string
    e.refresh_token: string,
    e.token_type: string,
    e.expires_in: number,
  },
};

const client = new TLclient(config);

Examples

// Get all departments
const departments = await client.departmentsList();

console.log(departments);

/* ---- RESULT----
{
data: [
        {
            id: 'c506e35a-2177-0626-865f-c1fcdfgc2bd21',
            name: 'Coachall BV',
            currency: 'EUR',
            vat_number: 'BE 0743.533.110',
            emails: [Array],
            status: 'active'
        }
    ]
}
*/

// Get a single department

const ourDepartment = await client.departmentsInfo(
	"c506e35a-2177-0626-865f-c1fcdfgc2bd21"
);

console.log(ourDepartment);

/* ---- RESULT----
{
data: {
        id: 'c506e35a-2177-0626-865f-c1fcdfgc2bd21',
        name: 'Coachall BV',
        currency: 'EUR',
        vat_number: 'BE 0743.533.110',
        emails: [Array],
        status: 'active'
      }
}
*/

// Filter the departments

const filteredDepartments = await client.departmentsList({
	filter: {
		status: "archived",
	},
});

console.log(filteredDepartments);

/* ---- RESULT----
{
data: []
}
*/

Endpoints

General (9/9)

Departments

Departments are used to split quotations and invoices for different legal entities or within one organisation. https://developer.teamleader.eu/#/reference/general/departments

List

Get a list of departments. https://developer.teamleader.eu/#/reference/general/departments/departments.list

const departments: Promise<DepartmentsListResponse> = await client.departmentsList(params?: DepartmentsListParams);

Info

Get details for a single department. https://developer.teamleader.eu/#/reference/general/departments/departments.info

const departmentsInfo: Promise<DepartmentsInfoResponse> = await client.departmentsList(id: Uuid);

Users

Users are co-workers in a Teamleader account. https://developer.teamleader.eu/#/reference/general/users

Me

Get the current authenticated user. https://developer.teamleader.eu/#/reference/general/users/users.me

const me: Promise<UsersMe> = await client.usersMe();

List

Get a list of all users. https://developer.teamleader.eu/#/reference/general/users/users.list

const userList: Promise<UsersList> = await client.usersList(params?: UsersListParams);

Info

Get details for a single user. https://developer.teamleader.eu/#/reference/general/users/users.info

const userInfo: Promise<UsersInfo> = await client.usersInfo(id: Uuid);

Teams

https://developer.teamleader.eu/#/reference/general/teams

List

Get a list of all teams. https://developer.teamleader.eu/#/reference/general/users/teams.list

const teams: Promise<TeamsList> = await client.teamsList();

Custom Fields

Custom fields are used to add additional data/properties to entities within Teamleader. https://developer.teamleader.eu/#/reference/general/custom-fields

List

Get a list of all the definitions of custom fields. https://developer.teamleader.eu/#/reference/general/custom-fields/customfielddefinitions.list

const customfields: Promise<CustomFieldDefinitionsList> = await client.customFieldDefinitionsList(params?: CustomFieldDefinitionsListParams);

Info

Get info about a specific custom field definition. https://developer.teamleader.eu/#/reference/general/custom-fields/customfielddefinitions.info

const customfieldInfo: Promise<CustomFieldDefinitionsInfo> = await client.customFieldDefinitionsInfo(id: Uuid);

Work Types

Work types define the type of work for events or time tracking. Hourly rates can be added to work types, so that the work can be billed to a customer. https://developer.teamleader.eu/#/reference/general/work-types

List

Get a list of all the definitions of custom fields. https://developer.teamleader.eu/#/reference/general/work-types/worktypes.list

const worktypes: Promise<WorkTypesList> = await client.workTypesList(params?: WorkTypesListParams);

CRM (17/20)

Contacts

Contacts are physical entities who are added to your CRM database. Contacts might be linked to one or more companies. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.list

List

Get a list of contacts. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.list

const contacts: Promise<ContactsListResponse> = await client.contactsList(params?: ContactsListParams);

Info

Get details for a single contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.info

const contact: Promise<ContactsInfoResponse> = await client.contactsInfo(id: Uuid);

Add

Add a new contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.add

const addContact: Promise<contactsAddResponse> = await client.contactsAdd(body: ContactsAdd);

Update

Update a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.update

const updateContact: Promise<null> = await client.contactsUpdate(body: ContactsUpdate);

Delete

Delete a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.delete

const deleteContact: Promise<null> = await client.contactsDelete(body: ContactsDelete);

Tag

Add a new or existing tag to a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.tag

const tagContact: Promise<null> = await client.contactsTag(body: ContactsTag);

Untag

Remove a tag from a contact. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.untag

const untagContact: Promise<null> = await client.contactsUntag(body: ContactsUntag);

Link to company

Link a contact to a company. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.linktocompany

const linkContact: Promise<null> = await client.contactsLinkToCompany(body: ContactsLinkToCompany);

Unlink from company

Unlink a contact from a company. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.unlinkfromcompany

const unlinkContact: Promise<null> = await client.contactsUnlinkFromCompany(body: ContactsUnlinkFromCompany);

Update company link

Update contact to company link. https://developer.teamleader.eu/#/reference/crm/contacts/contacts.updatecompanylink

const updateCompanyLink: Promise<null> = await client.contactsUpdateCompanyLink(body: ContactsUpdateCompanyLink);

About

A community developed Typescript API wrapper around the Teamleader Focus V2 API.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published