README
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).
Documentation
Link TBD
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 sdk from '@cognite/cognitesdk';
Using typescript
The SDK is written in native typescript, so no extra types needs to be defined.
import * as sdk from '@cognite/cognitesdk';
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
More Information
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.