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

netsuite-auth2

v1.0.1

Published

A Node.js package for authenticating and calling NetSuite REST Web Services using OAuth 2.0.

Readme

NetSuite OAuth2 API Client

A Node.js package for authenticating and calling NetSuite REST Web Services using OAuth 2.0.

Installation

npm install netsuite-auth2

Features

  • Authenticate with NetSuite using OAuth 2.0 (M2M authentication)
  • Cache access tokens for reuse
  • Invoke NetSuite REST Web Services easily

Usage

Import the Package

const NetSuiteWebServices = require("netsuite-auth2");

Initialize the Client

const netsuiteClient = new NetSuiteWebServices(
  "your_account_id",  // NetSuite Account ID
  "your_client_id",   // OAuth 2.0 Client ID
  "your_certificate_id", // Certificate ID
  "your_private_key", // Private Key (PEM format)
  3600,                // Token TTL (in seconds)
  "RS256"             // Signing Algorithm
);

Call a NetSuite API

(async () => {
  try {
    const response = await netsuiteClient.invokeAPI(
      "/record/v1/customer", // API path
      "GET", // HTTP method
      { limit: 10 }, // Query parameters
      null // Request body (if needed)
    );
    console.log(response.data);
  } catch (err) {
    console.error("Error calling NetSuite API:", err);
  }
})();

API Reference

NetSuiteWebServices Constructor

Creates an instance of the NetSuite API client.

new NetSuiteWebServices(accountId, clientId, certificateId, privateKey, ttl, algorithm);

Parameters:

  • accountId (string): NetSuite account ID (replace _ with -).
  • clientId (string): OAuth 2.0 Client ID.
  • certificateId (string): Certificate ID used for authentication.
  • privateKey (string): Private key for signing JWT.
  • ttl (number): Token time-to-live (TTL) in seconds.
  • algorithm (string): JWT signing algorithm (e.g., RS256).

invokeAPI(path, method, queryParams, body)

Invokes a NetSuite API with authentication.

Parameters:

  • path (string): The NetSuite API endpoint.
  • method (string): HTTP method (GET, POST, PUT, etc.).
  • queryParams (object, optional): Query parameters.
  • body (object, optional): Request body.

Returns:

  • Promise<Axios.Response>: The API response.

getNetSuiteRestWebServicesHomeUrl()

Returns the base URL for NetSuite REST Web Services.

const url = netsuiteClient.getNetSuiteRestWebServicesHomeUrl();
console.log(url);

Authentication Flow

  1. Generate a JWT assertion token using the client ID, certificate ID, and private key.
  2. Request an OAuth 2.0 access token from NetSuite.
  3. Store the access token in cache for reuse.
  4. Use the access token to authenticate API calls.

Dependencies

  • axios - For making HTTP requests.
  • jsonwebtoken - For generating and signing JWT tokens.

License

This project is licensed under the ISC License.

Author

Created by Naresh Kollipora.