A modular command-line toolchain written in C11 for fetching, storing, and querying global news via the World News API.
Two stable versions are maintained via Git branches:
| Branch | Backend | Best for |
|---|---|---|
main |
SQLite | Single-user, portable, zero-config |
postgres |
PostgreSQL | Scalable, concurrent, server-based |
Three single-purpose tools form a pipeline:
news_api_client → update_database → read_news
(fetch) (store) (query)
news_api_client— fetches articles from the API and saves raw JSONupdate_database— parses JSON and idempotently inserts articles into the databaseread_news— queries the local database from the command line
You need git and basic system utilities. make setup handles everything else.
- SQLite branch: installs
gcc,make,libcurl,jansson,sqlite3 - PostgreSQL branch: installs the above plus
pkg-configand a full PostgreSQL server
git clone https://github.com/PaulFalk/worldnews_cli.git
cd worldnews_cli
# Choose a branch (default is SQLite)
git switch main # SQLite
git switch postgres # PostgreSQL
make setup # Install dependencies and configure API key
make # Build all three tools into bin/Get a free API key at worldnewsapi.com.
make search query="artificial intelligence"This fetches articles matching the query, saves them as JSON, and inserts them into the database in one step.
| Command | Description | Example |
|---|---|---|
make recent |
Show the 10 most recent articles | make recent |
make search-db query="..." |
Search titles and content | make search-db query="nvidia" |
make category name="..." |
List articles by category | make category name="technology" |
make get-article id="..." |
View a single article by ID | make get-article id="42" |
| Command | Description |
|---|---|
make clean |
Remove binaries, temp data, and logs |
make clean-full |
Destructive. Also removes the database and config file |
worldnews_cli/
├── Makefile
├── include/
│ └── config.h
├── scripts/
│ ├── setup.sh
│ └── distros/
│ ├── debian.sh
│ └── arch.sh
└── src/
├── config.c # Secure API key loading
├── news_api_client.c # HTTP fetch from World News API
├── update_database.c # JSON parsing and DB insertion
└── read_news.c # Database query CLI
API keys are stored in ~/.config/news_client/config with permissions 600. The key is never logged or embedded in source code. You can also set it via the environment variable NEWS_API_KEY.
Build output is logged to logs/build.log. If a build fails, check there first.
Phase 1 — CLI engine (current) Solidify the C toolchain: error handling, structured logging, configuration management.
Phase 2 — API bridge Add a Redis job queue and a lightweight Go or Python web API server backed by the PostgreSQL version.
Phase 3 — Frontend Build a single-page application (React, Vue, or Svelte) powered by the Phase 2 API.