Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-newsapi

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-newsapi

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

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
86
decreased by-38.13%
Maintainers
1
Weekly downloads
 
Created
Source

NPM

ci Coverage Status NPM Downloads NPM License

ts-newsapi

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

Powered by https://newsapi.org/

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

Installation

npmyarn
npm install --save ts-newsapiyarn add ts-newsapi

Getting Started

Get API key from https://newsapi.org

Import library

typescriptjavascript
import NewsAPI from 'ts-newsapi'const NewsAPI = require('ts-newsapi')

Get the news

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,
});

Documentation

Tests

  npm test

License

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

Keywords

FAQs

Package last updated on 06 Jun 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc