interface Article {
id: string; /* Unique article ID */
title: string; /* Article headline */
summary: string; /* One-sentence summary */
content: string; /* Full article body */
author: Author; /* Article author info */
category: NewsCategory; /* Article category enum */
source: string; /* Source name */
url: string; /* Canonical URL */
publishedAt: string; /* ISO 8601 timestamp */
updatedAt: string; /* Last update timestamp */
tags: string[]; /* Associated tags */
language: string; /* Language code */
imageUrl: string | null; /* Featured image URL */
readTime: number; /* Estimated read time in minutes */
}
Installation
Install the SDK using your preferred package manager:
npm install @aevum/news-sdk
yarn add @aevum/news-sdk
pnpm add @aevum/news-sdk
deno install npm:@aevum/news-sdk
Quick Start
Initialize the client and fetch your first news articles in under 30 seconds:
import { NewsClient, NewsCategory } from '@aevum/news-sdk';
// Initialize with your API key
const client = new NewsClient({
apiKey: process.env.AEVUM_API_KEY,
region: 'global',
language: 'en',
cache: true, // Enable response caching
});
// Fetch top headlines
const headlines = await client.fetchArticles({
category: NewsCategory.WORLD,
pageSize: 10,
});
console.log(`Found ${headlines.total} articles`);
console.log(headlines.data[0].title);
// Search for specific topics
const results = await client.search({
query: 'climate summit',
dateFrom: '2025-01-01',
sources: ['reuters', 'ap', 'aevum'],
});
Configuration
The NewsClient constructor accepts the following options:
interface ClientConfig {
apiKey: string; /* Required: Your Aevum API key */
region: 'global' | 'us' | 'eu' | 'apac'; /* Default: 'global' */
language: string; /* ISO 639-1 code, default: 'en' */
timeout: number; /* Request timeout in ms, default: 10000 */
retries: number; /* Auto-retry count, default: 3 */
cache: boolean; /* Enable in-memory cache, default: false */
cacheTTL: number; /* Cache duration in ms, default: 300000 */
baseUrl: string; /* Override API base URL */
}
Authentication
All API requests require authentication via API key. Obtain your key from the Aevum Developer Dashboard.
// Option 1: Environment variable (recommended)
const client = new NewsClient({
apiKey: process.env.AEVUM_API_KEY
});
// Option 2: Bearer token (OAuth 2.0 flow)
const client = new NewsClient({
token: 'bearer_token_here'
});
// Option 3: API key as header override
const client = new NewsClient({
apiKey: 'your_key',
customHeaders: {
'X-Aevum-Version': 'v3',
}
});
Core API
Main client class for interacting with the Aevum News API. Provides methods for fetching articles, searching, and managing streams.
new NewsClient(config: ClientConfig): NewsClient
Fetch articles from the Aevum News database with filtering and pagination support.
fetchArticles(params: ArticleQuery): Promise<NewsResponse>
| Parameter | Type | Required | Description |
|---|---|---|---|
| category | NewsCategory | Optional | Filter by news category |
| query | string | Optional | Search keyword within articles |
| pageSize | number | Optional | Results per page (1-100, default: 20) |
| page | number | Optional | Page number (default: 1) |
| dateFrom | string | Optional | ISO 8601 date, e.g., '2025-01-01' |
| sources | string[] | Optional | Source filter ['reuters', 'ap', 'aevum', 'bbc'] |
| sortBy | 'date' | 'relevance' | Optional | Sort order (default: 'date') |
Full-text search across the Aevum news archive with fuzzy matching and advanced query syntax.
search(params: SearchQuery): Promise<SearchResponse>
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | string | Required | Search query with optional field:value syntax |
| dateFrom / dateTo | string | Optional | Date range filter |
| sources | string[] | Optional | Limit to specific sources |
| lang | string | Optional | Language filter (ISO 639-1) |
Type Definitions
interface SearchResult {
article: Article; /* Matching article */
relevanceScore: number; /* Match relevance (0-1) */
highlights: { title: string; body: string; };
}
Features
- โ Fetch articles by category, source, language, and date range
- โ Full-text search with fuzzy matching and query syntax
- โ Real-time WebSocket streaming for breaking news
- โ Automatic retry with exponential backoff
- โ Response caching with configurable TTL
- โ TypeScript-first with comprehensive type definitions
- โ Browser and Node.js runtime support
- โ Webhook subscription management
- โ Pagination support for large result sets
- โ Rate limit handling with backpressure
Code Examples
const stream = client.subscribe({
eventType: 'breaking',
categories: [
NewsCategory.WORLD,
NewsCategory.TECH,
],
});
stream.on('news', (article) => {
console.log(`๐ด ${article.title}`);
});
const intlClient = new NewsClient({
apiKey: key,
language: 'es', // Spanish
region: 'global',
});
const articles = await intlClient.fetchArticles({
category: NewsCategory.BUSINESS,
language: 'es',
});
const results = await client.search({
query: 'quantum computing',
dateFrom: '2025-01-01',
dateTo: '2025-06-30',
sources: ['aevum', 'techcrunch'],
sortBy: 'relevance',
});
results.data.forEach(r => {
console.log(`Score: ${r.relevanceScore}`);
});
// Create a webhook endpoint
const webhook = await client.createWebhook({
url: 'https://api.mysite.com/hook',
events: ['article.published'],
categories: ['technology'],
secret: 'your_webhook_secret',
});
console.log(webhook.id); // wh_xxxxx
Pagination
All list endpoints support cursor-based and offset-based pagination:
interface Pagination {
page: number; /* Current page */
pageSize: number; /* Items per page */
total: number; /* Total items */
totalPages: number; /* Total pages */
nextPage: number | null; /* Next page number */
previousPage: number | null;/* Previous page number */
hasNext: boolean; /* Has more results */
hasPrevious: boolean; /* Has previous page */
}
Error Handling
The SDK throws structured errors with helpful messages:
import { AevumError, ErrorCode } from '@aevum/news-sdk';
try {
const articles = await client.fetchArticles(...);
} catch (err) {
if (err instanceof AevumError) {
switch (err.code) {
case ErrorCode.RATE_LIMIT: // 429
await wait(err.retryAfter);
break;
case ErrorCode.AUTH_FAILED: // 401
refreshToken();
break;
case ErrorCode.NOT_FOUND: // 404
console.log('No articles found');
break;
}
}
}
Webhooks & Streaming
Subscribe to real-time news events via WebSocket or HTTP webhooks:
const ws = client.createWebSocket({
eventTypes: ['breaking', 'published'],
filters: {
categories: ['world', 'tech'],
urgency: 'high',
},
});
ws.on('open', () => console.log('Connected โ'));
ws.on('news', (msg) => console.log(msg.data.title));
ws.on('close', () => console.log('Disconnected'));
Migration Guide
Upgrading from v2.x to v3.x:
/* โ v2.x (deprecated) */
import { AevumSDK } from '@aevum/sdk';
const sdk = new AevumSDK(key);
const articles = await sdk.getHeadlines();
/* โ
v3.x (current) */
import { NewsClient } from '@aevum/news-sdk';
const client = new NewsClient({ apiKey: key });
const articles = await client.fetchArticles({ category: 'world' });
Changelog
- Added real-time WebSocket streaming support
- New search query syntax with field-based filtering
- Response caching with configurable TTL
- Added European Union (eu) region support
- Webhook retry mechanism with exponential backoff
- Fixed TypeScript definitions for NewsCategory enum
- Improved error messages for rate limit responses
- Renamed package from @aevum/sdk to @aevum/news-sdk
- Replaced callback-based API with Promises throughout
- Restructured configuration interface
- Removed Node.js 16 and below support
Contributing
We welcome contributions! Here's how to get started:
-
Fork the repository
Click the
Forkbutton on GitHub to create your own copy. -
Clone & install dependencies
git clone your-fork && cd news-sdk && npm install -
Create a feature branch
git checkout -b feature/amazing-improvement -
Write tests and implement changes
Run
npm testto ensure all tests pass. Add tests for new functionality. - Submit a Pull Request Push your branch and open a PR. Reference any related issues.
License
This project is licensed under the MIT License.
MIT License
Copyright (c) 2025 Aevum News
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in
the Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell
copies of the Software.
Resources
๐ src/ ๐ package.json โโโ ๐ client/ ๐ tsconfig.json โ โโโ NewsClient.ts ๐ README.md โ โโโ types.ts ๐ CHANGELOG.md โ โโโ search.ts ๐ LICENSE โโโ ๐ hooks/ ๐ .github/ โ โโโ webhooks.ts โ โโโ ISSUE_TEMPLATE/ โ โโโ stream.ts โ โโโ PULL_REQUEST_TEMPLATE/ โโโ ๐ utils/ โ โโโ cache.ts โ โโโ retry.ts โโโ ๐ index.ts โโโ ๐ types.ts
๐ข [#284] feat: Add GraphQL subscription support ๐ข [#271] feat: Support WebSocket reconnection logic ๐ก [#256] fix: Handle null content in Article type ๐ก [#243] fix: Rate limit header parsing on edge cases ๐ก [#230] docs: Update migration guide for v3.1 โ v3.2 ๐ด [#198] bug: Pagination breaks with special characters in query ๐ด [#175] bug: TypeScript types not exported from index
โ [#412] feat: Add real-time WebSocket streaming (#284) โ [#398] fix: Correct pagination cursor handling (#243) โ [#385] docs: Add Webhook examples and testing guide (#230) โ [#371] refactor: Split client into modular components (#198) ๐ [#356] feat: Implement caching layer with Redis support
๐ฌ [Announcement] v3.2.0 Released with WebSocket streaming ๐ฌ [Help] How to handle rate limiting in production? ๐ฌ [Discussion] Best practices for webhook security ๐ฌ [Show] Building a news dashboard with @aevum/news-sdk ๐ฌ [Question] TypeScript types not found in TypeScript 5.0
โ CI/CD Pipeline: Tests passing (472/472) โ CodeQL: No vulnerabilities โ Coverage: 96.4% test coverage โ Lint: All checks passed
๐ฆ @aevum/news-sdk v3.2.0 (latest) ๐ฆ @aevum/news-sdk v3.1.0 ๐ฆ @aevum/news-sdk v3.0.0 ๐ฆ @aevum/news-sdk v2.9.0
(Dec 15, 2025) Added: WebSocket streaming, improved search Fixed: Rate limit handling, TypeScript types v3.1.0 (Nov 2, 2025) Added: Webhook retry mechanism Fixed: Category enum types v3.0.0 (Aug 15, 2025) BREAKING: Package rename, callback โ Promise
๐ Getting Started Guide ๐ API Reference ๐ Webhook Setup Tutorial ๐ Migration: v2 โ v3 ๐ Best Practices ๐ FAQ