newsapi.js

1.3.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i newsapi.js

Weekly Downloads

0

Version

1.3.0

License

MIT

Unpacked Size

20.1 kB

Total Files

14

Last publish

Collaborators

  • circuitrcay