Registry / crm-productivity / netsuite-api-client

netsuite-api-client

JSON →
library1.0.3jsnpmunverified

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.

npm install netsuite-api-client
INSTALL
IMPORT
SIG · NETSUITE-API-CLIEN
N
netsuite-api-client
crm-productivityjavascriptv1.0.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

NetsuiteApiClient
import { NetsuiteApiClient } from 'netsuite-api-client';
const NetsuiteApiClient = require('netsuite-api-client');
This package is ESM-only since v1.0.0. CommonJS `require` statements will fail. Projects must be configured for ESM or use dynamic `import()`.

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();
Debug
Known issues
breakingThe package transitioned to ESM-only starting from version 1.0.0. Existing projects using CommonJS `require()` syntax will break and require migration to ESM `import` statements.
fix
Refactor `require()` statements to `import` statements. Ensure your `package.json` contains `"type": "module"` or use `.mjs` file extensions for ESM files.
affects: >=1.0.0
breakingIn v1.0.0, the `result()` method (internally used by `request()`) changed its return structure. The parsed JSON data is now encapsulated within a `data` property of the response object, where previously it might have been directly returned.
fix
Update your code to access `response.data` instead of `response` directly when handling results from `client.request()` calls.
affects: =1.0.0
gotchaStarting with v0.1.4, error messages from NetSuite are directly surfaced in the `Error` object's `message` property. This simplifies error handling by removing the need to parse the underlying `got` `HttpError` object for NetSuite-specific details.
fix
Access NetSuite specific error details via `err.message` directly. Avoid deeply inspecting properties like `err.response.body` which may contain the less-parsed `got` error.
affects: >=0.1.4
Errors
Common errors & fixes
Invalid search query. Detailed unprocessed description follows. Search error occurred: Unknown identifier 'not_existing_field'.
Attempting to query a non-existent, misspelled, or inaccessible field in a SuiteQL query.
fix
Verify the field names in your SuiteQL query against NetSuite's schema and ensure the integration role has appropriate permissions. Use `client.request({ path: "record/v1/metadata-catalog/" })` to inspect available resources and fields.
TypeError: NetsuiteApiClient is not a constructor
This error typically occurs when attempting to import an ESM-only package using CommonJS `require()` syntax in a Node.js environment not configured for ESM.
fix
Ensure your project is configured for ESM by setting `"type": "module"` in your `package.json` file. Change `const NetsuiteApiClient = require('netsuite-api-client');` to `import { NetsuiteApiClient } from 'netsuite-api-client';`.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
gotrequiredCore HTTP client for making requests, frequently updated for security and features.
Agent activity
24 hits · last 30 days
node
20
OpenAI (training)
1
Resources
netsuite-api-client — npm install netsuite-api-client · libregistry