Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

operate-api-client

A Node.js client for interacting with the Camunda 8 Operate API

Camunda

readme

Operate API Client for Node.js

NPM

Community Extension

Lifecycle

License

A Node.js client for interacting with the Camunda 8 Operate REST API in Camunda 8 SaaS.

Uses camunda-saas-oauth-nodejs to use client credentials from the environment for authentication.

Installation

npm i operate-api-client

Usage

Set the credentials for Camunda SaaS in the environment, then:

import { OperateApiClient } from 'operate-api-client'

const operate = new OperateApiClient()

operate.searchProcessInstances({
    filter: {
        state: "ACTIVE"
    },
    size: 50
}).then(instances => {
    console.log(instances)
})

Advanced Usage

If you want to create multiple instances of the client in an application - for example, to address different clusters - then you can hydrate the client manually using an OAuthProviderImpl like so:

import { OperateApiClient } from 'operate-api-client'
import { OAuthProviderImpl } from "camunda-saas-oauth"

const oauthProvider1 = new OAuthProviderImpl({
    audience: 'zeebe.camunda.io',
    authServerUrl: 'https://login.cloud.camunda.io/oauth/token',
    clientId: process.env.ZEEBE_CLIENT_ID_1, 
    clientSecret: process.env.ZEEBE_CLIENT_SECRET_1,
    userAgentString: 'operate-client-nodejs'
})

const client_1 = new OperateApiClient({
    oauthProvider,
    baseUrl: process.env.CAMUNDA_OPERATE_BASE_URL_1
});

const oauthProvider2 = new OAuthProviderImpl({
    audience: 'zeebe.camunda.io',
    authServerUrl: 'https://login.cloud.camunda.io/oauth/token',
    clientId: process.env.ZEEBE_CLIENT_ID_2, 
    clientSecret: process.env.ZEEBE_CLIENT_SECRET_2,
    userAgentString: 'operate-client-nodejs'
})

const client_2 = new OperateApiClient({
    oauthProvider,
    baseUrl: process.env.CAMUNDA_OPERATE_BASE_URL_2
});

changelog

1.2.4

Fixes

Things that were broken and are now fixed.

  • Update dependency camunda-saas-oauth to 1.2.4 to fix an issue with token expiration. Cached tokens were not correctly expired, leading to a 401 Unauthorized response to API calls after some time. The tokens are now correctly evicted from the cache. Thanks to @hanh-le-clv for reporting this. See this issue for more details.

1.2.3

  • Add private method safeJSONparse to handle non-serializable variables.
  • In version 1.2.2, a maximum of 10 variables were returned by getJSONVariablesforProcess. In version 1.2.3, up to 1000 variables are returned.

1.2.2

Enhancements

  • Add method getJSONVariablesforProcess to return variables as an object.

1.2.0

Enhancements

  • Support custom OAuthProvider and baseUrl via constructor to enable multiple clients/clusters per application. See #4 for more details.