evrythng.js v6.0.0

The release of evrythng.js version 6.0.0 brings several breaking changes. There is an introduction of new API key types, which also bring a set of new API entities.


Breaking Changes

New Default setup() Options

When using setup(), apiVersion:2 is used by default, which means the enterprise API v2 is used. If you still want to use the previous version, you must set apiVersion:1

// Before
evrythng.setup({})
// apiUrl is `apiUrl:https://api.evrythng.com`

// Now
evrythng.setup({})
// apiUrl is `https://api.evrythng.io/v2`

Configurable apiUrl in setup()

The apiUrl option is selected automatically depending on the values you specify for region and apiVersion.

// Before
evrythng.setup({})
// output is `apiUrl:https://api.evrythng.com`

// Now
evrythng.setup({
  apiVersion: 2,
  region: 'eu'
})
// apiUrl is `https://api.eu.evrythng.io/v2`

New Scopes for apiVersion:2

In API version 2, only two scope types are supported: Operator and Access Token.

// to create Operator scope
import { Operator } from 'evrythng';
const operator = new Operator(OPERATOR_API_KEY);

// to create Access Token scope
import { AccessToken } from 'evrythng';
const accessToken = new AccessToken(ACCESS_TOKEN_API_KEY);

New APIs for apiVersion:2

Operator Access

Create, read, update, or delete an operator access.

const accountId = '...';

// to create operatorAccess()
const operarorAccess = await operator
	.sharedAccount(accountId)
	.operatorAccess()
	.create(data)

Access Policy

Create, read, update, or delete an access policy.

// to create accessPolicy()
const accessPolicy = await operator.accessPolicy().create(data)

Access Token

Create and read an access token.

// to create accessToken()
const accessToken = await operator.accessToken().create(data)

Me

To read your Operator access scope, use the me() endpoint.

import { Operator } from 'evrythng';
const operator = new Operator(OPERATOR_API_KEY);

// to read my Operator access
const operatorAccess = await operator.me().read();

See our enterprise API v2 documentation to learn more about these new scopes. See our operatorAccess, accessTokens and me API documents to learn more about our new APIs.