Authentication

The Notardec API key is mandatory for all web service methods. Optionally, a user token can also be used to personalize the web service requests. A user token is only necessary if you are developing software that uses additional CoreLedger TEOS products and services. For example, the white label app template for signing transactions. You can find details about the user token here:
About Notardec keys

Step 1: Install dependencies
  npm install typescript --save-dev
  npm install axios
Step 2: Create function to request Notardec

We recommend to put the key in the environment variables. This will make it easier to work with all the functions of Notardec in the future.

All authentication parameters are to be submitted with the headers.

 'X-API-KEY': apiKey,
  Authorization: `Bearer token,

The Notardec API key is passed in the X-API-KEY header. Whereas the optional user token is to be used in the Authorization header.

The following request shall serve as an example. Detailed functions can be found in swagger

import axios from 'axios';
async function createAsset(apiKey: string, token: string | null, payload: any): Promise<IResponse<any>> {
  const result = await axios.post<IResponse<any>>(`LINK`, payload, {
    headers: {
      'X-API-KEY': apiKey,
      Authorization: `Bearer ${token}`,
    },
  });
  return result.data;
}

The Notardec API key and optional user key is followed by the by the asset body. Each request to Notardec returns a response having the following structure:

interface MetaResponse {
  size?: number;
  page?: number;
}

interface ErrorResponse {
  code: string;
  message: string;
}

interface IResponse<T> {
  value: T | null;
  meta?: MetaResponse;
  error?: ErrorResponse;
}

If the request was successful, the value field will contain the necessary information. If an error occurs, the value field will be null and the error field will contain an error (status and message)

Step 3: Confirm transaction

Keep in mind that the Notardec API allows you to write to and read from blockchain. A blockchain transaction must be signed. The Notardec API cannot sign transactions for you automatically. Therefore each write-process (such as creating a document) will just create a transaction for you, which waits to be signed by the holder of the private key. The holder of a private key can either be your end-user (e.g. having a smartphone App built on CoreLedger’s White-Label App) or a tool, such as the Autosigner, or a hardware device, etc …
Learn more about signing and submitting transactions