Development Quickstart

Get up and running with our API libraries and start working with Cognite Data Fusion in a few simple steps.

  1. Get your API key to authenticate your API requests.
  2. Make a test API request to test that everything is up and running.
  3. Install a Software Development Kit (SDK) to interact with the Cognite Data Fusion API.

To get set up, watch this video or see the text below for details:

Step 1: Get your API key

Cognite Data Fusion authenticates your API requests using the API key for a project. If you do not include a key when you make an API request, or use one that is incorrect or outdated, Cognite Data Fusion returns an error.

If you don't have your own project yet, you can test your setup with an API key and data from the Open Industrial Data project. The API key generated for the Open Industrial Data project is a read-only key, and you can not create or change any data in the project:

  1. Navigate to openindustrialdata.com, click Access Platform and fill out the registration form.

  2. Once you're redirected to your page, scroll down and click Generate your API key. Copy and store your API key in a safe location (for example in LastPass).

    Make sure you keep your API key secret, like you would with a password. Do not share it with others, and make sure you don't include it in a git commit.

Step 2. Make a test API request

We recommend that you download, install and use Postman to test API requests and examine responses.

In Postman:

  1. Click Import > Import From Link and enter a URL to import one of our Postman collections:

    • https://storage.googleapis.com/cognite-postman-collections/0.5.json (stable, recommended)
    • https://storage.googleapis.com/cognite-postman-collections/0.6.json (experimental)
    • https://storage.googleapis.com/cognite-postman-collections/0.3.json (deprecated)
    • https://storage.googleapis.com/cognite-postman-collections/0.4.json (deprecated)
  2. Set the api-key and project environment variables. The api-key is injected as the header to authenticate your requests, and the project routes all your requests to the correct project in Cognite Data Fusion. To set the environment variables:

    1. Click the the Cog in Postman button in the top-right corner, click Add and enter an Environment Name, for example cognite-publicdata.

    2. Under VARIABLE, enter api-key, and in the CURRENT_VALUE field enter your API key.

    3. Add another VARIABLE, name it project, and in the CURRENT_VALUE field enter the name of your project.

      If you got your API key from the Open Industrial Data Project, enter publicdata as the name of the project.

    4. Click Add to create the environment.

    5. If necessary, select your newly created environment in the dropdown menu in the top right corner.

      List all assets

  3. Make a test API request to check that your integration is working correctly:

    1. Click the Cognite API collection in the left-hand menu, and select Assets > List all assets.

      List all assets

    2. Click Send.

Cognite Data Fusion returns a list of all asset objects in response to your API request. For the Open Industrial Data project the JSON results look similar to this:

{
    "data": {
        "nextCursor": "Wzi_ZuNCVhRPwdxklsbDVDwPOTzsM4v4rcGqB0kGPqFIQbTnQt__kDREoZ_emf91",
        "items": [
            {
                "id": 3111454725058294,
                "path": [
                    6687602007296940,
                    4650652196144007,
                    3111454725058294
                ],
                "depth": 2,
                "name": "23",
                "parentId": 4650652196144007,
                "description": "GAS COMPRESSION AND RE-INJECTION (PH)",
                "metadata": {
                    "SOURCE_DB": "workmate",
                    "SOURCE_TABLE": "wmate_dba.wmt_system",
                    "WMT_LOCATION_ID": "1004",
                    "WMT_SYSTEM_ACTIVE": "Y",
                    "WMT_SYSTEM_CODE": "23",
                    "WMT_SYSTEM_DESC": "GAS COMPRESSION AND RE-INJECTION (PH)",
                    "WMT_SYSTEM_ID": "4440",
                    "WMT_SYSTEM_NAME": "GAS COMPRESSION AND RE-INJECTION (PH)"
                },
                "createdTime": 0,
                "lastUpdatedTime": 0
            },
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

Once you have successfully made an API request, you’re ready to begin interacting with the Cognite Data Fusion API through our Software Development Kits (SDKs).

Step 3. Install a Software Development Kit (SDK)

We provide official Software Development Kits (SDKs) for Python and JavaScript with libraries that interact with the Cognite Data Fusion API.

The Python Software Development Kit (SDK)

The Cognite Python library requires Python 3.5+ and provides access to the Cognite Data Fusion API from applications written in the Python language. For detailed information, see the Cognite Python SDK Documentation.

To download and install Python, visit Python.org.

To install the Cognite Python library:

pip install cognite-sdk
1

The JavaScript Software Development Kit (SDK)

The Javascript library provides access to the Cognite Data Fusion API from applications written in client- or server-side JavaScript. The library supports authentication through API keys (for server-side applications) and bearer tokens (for web applications). For detailed information, see the Cognite JavaScript documentation.

Install the Cognite Javascript library with yarn:

yarn add @cognite/sdk
1

Or with npm:

npm install @cognite/sdk --save
1
Last Updated: 4/12/2019, 10:53:12 AM