GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Stwissel/nforce8: NodeJS library to connect to Salesforce, forked from https://github.com/kevinohara80/nforce

BranchesTags
Open more actions menu

Latest commit

 

History

790 Commits
790 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
docs
docs
 
 
examples
examples
 
 
lib
lib
 
 
tasks
tasks
 
 
test
test
 
 
.codacy.yml
.codacy.yml
 
 
.eslintrc.cjs
.eslintrc.cjs
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
.snyk
.snyk
 
 
.travis.yml
.travis.yml
 
 
CLAUDE.md
CLAUDE.md
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
CONTRIBUTORS.md
CONTRIBUTORS.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
eslint.config.js
eslint.config.js
 
 
index.js
index.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
refactoring-expert-report.md
refactoring-expert-report.md
 
 
wallaby.js
wallaby.js
 
 

Repository files navigation

nforce8 :: node.js salesforce REST API wrapper

A promise-based Node.js REST API wrapper for Salesforce, a modernized fork of Kevin O'Hara's nforce library.

Codacy Badge Codacy Badge npm version Known Vulnerabilities Snyk security (npm package) Coverage Status CI

Requirements

  • Node.js >= 22.4.0 — uses built-in fetch and a stable built-in WebSocket (Node’s global WebSocket was experimental in 22.0–22.3)

Features

  • Promise-based API (no callback support)
  • Intelligent sObjects with field change tracking
  • CRUD operations (insert, update, upsert, delete, getRecord)
  • SOQL queries with automatic pagination (fetchAll)
  • SOSL search
  • Streaming API support (PushTopics, Platform Events, Change Data Capture)
    • Built-in CometD/Bayeux client with long-polling and WebSocket transports
    • Replay ID support for event replay
    • No external streaming dependencies
  • Binary content retrieval (Attachments, Documents, ContentVersions)
  • Apex REST endpoint support
  • OAuth authentication (authorization code, username/password, SAML assertion)
  • Automatic token refresh on session expiration
  • Single-user and multi-user modes
  • Plugin system for extending the Connection prototype

Installation

npm install nforce8

Quick Start

Create a Connection

const nforce = require('nforce8');

const org = nforce.createConnection({
  clientId: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  redirectUri: 'http://localhost:3000/oauth/_callback',
  apiVersion: 'v62.0',  // optional, defaults to current API version
  environment: 'production',  // optional, 'production' or 'sandbox'
  mode: 'multi' // optional, 'single' or 'multi' user mode
});

Authenticate

// Multi-user mode
const oauth = await org.authenticate({
  username: '[email protected]',
  password: 'password'
});

// Single-user mode — OAuth is cached on the connection
await org.authenticate({
  username: '[email protected]',
  password: 'password'
});

CRUD Operations

// Insert
const acc = nforce.createSObject('Account');
acc.set('Name', 'ACME Corporation');
acc.set('Phone', '800-555-2345');

const result = await org.insert({ sobject: acc, oauth });
console.log('Created:', result.id);

// Query
const resp = await org.query({
  query: 'SELECT Id, Name FROM Account WHERE Name = \'ACME Corporation\' LIMIT 1',
  oauth
});

// Update (only changed fields are sent)
const record = resp.records[0];
record.set('Name', 'ACME Coyote');
record.set('Industry', 'Explosives');
await org.update({ sobject: record, oauth });

// Delete
await org.delete({ sobject: record, oauth });

Streaming API

Subscribe to PushTopics, Platform Events, or Change Data Capture events:

const oauth = await org.authenticate(creds);
const client = org.createStreamClient();
const sub = client.subscribe({ topic: '/data/ChangeEvents' });

sub.on('data', (event) => console.log(event));
sub.on('connect', () => console.log('Subscribed'));
sub.on('error', (err) => {
  console.error(err);
  client.disconnect();
});

Replay support — resume from a specific event replay ID:

const sub = client.subscribe({
  topic: '/event/MyPlatformEvent__e',
  replayId: -2  // -1 = new only, -2 = all available
});

Apex REST

const result = await org.apexRest({
  uri: 'MyCustomEndpoint',
  method: 'POST',
  body: { key: 'value' },
  oauth
});

Binary Content

// Retrieve attachment, document, or content version binary data
const buffer = await org.getBinaryContent({
  sobject: attachmentRecord,
  oauth
});

API Version Format

API versions must be fully-qualified strings like 'v62.0'. Bare numbers (42, 42.0) and short strings ('v42') are rejected.

Single vs Multi User Mode

  • Multi-User Mode (default): pass oauth with each API call
  • Single-User Mode: OAuth is cached on the connection after authenticate(), no need to pass it

Important Differences from nforce

  • Promise-only API, no callback support
  • API version must be fully-qualified ('v45.0', not 42 or '42')
  • Streaming subscriptions require the full topic path (e.g. /topic/MyTopic)
  • Requires Node.js >= 22.4.0 (stable built-in WebSocket; experimental in 22.0–22.3)
  • Built-in CometD client replaces the faye dependency

Documentation

  • Changelog
  • Streaming API guide
  • Original nforce documentation (for inherited API details)

Development

# Run tests
npm test

# Lint
npm run lint

License

See LICENSE file.

About

NodeJS library to connect to Salesforce, forked from https://github.com/kevinohara80/nforce

stwissel.github.io/nforce8

Topics

nodejssalesforce

Resources

Readme
MIT license

Code of conduct

Code of conduct

Contributing

Contributing
Activity

Stars

1 star

Watchers

1 watching

Forks

5 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.