Skip to main content

Widget Embed Guide

A drop-in JavaScript library that renders a styled news feed inside any website. It uses Shadow DOM for CSS isolation, preventing style conflicts with your page.

API Base URL: https://wingnews.theinvestinsight.com


Quick Start​

Add the script tag and initialize with your API key:

<div id="news-feed"></div>

<script src="https://wingnews.theinvestinsight.com/widget/news-widget.iife.js"></script>
<script>
NewsWidget.init({
apiKey: 'na_live_abc123...',
container: '#news-feed',
});
</script>

That's it — a news feed with the default configuration will render in the #news-feed element.


Installation​

Three bundle formats are available:

FormatFileUsage
IIFEnews-widget.iife.js<script> tag, global NewsWidget
ESMnews-widget.esm.jsimport { NewsWidget } from '...'
UMDnews-widget.umd.jsCommonJS / AMD / global

ESM Example

import { NewsWidget } from 'https://wingnews.theinvestinsight.com/widget/news-widget.esm.js';

const widget = NewsWidget.init({
apiKey: 'na_live_abc123...',
container: '#news-feed',
theme: 'dark',
layout: 'grid',
});

Configuration​

Pass a configuration object to NewsWidget.init(). Only apiKey and container are required.

OptionTypeDefaultDescription
apiKeystring(required)Your API key
containerstring | HTMLElement(required)CSS selector or DOM element
apiBaseUrlstringcurrent originAPI base URL (for self-hosted deployments)
theme'light' | 'dark' | 'auto''auto'Color theme (auto follows system preference)
layout'list' | 'grid' | 'ticker''list'Display layout (details)
itemCountnumber10Initial number of items to load (max: 50)
showImagesbooleantrueShow article thumbnail images
showSummarybooleantrueShow article summary text
showDatebooleantrueShow publication date
dateFormat'relative' | 'absolute''relative'Date display ("2 hours ago" vs "Feb 15, 2026")
refreshIntervalnumber0Auto-refresh interval in seconds (0 = off)
clickBehaviorstring'modal'How item clicks are handled (details)
paginationstring'none'Pagination mode (details)
maxHeightstring'600px'Maximum widget height (CSS value)
borderRadiusstring'8px'Container border radius (CSS value)
fontFamilystringsystem stackFont family override (CSS value)

Filters​

Narrow the articles displayed in the widget:

NewsWidget.init({
apiKey: 'na_live_abc123...',
container: '#news-feed',
filters: {
languages: ['es', 'pt'],
topics: ['crypto', 'markets'],
dateFrom: '2026-02-01T00:00:00Z',
dateTo: '2026-02-28T23:59:59Z',
},
});
FilterTypeDescription
languagesstring[]Language codes
topicsstring[]Topic identifiers
querystringFull-text search query
dateFromstringStart date (ISO-8601)
dateTostringEnd date (ISO-8601)

Date Filter UI​

Enable an interactive date picker for users to filter articles by date:

NewsWidget.init({
apiKey: 'na_live_abc123...',
container: '#news-feed',
dateFilter: {
enabled: true,
presets: ['today', 'yesterday', 'week', 'month'],
defaultPreset: 'week',
allowCustomRange: true,
},
});

You can also pass dateFilter: true as a shorthand to enable with defaults.

Available Presets: today, yesterday, week, month, custom


Layouts​

List — Vertical layout with thumbnails alongside title and summary. Best for sidebar or narrow containers.

{ layout: 'list' }

Grid — Card-based layout. Best for wide containers where you want a magazine-style look.

{ layout: 'grid' }

Ticker — Horizontal scrolling ribbon. Best for a breaking-news banner at the top of a page.

{ layout: 'ticker' }

Click Behavior​

Control what happens when a user clicks an article:

ValueBehavior
'modal'Opens article content in a modal overlay (default)
'expand'Expands the article inline to show full content
'callback'Fires the onItemClick callback — no default action

Pagination​

ModeBehavior
'none'Shows only the initial itemCount items (default)
'infinite'Loads more articles as the user scrolls (cursor-based)
'numbered'Displays page buttons below the feed (offset-based)

Callbacks​

NewsWidget.init({
apiKey: 'na_live_abc123...',
container: '#news-feed',
onLoad: (items) => {
console.log(`Loaded ${items.length} articles`);
},
onItemClick: (item, event) => {
console.log('Clicked:', item.title);
},
onError: (error) => {
console.error('Widget error:', error.message);
},
});
CallbackArgumentsTrigger
onLoad(items: NewsItem[])After articles are loaded/refreshed
onItemClick(item: NewsItem, event: MouseEvent)When an article is clicked
onError(error: Error)On API or rendering error

Instance Methods​

NewsWidget.init() returns a widget instance with these methods:

const widget = NewsWidget.init({ ... });

widget.refresh(); // Reload articles from the API
widget.setTheme('dark'); // Switch theme
widget.setLayout('grid'); // Switch layout
widget.setConfig({ itemCount: 20 }); // Update any configuration
widget.getItems(); // Get currently displayed items
widget.destroy(); // Remove the widget and clean up

Multiple Instances​

You can run multiple widgets on the same page, each with independent configuration:

<div id="spanish-news"></div>
<div id="japanese-news"></div>

<script>
NewsWidget.init({
apiKey: 'na_live_abc123...',
container: '#spanish-news',
filters: { languages: ['es'] },
});

NewsWidget.init({
apiKey: 'na_live_abc123...',
container: '#japanese-news',
filters: { languages: ['ja'] },
theme: 'dark',
});
</script>

Instance Management

NewsWidget.getInstance('#spanish-news'); // Get instance by selector
NewsWidget.getInstances(); // Get all instances
NewsWidget.destroy('#spanish-news'); // Destroy by selector
NewsWidget.destroyAll(); // Destroy all instances

Language Codes​

Supported languages for the languages filter:

CodeLanguage
arArabic
deGerman
esSpanish
frFrench
huHungarian
idIndonesian
itItalian
jaJapanese
ptPortuguese
ruRussian
trTurkish
viVietnamese
zhChinese