npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

data2insights-test

v1.0.11

Published

javascript pakage for the data2insights cognitive services.

Downloads

3

Readme

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.