npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@moritzmyrz/tripletex.js

v0.1.5

Published

TypeScript SDK for the Tripletex API

Readme

tripletex.js

TypeScript SDK for the Tripletex API.

Default API base URL: https://tripletex.no/v2 (prod)

Install

npm install @moritzmyrz/tripletex.js

Quick start

import TripletexClient from '@moritzmyrz/tripletex.js';

const client = new TripletexClient();

const session = await client.createSessionToken({
  consumerToken: process.env.TRIPLETEX_CONSUMER_TOKEN!,
  employeeToken: process.env.TRIPLETEX_EMPLOYEE_TOKEN!,
});

client.useSessionToken(session.token, 0);

const customers = await client.Customer_search({
  query: { from: 0, count: 100, fields: 'id,name' },
});

Use test environment by setting environment: 'test':

const client = new TripletexClient({
  environment: 'test',
});

TypeScript infers request and response types per operation directly from the OpenAPI spec:

const company = await client.Company_get({
  path: { id: 123 },
  query: { fields: 'id,name' },
});
// company is typed as ResponseWrapperCompany

Typed usage cookbook

import TripletexClient from '@moritzmyrz/tripletex.js';

const client = new TripletexClient({
  sessionToken: process.env.TRIPLETEX_SESSION_TOKEN!,
  companyId: 0,
});

// 1) Get one by id (required path params are enforced)
const activity = await client.Activity_get({
  path: { id: 123 },
});

// 2) Search/list (query keys are operation-specific)
const customers = await client.Customer_search({
  query: {
    from: 0,
    count: 100,
    fields: 'id,name',
    isInactive: false,
  },
});

// 3) Create/update (required body is enforced)
await client.Company_put({
  body: {
    id: 1,
  },
});

// 4) Access transport metadata when needed
const withMeta = await client.Country_searchWithMeta({
  query: { count: 10 },
});
console.log(withMeta.meta.requestId);

For query arrays, repeat the same query key by passing an array value:

await client.Contact_search({
  query: {
    id: ['1', '2', '3'],
  },
});

Authentication

Tripletex expects Basic auth where username is companyId (or 0) and password is sessionToken. This client handles that for you after useSessionToken() or createSessionToken().

The recommended session-token endpoint is used:

  • POST /token/session/:create

Pagination and envelope handling

List endpoints usually accept:

  • from
  • count
  • sorting
  • fields

The API often wraps payloads in value or values. The generated endpoint methods return the raw payload from Tripletex so you can inspect all envelope fields, including paging metadata.

Rate limits and retries

Tripletex returns:

  • X-Rate-Limit-Limit
  • X-Rate-Limit-Remaining
  • X-Rate-Limit-Reset

For 429 responses, the base transport retries automatically up to maxRateLimitRetries (default 1) using X-Rate-Limit-Reset as delay guidance.

Response metadata

Every *WithMeta method returns:

  • payload (data)
  • transport metadata (meta) including:
    • requestId (x-tlx-request-id)
    • rate-limit headers

Full API surface

All OpenAPI operations from the OpenAPI specs are generated into typed method signatures and grouped into resource mixins:

  • each method has operation-specific path, query, and body argument types
  • required path/body parameters are enforced at compile time
  • each method returns the exact success payload type from the spec

Regenerate from production spec:

npm run generate:resources

Regenerate from test spec:

npm run generate:resources:test

Development

npm install
npm run generate:resources
npm run check
npm run build

References