ns-fetch
v1.0.0
Published
A flexible CLI for NetSuite SuiteTalk REST Record API, supporting CRUD operations, bulk import from JSON/CSV/Excel, and customizable header/value mapping.
Readme
ns-fetch CLI
ns-fetch is a Node.js command-line tool for interacting with NetSuite's SuiteTalk REST Record API. It supports full CRUD operations, bulk imports from JSON/CSV/Excel, header and value mapping, and more.
Features
- CRUD: Create, Read, Update, Delete records
- Bulk Create: from JSON file (
--bulkFile) orcreatesubcommand - Import: CSV/Excel import with header and value mapping
- Field Selection: fetch only specific fields (
--fields) - Pagination: list records with
--limitand--offset - OAuth 1.0a: secure SuiteTalk authentication
Installation
# clone or npm install globally
npm install -g ns-fetch
# or locally
git clone <repo>
cd ns-fetch
npm install
npm linkConfiguration
Initialize your NetSuite OAuth credentials:
ns-fetch initYou will be prompted to enter:
- Consumer Key
- Consumer Secret
- Token
- Token Secret
- Realm (Account ID)
These are saved in ~/.nsfetch-config.json with restricted permissions.
Usage
All commands follow the pattern:
ns-fetch [init|get|create|update|delete|import|bulk] [options]GET (Read)
Fetch a single record:
ns-fetch --type customer --id 12345Fetch specific fields:
ns-fetch --type so --id 31099 --fields "memo,entity"List records (paginated):
ns-fetch --type customer --limit 200 --offset 400CREATE
Create a single record with inline JSON:
ns-fetch create --type customer \
--data '{"companyName":"Acme Corp","subsidiary":{"id":1}}'Bulk create from JSON file:
ns-fetch create --type customer --bulkFile customers.jsonUPDATE
ns-fetch update --type so --id 31099 \
--data '{"memo":"Updated via CLI"}'DELETE
ns-fetch delete --type vendor --id 452IMPORT (CSV / Excel)
Import CSV:
ns-fetch import --type customer \
--csvFile customers.csv \
--mapFile headerMap.json \
--valueMapFile valueMap.jsonImport Excel:
ns-fetch import --type customer \
--excelFile customers.xlsx \
--mapFile headerMap.json \
--valueMapFile valueMap.json- headerMap.json maps column headers to NetSuite field IDs
- valueMap.json maps raw cell values (e.g. subsidiary names) to IDs
Mapping Files
headerMap.json
{
"Name": "companyName",
"Email": "email",
"Phone": "phone",
"Subsidiary": "subsidiary.id"
}valueMap.json
{
"Subsidiary": {
"Test Company": 6,
"Globex Subsidiary": 2,
"Initech Ltd": 3
}
}headerMapSO.json (Sales Orders)
{
"Sales Order Number": "tranId",
"Customer": "entity.id",
"Date": "trandate",
"Memo": "memo",
"Item": "itemList.0.item.id",
"Quantity": "itemList.0.quantity",
"Rate": "itemList.0.rate"
}Advanced Features (Planned)
- Dry-run & validation mode
- Auto-schema discovery & CLI completion
- Delta-sync / upsert mode
- Data cleansing & fuzzy matching
- Interactive mapping UI
- Exponential back-off & retries
- Slack/email notifications on bulk jobs
