NetSuite API Client

1.0.3 · active · verified Tue Apr 21

The `netsuite-api-client` package provides a robust interface for interacting with NetSuite's SuiteTalk Web Services, specifically focusing on REST calls and SuiteQL queries. It is currently at stable version `1.0.3` and demonstrates an active release cadence with frequent patch updates addressing dependencies and minor fixes. This library distinguishes itself as a direct fork and merge of the formerly popular `netsuite-rest` and `suiteql` packages, specifically designed to address their limitations. Key differentiators include its ESM-only nature, comprehensive TypeScript typings, and the integration of updated dependencies like `got` to mitigate recent CVEs. It is explicitly maintained and supported, offering a more modern and secure alternative for NetSuite integrations. The package supports promise-based operations for standard REST `request` calls and `query` executions, along with a `queryAll` streaming mechanism for efficiently handling large datasets, which is crucial for enterprise-level data operations. Error handling has also been significantly improved to directly surface NetSuite-specific messages.

Common errors

Warnings

Install

Imports

Quickstart

Instantiates the NetSuite API client using token-based authentication and performs a basic GET request for customer data, followed by a SuiteQL query.

import { NetsuiteApiClient } from 'netsuite-api-client';

async function runNetsuiteOperations() {
  const client = new NetsuiteApiClient({
    consumer_key: process.env.NETSUITE_CONSUMER_KEY ?? '',
    consumer_secret_key: process.env.NETSUITE_CONSUMER_SECRET_KEY ?? '',
    token: process.env.NETSUITE_TOKEN ?? '',
    token_secret: process.env.NETSUITE_TOKEN_SECRET ?? '',
    realm: process.env.NETSUITE_REALM ?? '',
    base_url: process.env.NETSUITE_BASE_URL ?? ''
  });

  try {
    // Perform a GET request to fetch customer records
    const response = await client.request({
      path: 'record/v1/customer/',
      method: 'GET'
    });
    console.log('Customer data:', response.data.links);

    // Perform a SuiteQL query
    const transactions = await client.query("select id from transaction where rownum <= 5");
    console.log('Transactions:', transactions);

  } catch (err) {
    console.error('Netsuite API Error:', err.message);
  }
}

runNetsuiteOperations();

view raw JSON →