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

mews-sdk

v1.0.0

Published

A TypeScript SDK for interacting with the Mews API, with dual ESM/CJS builds and type declarations.

Readme

Mews SDK

This is an unofficial TypeScript SDK for interacting with the Mews connector API, with dual ESM/CJS builds and type declarations.

Installation

npm install mews-sdk
# or
yarn add mews-sdk
# or
pnpm add mews-sdk

Basic usage example

import { ApiCall, AccountingCategories, type Api } from 'mews-sdk';

const tenant: Api.Tenant = {
  AccessToken: 'myAccessToken',
  ClientToken: 'myClientToken',
  Client: 'myClient',
  ApiUrl: 'https://mews.li/api/connector/v1',
};

const call = new ApiCall(tenant, 'getAllAccountingCategories', {});
const categories = await AccountingCategories.getAll(call);
console.log(categories);

Imports

Types and runtime services can both be imported from mews-sdk in ESM or CJS fashion. All runtime services are directly imported at the root level and all types are imported under the 'Api' namespace.

//Runtime services
import { ApiCall, AccountingCategories } from 'mews-sdk';
//Types
import { type Api } from 'mews-sdk';

Connection credentials

Mews connection credentials and URL must be stored in a Tenant object that you can extend from Api.Tenant.

import { type Api } from 'mews-sdk';

interface MyTenant extends Api.Tenant {
  mydata?: string;
  //more of your data...
}
const tenant: MyTenant = {
  AccessToken: 'put_your_access_token_here',
  ClientToken: 'put_your_client_token_here',
  Client: 'put_your_client_description_here',
  ApiUrl: 'put_your_mews_api_base_url_here',
  mydata: 'mydata',
  //more of your data....
};

Api configuration

You can define api configuration options if desired. All errors will be thrown as exceptions that can be caught by plugging in your own logger callbacks. This api configuration parameter is optional and defaults to the following values when omitted:

import { type Api } from 'mews-sdk';

const config: Api.Config = {
  timeoutMs: 30000,
  retryPolicy: {
    maxRetries: 3,
    baseDelayMs: 500,
    retryableStatusCodes: [429, 500, 502, 503, 504],
    retryOnNetworkErrors: true,
    jitter: true,
  },
  logger: null,
};

Defining the call

First you need to define your operation. The possible operations can easily be inferred from the Mews API documentation or by simple inspection of the Api.Ops type.

import { type Api } from 'mews-sdk';
const apiOp: Api.Ops = 'getAllAccountingCategories';

The easiest way to define your call is by using the ApiCall helper. This helper will inject your connection credentials and URLs from the provided Tenant, type the request according to the provided operation and also provide sensible defaults for omitted generic request fields whenever possible; for example in the case of pagination it will provide by default a null Cursor and a page Count of 100. Any request fields different from the credentials can be overriden in the third parameter.

import { ApiCall } from 'mews-sdk';
//Define an api call using ApiCall and overriding default page size.
const call = new ApiCall(tenant, apiOp, {
  Limitation: {
    Count: 30, // Cursor defaults to null
  },
});

Should you ever wish to you can also directly type your request body without using the helper but in that case you must provide all required fields.

import { ApiCall, type Api } from 'mews-sdk';
//Directly type a request
const request: Api.AccountingCategories.GetAllRequest = {
  // All required fields must be provided:
  AccessToken: 'accessToken',
  ClientToken: 'clientToken',
  Client: 'client',
  Limitation: {
    Cursor: null,
    Count: 30,
  },
};
//config is optional:
const call = new ApiCall(tenant, apiOp, request, config);

Calling the Api

There are two ways to call the Api: using the ApiCall object or using dedicated endpoint function helpers. The helper functions are slightly more ergonomic but use some predetermined settings: they will automatically return paginated aggregated results for all endpoints supporting pagination and they will also internally scope the result when the api response objects are simple. The ApiCall object is less opinionated: it always returns unscoped bare responses and allows you more control over pagination by calling send() for a single unpaginated result or sendAll() for a paginated aggregated result.

import { AccountingCategories, ApiCall } from 'mews-sdk';

const call = new ApiCall(tenant, apiOp, request);

// Helper function call:
const aggregatedCategories = await AccountingCategories.getAll(call);

//ApiCall Object call:
const unPaginatedResponse = await call.send();
const aggregatedCategories = (await call.sendAll()).AccountingCategories;