Cognite Javascript SDK
The Cognite js library provides convenient access to the Cognite API from
applications written in client- or server-side JavaScript.
The SDK supports authentication through api-keys (for server-side applications) and bearer tokens (for web applications).
Installation
Install the package with yarn:
yarn add @cognite/cognitesdk
or npm
npm install @cognite/cognitesdk --save
Usage
const sdk = require('@cognite/cognitesdk');
sdk.configure({
project,
apiKey,
});
Using ES modules
import * as sdk from '@cognite/cognitesdk';
Using typescript
The SDK is written in native typescript, so no extra types needs to be defined.
Authentication
Api key
Authenticating with an api key should only happen when building server-side applications.
const sdk = require('@cognite/cognitesdk');
sdk.configure({
project: 'yourProject',
apiKey: 'yourApiKey',
});
It is generally a good idea store the api key as an environment variable, so it's not directly part of your code.
Configuring for a web application
See the react example
Examples
See examples.
Documentation
License
Apache 2.0
Development
There is one integration test that requires a api key. In order to run this, you need an api key for the cognitesdk-js
tenant. Talk to any of the contributors or leave an issue and it'll get sorted. Jenkins will run the test and has its own api key.
Set the environment variable COGNITE_CREDENTIALS
to your api-key.
Run all tests:
$ yarn
$ yarn test
We use jest
to run tests, see their documentation for more information.
Release
How to release a new version:
- Create a new branch
- Run
$ npm version [patch/minor/major]
- Push branch and push tags (
git push --tags
) - Create a new pull requests
- A new version will be published when PR is merged