Skip to content

Client library (SDK) to quickly and easily get started with News API without worrying about the underlying set up.

License

Notifications You must be signed in to change notification settings

isolomak/ts-newsapi

Repository files navigation

ts-newsapi

ci Coverage Status NPM Downloads NPM License

Client library (SDK) to quickly and easily get started with News API without worrying about the underlying set up

Fast and easy to use.
Written in TypeScript.
Fully tested with 100% code coverage.
Powered by newsapi

Installation

npm install --save ts-newsapi

Getting Started

Get API key from newsapi.org

import NewsAPI from 'ts-newsapi';

const newsAPI = new NewsAPI('api_key');

// Get the subset of news publishers that top headlines (newsAPI.getTopHeadlines()) are available from. 
// It's mainly a convenience method that you can use to keep track of the publishers available on the API, and you can pipe it straight through to your users.
const sources = await newsAPI.getSources({
    category: 'general',
    language: 'en',
    country: 'us',
});

// Top and breaking headlines  
const topHeadlines = await newsAPI.getTopHeadlines({
    q: 'stocks',
    country: 'us',
    category: 'business',
    pageSize: 20,
    page: 1,
});

// Search through millions of articles from over 50,000 large and small news sources and blogs.
const headlines = await newsAPI.getEverything({
    q: 'stocks',
    qInTitle: 'stock',
    sources: [ 'bbc-news' ],
    language: 'en',
    sortBy: 'relevancy',
    pageSize: 20,
    page: 1,
});

Tests

  npm test

License

This project is licensed under the MIT License - see the LICENSE file for details.


Documentation

NewsAPI Documentation

About

Client library (SDK) to quickly and easily get started with News API without worrying about the underlying set up.

Resources

License

Stars

Watchers

Forks

Packages

No packages published