Skip to main content
Big news! Interval has been acquired by Meter. Learn more →

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:

src/interval.ts
import path from "path";
import { Interval } from "@interval/sdk";

const interval = new Interval({
apiKey: "<YOUR API KEY>" // get an API key at https://interval.com/dashboard/develop/keys
routesDirectory: path.resolve(__dirname, "routes"),
});

// This is important! If you don't call listen(), your app won't connect to Interval.
interval.listen();
src/routes/hello_world.ts
import { Action, io } from "@interval/sdk";

export default new Action(async () => {
const name = await io.input.text("Your name");
return `Hello, ${name}`;
});

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.
  • Starting with version 0.36.0 of the SDK, you can add logLevel: "quiet" to the Interval constructor to silence informational logs and warnings if desired.
Did this section clearly explain what you wanted to learn?