Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

AYLIEN News API - JavaScript SDK

The AYLIEN News API is the most powerful way of sourcing, searching and syndicating analyzed and enriched news content. It is accessed by sending HTTP requests to our server, which returns information to your client.

Sign up at https://newsapi.aylien.com/.

For more documentation see https://newsapi.aylien.com/docs/.

Installation

For Node.js

npm

Install it via:

npm install aylien-news-api --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var AylienNewsApi = require("aylien-news-api");

var defaultClient = AylienNewsApi.ApiClient.instance;

var app_id = defaultClient.authentications["app_id"];
app_id.apiKey = process.env["NEWSAPI_APP_ID"];

var app_key = defaultClient.authentications["app_key"];
app_key.apiKey = process.env["NEWSAPI_APP_KEY"];

var api = new AylienNewsApi.DefaultApi();

var opts = {
  title: "trump",
  sortBy: "social_shares_count.facebook",
  notLanguage: ["en"],
  publishedAtStart: "NOW-7DAYS",
  publishedAtEnd: "NOW",
  entitiesBodyLinksDbpedia: [
    "http://dbpedia.org/resource/Donald_Trump",
    "http://dbpedia.org/resource/Hillary_Rodham_Clinton"
  ]
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log("API called successfully. Returned data: ");
    console.log("========================================");
    for (var i = 0; i < data.stories.length; i++) {
      console.log(data.stories[i].title + " / " + data.stories[i].source.name);
    }
  }
};

api.listStories(opts, callback);

Documentation for API Endpoints

All URIs are relative to https://api.aylien.com/news

Class Method HTTP request Description
AylienNewsApi.DefaultApi listAutocompletes GET /autocompletes List autocompletes
AylienNewsApi.DefaultApi listClusters GET /clusters List Clusters
AylienNewsApi.DefaultApi listCoverages GET /coverages List coverages
AylienNewsApi.DefaultApi listHistograms GET /histograms List histograms
AylienNewsApi.DefaultApi listRelatedStories GET /related_stories List related stories
AylienNewsApi.DefaultApi listStories GET /stories List Stories
AylienNewsApi.DefaultApi listTimeSeries GET /time_series List time series
AylienNewsApi.DefaultApi listTrends GET /trends List trends

Documentation for Models

You can’t perform that action at this time.