github.com / aevum / news-sdk
A
news-sdk Public
18 branches
12 tags
๐Ÿ”’ Insights
Updated Dec 15, 2025

๐Ÿ“ฐ Aevum News SDK

The official JavaScript/TypeScript SDK for accessing Aevum News API. Fetch global news, manage subscriptions, and integrate real-time journalism into your applications with minimal setup.

๐Ÿ† v3.2.0 โœ… Stable ๐Ÿ“ฆ npm ๐Ÿ”’ Auth โšก Fast ๐ŸŒ 190+ Countries
2.4k
Stars
386
Forks
18
Contributors
12
Releases
6 months
Test Coverage

Installation

Install the SDK using your preferred package manager:

Terminal
npm install @aevum/news-sdk
Terminal
yarn add @aevum/news-sdk
Terminal
pnpm add @aevum/news-sdk
Terminal
deno install npm:@aevum/news-sdk
๐Ÿ’ก
Requires Node.js 18+ or any modern browser with ES2020 support. TypeScript types are included out of the box.

Quick Start

Initialize the client and fetch your first news articles in under 30 seconds:

index.ts
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:

TypeScript
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.

Authentication Options
// 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',
  }
});
โš ๏ธ
Security Notice: Never commit API keys to version control. Use environment variables or a secrets manager in production.

Core API

class NewsClient

Main client class for interacting with the Aevum News API. Provides methods for fetching articles, searching, and managing streams.

Constructor
new NewsClient(config: ClientConfig): NewsClient
method fetchArticles() async

Fetch articles from the Aevum News database with filtering and pagination support.

Signature
fetchArticles(params: ArticleQuery): Promise<NewsResponse>
ParameterTypeRequiredDescription
categoryNewsCategoryOptionalFilter by news category
querystringOptionalSearch keyword within articles
pageSizenumberOptionalResults per page (1-100, default: 20)
pagenumberOptionalPage number (default: 1)
dateFromstringOptionalISO 8601 date, e.g., '2025-01-01'
sourcesstring[]OptionalSource filter ['reuters', 'ap', 'aevum', 'bbc']
sortBy'date' | 'relevance'OptionalSort order (default: 'date')

Type Definitions

interface Article
TypeScript
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 */
}
interface SearchResult
TypeScript
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

๐Ÿ“ฐ Breaking News Stream
Live Stream
const stream = client.subscribe({
  eventType: 'breaking',
  categories: [
    NewsCategory.WORLD,
    NewsCategory.TECH,
  ],
});

stream.on('news', (article) => {
  console.log(`๐Ÿ”ด ${article.title}`);
});
๐ŸŒ Multi-Language
International
const intlClient = new NewsClient({
  apiKey: key,
  language: 'es',  // Spanish
  region: 'global',
});

const articles = await intlClient.fetchArticles({
  category: NewsCategory.BUSINESS,
  language: 'es',
});
๐Ÿ” Advanced Search
Search
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}`);
});
๐Ÿ”Œ Webhooks
Webhook
// 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:

Pagination Response
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:

Error Types
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:

WebSocket Example
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:

Breaking Changes
/* โŒ 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' });
๐Ÿ“‹
For a complete changelog with all breaking changes, see the Changelog section below.

Changelog

v3.2.0 NEW
Published December 15, 2025
  • 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
v3.1.0 NEW FIX
Published November 2, 2025
  • Webhook retry mechanism with exponential backoff
  • Fixed TypeScript definitions for NewsCategory enum
  • Improved error messages for rate limit responses
v3.0.0 BREAKING
Published August 15, 2025
  • 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:

  1. Fork the repository Click the Fork button on GitHub to create your own copy.
  2. Clone & install dependencies git clone your-fork && cd news-sdk && npm install
  3. Create a feature branch git checkout -b feature/amazing-improvement
  4. Write tests and implement changes Run npm test to ensure all tests pass. Add tests for new functionality.
  5. Submit a Pull Request Push your branch and open a PR. Reference any related issues.
๐ŸŽ‰
Follow our Code of Conduct and Contribution Guidelines for detailed standards.

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

Repository BrowserShowing latest commit
๐Ÿ“ 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
Issues42 open issues
๐ŸŸข [#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
Pull Requests18 open PRs
โœ… [#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
Discussions127 discussions
๐Ÿ’ฌ [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
Actions
โœ… CI/CD Pipeline: Tests passing (472/472)
โœ… CodeQL: No vulnerabilities
โœ… Coverage: 96.4% test coverage
โœ… Lint: All checks passed
Packages
๐Ÿ“ฆ @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
Releases
(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
Wikis
๐Ÿ“š Getting Started Guide
๐Ÿ“š API Reference
๐Ÿ“š Webhook Setup Tutorial
๐Ÿ“š Migration: v2 โ†’ v3
๐Ÿ“š Best Practices
๐Ÿ“š FAQ