1.0.11 • Published 3 years ago

data2insights-test v1.0.11

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Data2Insights-node

Data2Insights nodejs API. It call's the machine learning models for Text and Vision analysis from your Node apps.

Install

You can use npm to install the library:

$ npm install data2insights

Alternatively, you can just clone the repository and install:

$ cd data2insights/
$ npm install

Create Data2insights Instance

By using below statement,the data2insights instance will be created.

    // Use the API key,account Id and email Id  from your account,
    const d2i = new Data2Insights('<YOUR API KEY HERE>','<ACCOUNT ID>','<EMAIL ID>');

Simple usage examples

Here are example Emotion model, how to use the library in your application:

Text Analysis

const Data2Insights = require('data2insights');

// Use the API key,account Id and email Id  from your account,
const d2i = new Data2Insights('<YOUR API KEY HERE>','<ACCOUNT ID>','<EMAIL ID>');

const data = "Welcome to Data2Insights";
// Pass the input text as the parameter to the getModel_name method
d2i.text.getEmotion(data).then(response=>{
        // handle response
        console.log(response)
    }).catch(error=> {
        // handle error
        console.log(error)
    });

On a successful API, response.body would look like this:

// This is exactly the parsed JSON that the Data2Insights API returns!
{
   Classifier_id: 'Emotion',
   classifications: {
     Prediction_accuracy: '78.68',
     emotion: 'Happy',
     given_text: 'Welcome to d2i'
   },
   content_type: 'application-json',
   query_limit: '5000',
   query_limit_remaining: '4937',
   query_limit_request: 1,
   status_code: 200
 }

The available text models in data2insights are listed below.Click on the model name for more details.

getEmotion(); getSentiment(); getTopic(); getSpam(); getAge(); getGender();
getTweetsentiment();
getEntity(); getTweetentity(); getKeyword(); getUrlextraction();
getPersonalitytraits(); getReadability(); getSimilarity(); getQandA();


text batch process

The Data2insights API has having text batch methods to process multiple texts at once to classify or extract. In batch, through the API you can pass input data in the form of supported file formates(.xlsx,.csv).


Vision Analysis

const Data2Insights = require('data2insights');

// Use the API key,account Id and email Id  from your account,
const d2i = new Data2Insights('<YOUR API KEY HERE>','<ACCOUNT ID>','<EMAIL ID>');

// this is for external image as the input
const data_1 = {
    url:"https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/main-1-1200x800-1516104858.jpg" 
    //image url
};

const data_2 = {
    file:"uploaded file" // supports .png,.jpeg files
}

// Pass the input text as the parameter to the getModel_name method
d2i.vision.getGender(data_1).then(response=>{
        // handle response
        console.log(response)
    }).catch(error=> {
        // handle error
        console.log(error)
    });

// this is for file upload 
d2i.vision.getGender(data_2).then(response=>{
        // handle response
        console.log(response)
    }).catch(error=> {
        // handle error
        console.log(error)
    });

On a successful API, response would look like this:

// This is exactly the parsed JSON that the Data2Insights API returns!
{
  "Classifier_id": "Gender", 
  "classifications": {
    "Faces": [
      {
        "Coordinates": {
          "Bottom": 295.8600044250488, 
          "Left": 507.1301221847534, 
          "Right": 694.7623014450073, 
          "Top": 10.44924259185791
        }, 
        "Face": 1, 
        "Gender": "Male", 
        "Predicted_accuracy": 99
      }
    ]
  }, 
  "content_type": "application-json", 
  "query_limit": "20", 
  "query_limit_remaining": "17", 
  "query_limit_request": 1, 
  "status_code": 200
}

The available text models in data2insights are listed below.Click on the model name for more details.

getLogo(); getBird(); getTransport(); getPlant(); getAge(); getGender(); getEmotion(); getColor(); getScene(); getWeather(); getViolence(); getTlo(); getObject();


Responses and Errors

Every function returns a promise.

If the promise is accepted, you will get the success response with status_code 200.

If the promise is rejected for some reason, an error of type Data2InsightsErrors is raised. This object has the following attributes:

  • message: The error message. If it was an API error, it's the API error message.
  • error_code: The API error code. Only present if the error actually comes from an API error, and not some other runtime error.
  • response: The Data2InsightsErrors of this request. You can use this to troubleshoot the error in detail. Only present if the error actually comes from an API error, and not some other runtime error.
1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago