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

@jasonbelmonti/news-api-cli

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jasonbelmonti/news-api-cli

command line interface to News API (https://newsapi.org/)

  • 0.0.5
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

News API CLI

Command-line interface for News API.

Provides three commands:

Getting Started

Make news.js executable

computer-1:repositories user$ cd news-api-cli
computer-1:news-api-cli user$ chmod +x news.js

Add News API Key

Get a key here).

Add a file called .env in the project root containing your News API key.

// contents of news-api-cli/.env
NEWS_API_KEY=YOUR-KEY-HERE

Commands

Sources

Usage

sources [options]

Options
  -l, --language [language]  Only return articles written in this language
  -v, --verbose              If enabled, show description, url, category, language, country
  -c, --category [category]  Only return articles relevant to this category
  -w, --write [path]         Save the result to [path] (utf-8 encoding)
  -h, --help                 output usage information
Examples
Retreive all english language sources and write them to sources.json:
./news.js sources -l en -w sources.json
Retreive all "business" sources and save to sources/business.json:
./news.js sources -c business -w sources/business.json
Retreive all sources and print all information:
./news.js sources -v

Everything

Usage

everything [options] [query]

Options:
  -f, --from [from]           Articles published after date This should be in ISO 8601 format (e.g. 2018-07-07 or 2018-07-07T01:07:36)
  -t, --to [to]               Articles published before date. This should be in ISO 8601 format (e.g. 2018-07-07 or 2018-07-07T01:07:36)
  -s, --sources <sources>     A list of comma-separated news source ids
  -p, --pages <pages>         Number of pages to fetch
  -z, --page-size <pageSize>  Number of results per page (max 100)
  -v, --verbose               If enabled, show url
  -l, --language [language]   Only return articles written in this language
  -o, --order [order]         order by "relevancy", "popularity", or "publishedAt"
  -w, --write [path]          Save the result to [path]
  -h, --help                  output usage information
Examples
retreive up to 400 articles (4 pages of 100 results each) matching the query "gun control" from The New York Times from 05/01/2017 to 06/01/2017 and save to nyt.json:
./news.js everything gun control -s the-new-york-times -f 2018-05-01 -t 2018-06-01 -p 4 -z 100 -w nyt.json

Keywords

FAQs

Package last updated on 12 Aug 2018

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