🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

newsapi.js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

newsapi.js

A TypeScript/JS wrapper for the News API newsapi.org

1.3.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

newsapi.js

newsapi.js is a TypeScript (and plain JS) library for newsapi.org.

How do I use this thing?

Just run:

npm install newsapi.js -s

And some examples:

const news = require("newsapi.js");

// For TypeScript: import {NewsAPIClient} from "newsapi.js"

const sources = news.getSources()
    .then(source => console.log(sources)) // Wouldn't do this if I were you
    .catch((err) => console.error(err));

const topHeadlines = news.getTopHeadlines()
    .then(headline => {
        const articles = headline.articles;
        console.log(articles[0].title);
    });

How do I contribute?

Just create a PR! Testing information is below:

How to test this library.

All the hard Mocha & TypeScript work is done for you. But you need to provide yourself a token from here: https://newsapi.org/account.

Once you have received a token, create a file at src/test/config/test.config.json with the following content:

{
    "token": "token here"
}

While replacing the string token here with your token. Then run the following:

$ npm install

and to test:

$ npm test

Licence

We abide by the MIT license.

FAQs

Package last updated on 19 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts