newsapi-pull is a WordPress plugin that pulls headlines from NewsAPI into drafts, with country, language and source filters. It is for editorial teams who want a steady list of leads to work from. It is MIT licensed, and v0.1.0 was released on 15 November 2026. It is independent of NewsAPI and uses its documented HTTP interface with your own API key.
An editor who wants current headlines to work from has two poor options. Copying links by hand is slow. Wiring a news API in with a quick script goes wrong in four ways, each of which costs real time.
list, run, validate, quota, check, sources, log, export and import.A fresh install runs nothing. There are no default pulls, and you must choose a plan before anything is fetched.
Each run goes through pre-checks in order: kill switch, plan chosen, environment rule, key present, pull valid, pull not paused, no back-off, quota meter allows. The first failure ends the run with its reason and sends no request. Then the plugin takes a one-run-at-a-time lock, an option written with an atomic add that expires after 10 minutes. It sends HTTPS requests to the NewsAPI host only, with the key in the X-Api-Key header and TLS verification always on.
For each article, in API order, it rejects removed placeholders and bad or wrapper URLs, skips articles already seen, then checks the title, deny lists, language, age and an optional accept filter. The draft is built from the description and the attribution block, with all API text escaped and the body passed through wp_kses_post. The key is recorded only after the draft exists, so a failed insert is retried.
De-duplication stores two 16-byte hashes per URL in a table, with no URL text. The canonical key ignores the scheme, drops default ports, lower-cases and converts the host to ASCII, strips delivery labels such as www, m and amp, normalises the path, collapses AMP path forms and drops tracking parameters. Language subdomains are kept, so hindi.example.com is a different article. The plain key is frozen forever, so rows keep matching if the canonical rules change. You can try the keys without WordPress:
php examples/check-keys.php "https://m.example.com/news/story/amp/?utm_source=x"
Typical setup in wp-config.php:
define('NEWSAPI_PULL_API_KEY', 'your-key');
define('NEWSAPI_PULL_PLAN', 'developer'); // or 'paid'
define('WP_ENVIRONMENT_TYPE', 'development'); // developer plan only fetches on local or development
draft or pending after every filter, enforced by a wp_insert_post_data hook at PHP_INT_MAX, and checked again after the insert. The plugin never publishes or schedules.developer plan fetches only when the environment type is local or development. No setting, filter, constant, CLI flag or button changes that. The environment filter may only turn true into false. Only the paid plan fetches elsewhere.[redacted], and the settings page shows only the last four characters.developer) with a reserve of 20 requests held back for manual runs. A kill switch constant, NEWSAPI_PULL_DISABLED, wins over the setting.manage_options and a nonce, and all output is escaped.Meter::claim() now checks and counts in one step under a MySQL named lock, just before each send.redirection, and a redirect carries the key header to any host. Redirects are now fixed at 0 after the filter.content field the API returns is truncated and the plugin never fetches the article page for more.newsapi_pull_sideload_image.Test status: this is v0.1.0. The review reports 125 PHPUnit tests, PHPStan level 8 and phpcs clean on a local PHP 8.3. The tests use stubs and no live NewsAPI account, and the plugin has not run on a live site. CI has not yet run on GitHub. It was specified, built and reviewed in separate roles by language-model coding agents under the editor’s direction.
It needs WordPress 6.4 or later and PHP 8.1 or later. The intl extension is optional.
The package is not on Packagist yet, so first add a Composer vcs repository entry for https://github.com/IndianOpinion/newsapi-pull.
composer require indianopinion/newsapi-pull
Without Composer, put the folder in wp-content/plugins/newsapi-pull/ and activate it. Nothing runs until you choose a plan.