wpnews
v1.2.1
Published
Official JavaScript/TypeScript SDK for the wpnews AI news API — 75 pre-built tools for AI agents
Maintainers
Readme
wpnews JavaScript / TypeScript SDK
Official JavaScript/TypeScript SDK for the wpnews AI news API.
- Zero dependencies — uses native
fetch(Node 18+, browsers, Deno, Bun, Cloudflare Workers) - Full TypeScript types — every response is typed
- 71 pre-built news tools available via the REST API
Install
npm install wpnews
# or
pnpm add wpnews
# or
yarn add wpnewsQuick start
import { WPNews } from "wpnews";
const news = new WPNews({ apiKey: process.env.WPNEWS_API_KEY });
// Morning briefing — velocity status + hot articles + trending entities
const briefing = await news.getMorningBriefing();
console.log(briefing.velocity.status); // "burst" | "normal" | "quiet"
console.log(briefing.hot_articles[0].title);
// Search
const results = await news.search({ q: "OpenAI GPT-5", limit: 5 });
// Hot articles (breaking news radar)
const hot = await news.getHotArticles({ hours: 6, limit: 10 });
// Batch fetch by slug
const batch = await news.getArticlesBatch({
slugs: ["openai-gpt-5-release", "anthropic-claude-4"],
});
console.log(`Found ${batch.found} of ${batch.requested} articles`);Use with OpenAI function calling
import OpenAI from "openai";
import { WPNews } from "wpnews";
const client = new OpenAI();
const news = new WPNews({ apiKey: process.env.WPNEWS_API_KEY });
// Or load all 71 pre-built tool schemas directly
const tools = await fetch("https://api.wpnews.pro/api/v1/openai-tools.json").then(r => r.json());
const response = await client.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "What's the latest AI news?" }],
tools,
tool_choice: "auto",
});Use with Vercel AI SDK
import { openai } from "@ai-sdk/openai";
import { generateText, tool } from "ai";
import { WPNews, type MorningBriefing } from "wpnews";
import { z } from "zod";
const news = new WPNews({ apiKey: process.env.WPNEWS_API_KEY });
const { text } = await generateText({
model: openai("gpt-4o"),
prompt: "What's the top AI news today?",
tools: {
getMorningBriefing: tool({
description: "Get AI news velocity status, hot articles, and trending entities",
parameters: z.object({ hours: z.number().optional() }),
execute: async ({ hours }) => news.getMorningBriefing({ hours }),
}),
searchNews: tool({
description: "Search AI news by keyword",
parameters: z.object({ q: z.string(), limit: z.number().optional() }),
execute: async ({ q, limit }) => news.search({ q, limit }),
}),
},
});API reference
| Method | Endpoint | Description |
|--------|----------|-------------|
| getArticles(params?) | GET /api/v1/articles | Paginated article list |
| search(params) | GET /api/v1/search | Full-text search |
| getTopics(params?) | GET /api/v1/topics | Topics with article counts |
| getHotArticles(params?) | GET /api/v1/articles/hot | Breaking news by freshness × quality |
| getMorningBriefing(params?) | GET /api/v1/morning-briefing | Agent situational awareness |
| getHourlyActivity(params?) | GET /api/v1/articles/hourly-activity | Publication rate time-series |
| getArticlesBatch(params) | GET /api/v1/articles/batch | Fetch multiple articles by slug |
| getTrendingEntities(params?) | GET /api/v1/entities/trending | Top entities by mention count |
| getEntities(params?) | GET /api/v1/entities | All entities with counts |
| getPulse(params?) | GET /api/v1/pulse | Ultra-compact (~50 tokens) status |
| getNewsVelocity(params?) | GET /api/v1/news-velocity | Current vs baseline publication rate |
| getDailyDigest(params) | GET /api/v1/digest/daily | Articles for a specific date |
Free tier
1,000 API calls/day free. No credit card required. Get your API key →
Or try keyless (rate-limited):
curl https://api.wpnews.pro/api/v1/morning-briefingTypeScript
All response types are exported:
import type { Article, MorningBriefing, HourlyActivity, BatchResult } from "wpnews";License
MIT
