npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@jasonbelmonti/news-api-cli

v1.0.1

Published

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

Downloads

3

Readme

News API CLI

A nodejs-powered command-line interface for News API.

sources :arrow_right: /sources

everything :arrow_right: /everything

top-headlines :arrow_right: /top-headlines

Getting Started

Install dependencies

computer-1:repositories user$ cd news-api-cli
computer-1:news-api-cli user$ npm install

Make news.js executable

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

Get all english language sources and write them to sources.json:
./news.js sources -l en -w sources.json
Get all "business" sources and save to sources/business.json:
./news.js sources -c business -w sources/business.json
Get 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

Get 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

Top Headlines

Usage

topHeadlines [options] [query]

Options:

-u, --country [country]     Only return articles relevant to this country
-c, --category [category]   Only return articles relevant to this category
-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
-w, --write [path]          Save the result to [path]
-h, --help                  output usage information

Examples

Get top headlines in the United States
./news.js topHeadlines -u us
Get top business headlines in China matching the query "Apple"
./news.js topHeadlines Apple -u ch -c business