@corticalio/js-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

JS SDK

JS SDK for APIs published by cortical.io

API docs

The API docs as well as a get started guide can be found on api.cortical.io.

Specifically, you can check out:

where you will also find the API specifications.

Installation

Run

npm i @corticalio/js-sdk

in the root folder of the node project where you want to use this SDK.

Usage

Import the NlpApiEndpoints or FpApiEndpoints class from the npm package:

const { NlpApiEndpoints, FpApiEndpoints } = require('@corticalio/js-sdk');

Supply your API tokens (e.g. store them in an .env file so you don't have to add them to your code):

const nlpApiEndpoints = new NlpApiEndpoints("<YOUR-NLP-API-TOKEN>");
const fpApiEndpoints = new FpApiEndpoints("<YOUR-FP-API-TOKEN>");

Use the SDK by calling the constructor of the instantiated classes. E.g.:

// sends a request to the `supported-languages` endpoint of the NLP API
const languages = await nlpApiEndpoints.getSupportedLanguages();

// sends a request to the "fingerprint" endpoint of the Semantic Fingerprint API
const payload = {
    text: 'this is some example text',
};
const queryParams = {
    inverse_position_weighting: true,
    max_density: 0.04,
    max_df: 0.2,
    max_terms: 3,
    pos_filter: false,
    pos_weighting: false,
    retina_name: 'en_retina',
    stop_filter: false,
    tfidf_weighting: false,
    use_phrase_fingerprints: false
};
const fingerprint = await fpApiEndpoints.getFingerprint(payload, queryParams);

API Key Retrieval

Once you have selected either a free plan or purchased a paid plan on the API portal associated with an API product, you can retrieve the API key via the username dropdown in the top right corner, select Apps & Subscriptions / My Apps, click on the name of the app you associated with the product and plan in the previous section. The apiKey is listed as Token ID under Access and Credentials info.

This API token can then be passed to either the constructor of the NlpApiEndpoints or the FpApiEndpoints class.

Package Sidebar

Install

npm i @corticalio/js-sdk

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

32.6 kB

Total Files

48

Last publish

Collaborators

  • pgonzalvez
  • patrick.corticalio
  • danielschreiber
  • janoscortical