Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

worldnews_cli

License: MIT C11

A modular command-line toolchain written in C11 for fetching, storing, and querying global news via the World News API.


Database Backends

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

Architecture

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 JSON
  • update_database — parses JSON and idempotently inserts articles into the database
  • read_news — queries the local database from the command line

Prerequisites

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-config and a full PostgreSQL server

Installation

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.


Usage

Fetch and store news

make search query="artificial intelligence"

This fetches articles matching the query, saves them as JSON, and inserts them into the database in one step.

Query the database

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"

Maintenance

Command Description
make clean Remove binaries, temp data, and logs
make clean-full Destructive. Also removes the database and config file

Project Structure

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

Configuration

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.


Roadmap

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.


License

MIT

About

A simple yet powerful command-line toolchain written in C for fetching and parsing news articles from the [World News API](https://worldnewsapi.com/). This project is designed with a clean, modular, and secure architecture, separating the fetching and parsing logic into two distinct utilities.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages