API Libraries > Node.js - v1

Node.js - v1

This document is for v1 of the rockset nodejs client, which is being deprecated. We strongly recommend upgrading to rockset-node-client v2.

This document describes how to use node.js client for Rockset. This client allows you to:

  • securely connect to Rockset service
  • create, manage and administer collections
  • issue queries against collections

The Node.js client library code is present here.


npm install rockset --save


Client objects allow you to connect securely to Rockset service. All other API calls require a valid client object.

In order to create a client object, you will need a valid Rockset API key. If you have access to the Rockset Console, then you can use the console to create an API key. If not, please contact the Rockset team at support@rockset.com

var client = require('rockset')("{apiKey}", "{apiServer}");

Use https://api.rs2.usw2.rockset.com for the apiServer.


Create a collection

Create a collection using the client object as follows:

client.collections.create('commons', {
    'name': 'my-first-collection',
    'description': 'my first collection'
}, function (error, response, body) {

If your document source is S3, follow the steps below otherwise refer to Rock CLI to add documents to the created collection.

Create an Integration

If you have an Amazon S3 bucket that you want to ingest data from, create a Rockset Integration to store credentials required to access the bucket. Create an integration object using the client object as follows:

    'name': 'my-first-integration',
    'description': 'my-first-integration',
    'aws': {
        'aws_access_key_id': '.....',
        'aws_secret_access_key': '.....'
}, function (error, response, body) {

Create a collection from Amazon S3

Prior to creating a collection using Amazon S3 as source, create a Rockset Integration first as described above.

client.collections.create('commons', {
    'name': 'my-first-s3-collection',
    'description': 'my first s3 collection',
    'sources': [{
        'integration_name': 'my-first-integration',
        's3': {
            'bucket': 'bucket-name'
}, function (error, response, body) {

Add Documents

Add documents to an existing collection using the client object.

        'data': [{
            "name": "foo",
            "address": "bar"
    }, function (error, response, body) {


Make queries to Rockset using the client object.

    'sql': {
        'query': 'select * from _events limit 1'
}, function(error, response, body) {

You can find more examples here.