A small CLI script for bulk-importing contractor-specific equipment prices into
SetSale from a CSV file, via POST /distributor/prices/import.
The script reads a CSV of model numbers and per-contractor prices, then syncs each price to SetSale. It runs in dry-run mode by default so you can preview exactly what would be sent before making any live changes.
- Install dependencies:
npm install- Create a local
.envfile from the template:
cp .env.example .env- Set your SetSale distributor API key in
.env:
SETSALE_API_KEY=your_setsale_api_key_here
.envis gitignored. Never commit it — it holds a live secret.
By default the script reads data.csv from this directory. Use --file to point
at another CSV.
Model Number,CONTRACTOR_EXTERNAL_ID_1,CONTRACTOR_EXTERNAL_ID_2
,Contractor Name 1,Contractor Name 2
SKU-001,100,125
SKU-002,#N/A,150- Row 1 —
Model Numberin column A, then one contractor external ID per column. - Row 2 (optional) — a blank column A followed by contractor display names. This row is only used for friendlier log output and can be omitted. If column A of row 2 contains a model number instead of a blank, the script automatically treats it as the first data row.
- Data rows — a model number in column A, then the price for each contractor.
- Numeric cells create or update a price (upsert).
- Blank,
#N/A,#NA, andN/Acells are treated as intentional removals when pruning is enabled (the default). Use--no-prunefor additive-only updates. - Non-numeric or negative prices are skipped, not turned into deletes.
- Duplicate rows for the same model number are merged. If a duplicate has conflicting prices for the same contractor, that cell is skipped (not deleted).
- Model numbers not present in the CSV are never touched.
Preview the import (dry run, no API calls — this is the default):
npm run populate-pricesSend the import to SetSale:
npm run populate-prices:executePass extra flags after --.
Import only a single contractor by external ID:
npm run populate-prices -- --contractor CONTRACTOR_EXTERNAL_ID
npm run populate-prices:execute -- --contractor CONTRACTOR_EXTERNAL_IDUse a different CSV file:
npm run populate-prices -- --file ./other.csvAdditive-only sync (don't send deletes for blank cells):
npm run populate-prices:execute -- --no-pruneWrite detailed per-batch API results to a JSON file:
npm run populate-prices:execute -- --log-file import-results.json