Node.js QuickStart

10 minutes

Node.js is one of the most commonly used programming languages due to its strong performance and scalability.

InterSystems IRIS™ Native API for Node.js lets your application directly access the underlying data structure within InterSystems IRIS (known as globals) as well as call ObjectScript methods and routines.

To review ways to connect your application to InterSystems IRIS data platform, watch the video above.

The exercise below will walk you through the set up and execution of using Node.js to connect to InterSystems IRIS.

Node.js is only available on InterSystems IRIS v2019.2+.

The Native API can be used to store data in your own custom structures to InterSystems IRIS. It can also be used to run existing InterSystems IRIS methods or routines. For this exercise, you will see how Native API allows your Node.js application to interact directly with InterSystems IRIS. You can use your favorite IDE that supports Node.js, such as Visual Studio Code.

If you don’t have InterSystems IRIS set up yet, get a free development sandbox here.


  1. Verify you have an instance of InterSystems IRIS and an IDE that supports Node.js (such as Visual Studio Code). If you are using AWS, Azure, or GCP, verify that you have followed the steps to change the password for InterSystems IRIS.
  2. Load sample stock data into InterSystems IRIS:
    1. Clone or download this repository: This repository has a folder named data, which contains all files needed to load the sample stock data.
    2. In the Management Portal, navigate to System Explorer > Classes and import DemoStockCls.xml and StocksUtil.xml files into the USER namespace from the data folder.
    3. In the InterSystems IRIS Terminal, type the following command. Replace repo_home with the directory of Sample-Stock-Data repo that you recently cloned:
      do ##class(Demo.Stock).LoadData("repo_home/data/all_stocks_1yr.csv")
  3. To get the sample Node.js code, download or clone the following repo into your IDE:

    1. In your IDE:
      1. Open the Node.js folder you recently cloned.
      2. Open connections.config file and modify the IP and password to be the correct values for your InterSystems IRIS instance. Although port and username are most likely the defaults, you should verify that the values are correct.
    2. In the Terminal of your IDE:
      1. Navigate to the sample code directory:
        cd Solutions
    3. Install the necessary modules:
      1. npm install --save intersystems-iris-native to install IRIS Native API for Node.js module
      2. npm install readline-sync for handling user input
      3. npm install file-system for handling filesystem
  4. You should now have several Node.js classes that use the Native API. To run a file, type node filename.js, replacing filename.js with the name of the file you want to run.

Use the Native API to store and exercise a custom structure

Use the Native API to store to a custom structure and call methods or routines.

  1. Open nodeplaystockTask5.js to view the Native API code. You will notice the connection string uses these variables to connect:const connection = irisnative.createConnection({host: ip, port: port, ns: namespace, user: username, pwd: password})
  2. Run nodeplaystockTask5.js. This code stores stock data in a custom data structure.
    • Run option 2: Store the stock data in a custom structure.
    • Run option 3: Retrieve and view the stock data from this custom structure.
    • Run option 4: Call population methods within InterSystems IRIS to generate better information for trades.
    • Run option 5: Print the version of IRIS to the screen. This is retrieved by calling a routine within InterSystems IRIS.
    • Run option 6: Quit.
With the Native API, you can efficiently store data in your own custom data structure. Additionally, you can call class methods and routines from within InterSystems IRIS using the Native API.