Giter Site home page Giter Site logo

alchemy-news-api's Introduction

An Alchemy News API Library for Node.js

This module provides calls to the Alchemy News API for Nodejs. It is based on AlchemyAPI for Nodejs. For more information on the API requests and responses, visit the AlchemyData News API docs. To use this module, you will need to obtain a key from Alchemy.

Installation

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

You can install via git by cloning: git clone https://github.com/davidadamojr/alchemy-news-api.git /path/to/alchemy-news-api

Usage

    var AlchemyNewsAPI = require('alchemy-news-api');
    var alchemyNewsAPI = new alchemyNews('<YOUR API KEY>');
    var taxonomyQuery = {
        'taxonomy_label': 'politics',
        'return': ['url', 'title']
    };
    alchemyNewsAPI.getNewsByTaxonomy(taxonomyQuery, function (error, response) {
        if (error) {
            console.log(error);
        } else {
            console.log(response);

            // do something with response
        }
    });

Tests

To run tests type mocha

Alchemy News API Features

Taxonomy

Retrieve categorized news content by searching for news on topics that you care about e.g. baseball, mobile phones, etc.

    var AlchemyNewsAPI = require('alchemy-news-api');
    var alchemyNewsAPI = new alchemyNews('<YOUR API KEY>');
    var taxonomyQuery = {
        'taxonomy_label': 'baseball',
        'return': ['url', 'title']
    };
    alchemyNewsAPI.getNewsByTaxonomy(taxonomyQuery, function (error, response) {
        if (error) {
            console.log(error);
        } else {
            // do something with response

            console.log(response);
        }
    });

Concepts

Retrieve news content containing abstract concepts.

    var AlchemyNewsAPI = require('alchemy-news-api');
    var alchemyNewsAPI = new alchemyNews('<YOUR API KEY>');
    var conceptQuery = {
        'concept_text': 'Android',
        'return': ['url', 'title']
    };
    alchemyNewsAPI.getNewsByConcept(conceptQuery, function (error, response) {
        if (error) {
            console.log(error);
        } else {
            // do something with response

            console.log(response);
        }
    });

Keywords

Retrieve news content containing specified keywords. Keywords are terms explicitly mentioned in the article that are determined to be highly relevant to the subject matter of the news article.

    var AlchemyNewsAPI = require('alchemy-news-api');
    var alchemyNewsAPI = new alchemyNews('<YOUR API KEY>');
    var keywordQuery = {
        'keyword_text': 'Clinton',
        'return': ['url', 'title']
    };
    alchemyNewsAPI.getNewsByKeyword(keywordQuery, function (error, response) {
        if (error) {
            console.log(error);
        } else {
            // do something with response

            console.log(response);
        }
    });

Entities

Retrieve news articles using named entities. Named entities are proper nouns such as people, cities, companies, products, etc.

    var AlchemyNewsAPI = require('alchemy-news-api');
    var alchemyNewsAPI = new alchemyNews('<YOUR API KEY>');
    var entityQuery = {
        'entity_text': 'Apple',
        'entity_type': 'company',
        'return': ['url', 'title']
    };
    alchemyNewsAPI.getNewsByEntity(entityQuery, function (error, response) {
        if (error) {
            console.log(error);
        } else {
            // do something with response

            console.log(response);
        }
    });

Sentiment Analysis

Retrieve news articles based on sentiment. Articles have positive, negative or neutral sentiment.

    var AlchemyNewsAPI = require('alchemy-news-api');
    var alchemyNewsAPI = new alchemyNews('<YOUR API KEY>');
    var sentimentQuery = {
        'title': 'IBM',
        'sentiment_type': 'positive',
        'sentiment_score': '>0.5',
        'return': ['url', 'title']
    };
    alchemyNewsAPI.getNewsBySentiment(sentimentQuery, function (error, response) {
        if (error) {
            console.log(error);
        } else {
            // do something with response

            console.log(response);
        }
    });

Contributions

This Nodejs library does not implement all the capabilities of the Alchemy News API. So there is still a lot that can be added. Contributions and improvements are welcome.

alchemy-news-api's People

Contributors

davidadamojr avatar

Watchers

 avatar  avatar

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.