Skip to main content

Installation

The Interval SDK is a pure JS Node.js module requiring Node.js version 16 or greater.

We built Interval from the ground up specifically for TypeScript and we strongly recommend using it when building your apps. Interval's I/O methods do the heavy lifting of parsing, sanitizing, and type checking all user input.

info

Although Interval's SDK is pre-1.0, several companies (ourselves included) use Interval to create "production" tools. Before 1.0 you can expect meaningful additions and changes to the SDK.

Creating a new app

If you're starting from scratch, create-interval-app allows you to initialize a new TypeScript or JavaScript Interval app with a single command.

npx create-interval-app --template=refund-charges --language=ts

Adding Interval to an existing app

If you have one, we recommend adding Interval to your existing Node.js app. We've found that teams are able to move incredibly quickly by sharing code between their main app and internal tools built with Interval.

When your Interval actions are defined alongside the code in your main app, code sharing is as simple as importing shared functions and calling them within your actions.

To add Interval to your app:

npm install @interval/sdk

Once the SDK is installed, you can create a minimal Interval app:

import Interval from "@interval/sdk";

const interval = new Interval({
apiKey: "<YOUR API KEY>" // get an API key at https://interval.com/dashboard/develop/keys
actions: {
hello_world: async (io) => {
const name = await io.input.text("Your name");
return `Hello, ${name}`;
},
},
});

// This is important! If you don't call listen(), your app won't connect to Interval.
interval.listen();

A few things to note:

  • Calling .listen() sets up a persistent connection between your app and Interval.
  • Actions are defined as a map of slug identifiers to async handler functions.
  • The Interval API key that you use determines whether your app will run in Dev mode or Live mode.
Did this section clearly explain what you wanted to learn?