Giter Site home page Giter Site logo

framingeinstein / node-alchemy Goto Github PK

View Code? Open in Web Editor NEW
54.0 7.0 18.0 61 KB

An Alchemy API library for Node.JS

Home Page: https://npmjs.org/package/alchemy-api

License: MIT License

JavaScript 100.00%
sentiment-analysis keyword entity-extraction alchemyapi javascript alchemy

node-alchemy's Introduction

alchemy-api - An Alchemy API library for Node.js

Build Status

This module provides calls to the AlchemyAPI for Nodejs. For more information on the API request and responses visit the AlchemyAPI docs. To use the module you will need to obtain an api key from Alchemy.

Installation

You can install this through npm: npm install alchemy-api

You can also install via git by cloning: git clone https://github.com/framingeinstein/node-alchemy.git /path/to/alchemy-api

Usage

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.sentiment('<URL|HTML|TEXT>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/ for format of returned object
  var sentiment = response.docSentiment;

  // Do something with data
});

For api methods that allow for sentiment analysis such as Entity Extraction, Relations and Keywords pass: {"sentiment":1} as the second parameter.

Tests

To run tests type npm test

AlchemyAPI Features

Named Entity Extraction

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.entities('<URL|HTML|TEXT>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/entity/htmlc.html for format of returned object
  var entities = response.entities;

  // Do something with data
});

Sentiment Analysis

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.sentiment('<URL|HTML|TEXT>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/sentiment/htmlc.html for format of returned object
  var sentiment = response.docSentiment;

  // Do something with data
});

Emotions

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.emotions('<URL|HTML|TEXT>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/html-api-1 for format of returned object
  var emotions = response.docEmotions;

  // Do something with data
});

Targeted Sentiment Analysis

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.sentiment_targeted('<URL|HTML|TEXT>', '<Target>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/sentiment/htmlc.html for format of returned object
  var sentiment = response.docSentiment;

  // Do something with data
});

Relation Extraction

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.relations('<URL|HTML|TEXT>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/relation/htmlc.html for format of returned object
  var relations = response.relations;

  // Do something with data
});

Concept Tagging

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.concepts('<URL|HTML|TEXT>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/concept/htmlc.html for format of returned object
  var concepts = response.concepts;

  // Do something with data
});

Keyword / Terminology Extraction

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.keywords('<URL|HTML|TEXT>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/keyword/htmlc.html for format of returned object
  var keywords = response.keywords;

  // Do something with data
});

Taxonomy

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.taxonomies('<URL|HTML|TEXT>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/taxonomy_calls/html.html for format of returned object
  var taxonomies = response.taxonomies;

  // Do something with data
});

Topic Categorization

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.category('<URL|HTML|TEXT>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/categ/htmlc.html for format of returned object
  var category = response.category;

  // Do something with data
});

Image Link Extraction (Main Image)

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.imageLink('<URL|HTML|TEXT>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/image-link-extraction/htmlc.html for format of returned object
  var image = response.image;

  // Do something with data
});

Image Tags/Keyword Extraction

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.imageKeywords('<URL|IMAGE>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/image-tagging/urls.html for format of returned object
  var imageKeywords = response.imageKeywords;

  // Do something with data
});

Image Faces Detection

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.imageFaces('<URL|IMAGE>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/face-detection/urls.html for format of returned object
  var imageFaces = response.imageFaces;

  // Do something with data
});

Language Detection

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.language('<URL|HTML|TEXT>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/lang/htmlc.html for format of returned object
  var language = response.language;

  // Do something with data
});

Author Extraction

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.author('<URL|HTML>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/author/htmlc.html for format of returned object
  var author = response.author;

  // Do something with data
});

Text Extraction / Web Page Cleaning

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.text('<URL|HTML>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/text/htmlc.html for format of returned object
  var text = response.text;

  // Do something with data
});

Structured Content Scraping

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.scrape('<URL|HTML>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/scrape/htmlc.html for format of returned object
  var results = response.queryResults;

  // Do something with data
});

Microformats

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.microformats('<URL|HTML>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/mformat/htmlc.html for format of returned object
  var microformats = response.microformats;

  // Do something with data
});

RSS / ATOM Feed Discovery

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.feeds('<URL|HTML>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/feed/htmlc.html for format of returned object
  var feeds = response.feeds;

  // Do something with data
});

Publication Date

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.publicationDate('<URL|HTML>', {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/publication-date/htmlc.html for format of returned object
  var publicationDate = response.publicationDate; //YYYYMMDDTHHMMSS string

  // Do something with data
});

Combined Feature Extraction Call

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.combined('<URL|HTML|TEXT>', ["FEATURE_NAME",...], {}, function(err, response) {
  if (err) throw err;

  // See http://www.alchemyapi.com/api/combined-call/ for format of returned object.
  // Each feature response will be available as a separate property.
  var feature_response = response.FEATURE_NAME; 

  // Do something with data
});

API Key Information

var AlchemyAPI = require('alchemy-api');
var alchemy = new AlchemyAPI('<YOUR API KEY>');
alchemy.apiKeyInfo({}, function(err, response) {
  if (err) throw err;

  // Do something with data
  console.log('Status:', response.status, 'Consumed:', response.consumedDailyTransactions, 'Limit:', response.dailyTransactionLimit);
  
});

node-alchemy's People

Contributors

chicagodev avatar codercooke avatar dling avatar fastfrwrd avatar framingeinstein avatar kfitzgerald avatar kjones1876 avatar weareu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-alchemy's Issues

Problems with Russian Language (and possibly others)

We received a support request from someone using node-alchemy with keyword extraction for the Russian language. The module returns no results when attempting to parse Russian text.

If I were to make a guess, the problem may lay in how node-alchemy handles special characters, or perhaps in how they get submitted to the API.

HTTP POST

Receive invalid-url when using the POST method.

custom classifier endpoint

Would be great to be able to access the /v3/classifiers endpoint to do training via server side calls. Could be missing something in the functionality here, but thought I'd suggest it.

Adam

Implement Browserify Support

Currently this module breaks down when used in the browser via browserify because browserify does not support full node url objects.

Emotion and sentiment-levels features

Comparing the AlchemyAPI docs with the features list in the alchemy-api node package I see a few features missing. Emotion analysis is a new feature, and sentiment analysis can also be done on the following levels: entity, keyword, and directional. I just wanted to make a request that these features be added. It'd be a big help and I really appreciate the work already done!

Here are links to each feature:
Emotion: http://www.alchemyapi.com/api/emotion-analysis
Entity: http://www.alchemyapi.com/api/entity/sentiment.html
Keyword: http://www.alchemyapi.com/api/keyword/sentiment.html
Directional: http://www.alchemyapi.com/api/relation/sentiment.html

Getting error while accessing api

Error: request.error: Error: socket hang up
at ClientRequest. (/Users/ayushnarula/node_modules/alchemy-api/index.js:123:6)
at ClientRequest.EventEmitter.emit (events.js:95:17)
at Socket.socketOnEnd as onend
at Socket.g (events.js:175:14)
at Socket.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:872:14
at process._tickCallback (node.js:415:13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.