I am trying to write a simple node app to get the record count from various objects in salesforce.

Following rest api gives the count for objects mentioned in the request


I am not sure how to call this rest api from jsforce. Tried following the jsforce documentation but no luck so far.

appreciate your help!


I have figured this out. Posting answer hoping it would help others.

var jsforce = require('jsforce');
var conn = new jsforce.Connection({
  // you can change loginUrl to connect to sandbox or prerelease env.
  loginUrl : 'https://test.salesforce.com'

var _request = {
  url: '/services/data/v45.0/limits/recordCount?sObjects=Account,User',
  method: 'get',
  body: '',
  headers : {
          "Content-Type" : "application/json"

conn.login('username', 'pwd', function(err, userInfo) {
  if (err) { return console.error(err); }
  // Now you can get the access token and instance URL information.
  // Save them to establish connection next time.
  // logged in user property
  console.log("User ID: " + userInfo.id);
  console.log("Org ID: " + userInfo.organizationId);

  // var records = [];
  // conn.query("SELECT Id, Name FROM Account", function(err, result) {
  //   if (err) { return console.error(err); }
  //   console.log("total : " + result.totalSize);
  //   console.log("fetched : " + result.records.length);
  // });

  conn.request(_request, function(err, resp) {


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.