Skip to main content
Version: 1.1.0

Installation

To get started, install alloy-node using npm as seen below:

npm install alloy-node --save

Or using yarn:

yarn add alloy-node

Usage

The package needs to be configured with your account's API key, which is available in the Alloy Dashboard under settings. You must supply the API key with each instantiation of the module.

To set up Alloy's Unified API, use the code snippet below:

JavaScript
import { UAPI } from "alloy-node";

const apiClient = new UAPI("MY_API_KEY...");

Creating a User

To make API calls to Unified API, you must first create a user. To create a user, call the User.createUser() method as seen below. You must pass a unique username.

JavaScript
let bodyData = {
username: `gregg321`,
};
let data = await apiClient.User.createUser(bodyData);

Obtain a connectionId

Before you make your first API call, you will need to obtain a connectionId. A connectionId represents the unique identifier of an app you plan to make API calls to. You can obtain a connectionId by using the frontend SDK. Read more here.

Once you have the connectionId, call the connect() method as seen below.

JavaScript
await apiClient.connect(YOUR_CONNECTION_ID);

Making requests to Alloy Unified API's SDK

Once you have a connectionId, you can start making calls to Alloy Unified API. See the example below for making a request to the Commerce Unified API:

JavaScript
let data = await apiClient.Commerce.listCustomers();

Alloy Unified API currently offers three models:

ModelDocs
Commercehere
Accountinghere
CRMhere