JavaScript Integration
The Feed API is a plain HTTP JSON endpoint with full CORS support, callable from any JavaScript environment — browser, Node.js, Deno, a Cloudflare Worker — no SDK required.
Displaying a Single Item
The widget renders list views. Detail pages require fetching a specific item by UUID:
const id = new URLSearchParams(location.search).get('id');const res = await fetch(`https://your-org.flarebuilder.com/p/${id}`);
if (!res.ok) { document.getElementById('content').textContent = 'Not found.';} else { const item = await res.json(); const content = item.sections.find(s => s.id === 'content')?.data ?? {};
document.getElementById('title').textContent = item.title; document.getElementById('body').innerHTML = content.body ?? ''; document.getElementById('published').textContent = new Date(item.date_published).toLocaleDateString();}Fetch All Pages
To retrieve every item — for a search index, a static site build, or a data pipeline:
async function fetchAll(baseUrl, params = {}) { const items = []; const qs = new URLSearchParams({ limit: 100, ...params }); let url = `${baseUrl}?${qs}`;
while (url) { const res = await fetch(url); const data = await res.json(); items.push(...data.items); url = data.pagination.has_more ? data.pagination.next : null; }
return items;}
const allEvents = await fetchAll('https://your-org.flarebuilder.com/feed', { templates: 'event', status: 'active',});console.log(`Fetched ${allEvents.length} events`);Node.js / Server-Side
Node.js 18+ ships fetch natively. Use fetchAll in build scripts to generate static data:
import { writeFileSync } from 'fs';
const items = await fetchAll('https://your-org.flarebuilder.com/feed');
writeFileSync('public/search-index.json', JSON.stringify( items.map(({ id, title, sections }) => ({ id, title, summary: sections[0]?.data?.summary ?? '', }))));
console.log(`Indexed ${items.length} items`);For older Node.js (< 18) or environments without fetch, use any HTTP library (node-fetch, axios, undici) — the API surface is identical.
Cloudflare Workers
The Feed API runs on the same Cloudflare network as Workers, so inter-worker requests are extremely fast:
export default { async fetch(request, env) { const feedRes = await fetch( 'https://your-org.flarebuilder.com/feed?templates=news&limit=5' ); const feed = await feedRes.json();
const html = `<!doctype html><html><body> <h1>${feed.title}</h1> <ul> ${feed.items.map(item => `<li>${item.title}</li>`).join('')} </ul> </body></html>`;
return new Response(html, { headers: { 'Content-Type': 'text/html' }, }); },};Efficient Polling with ETags
If you poll the feed on a timer, use ETags to skip processing when nothing has changed:
let etag = null;
async function pollFeed() { const headers = etag ? { 'If-None-Match': etag } : {}; const res = await fetch('https://your-org.flarebuilder.com/feed', { headers });
if (res.status === 304) return; // Nothing changed
etag = res.headers.get('etag'); const data = await res.json(); renderFeed(data.items);}
setInterval(pollFeed, 2 * 60 * 1000);pollFeed();ICS Calendar Subscription
Construct the ICS URL and let the browser or OS handle the subscription prompt:
function addCalendarLink(containerId, type = 'event') { const url = `https://your-org.flarebuilder.com/feed?format=ics&templates=${type}`; const a = document.createElement('a'); a.href = url; a.download = 'calendar.ics'; a.textContent = 'Subscribe to calendar'; document.getElementById(containerId).appendChild(a);}
// Or open directly after a button click:window.location.href = 'https://your-org.flarebuilder.com/feed?format=ics&templates=event';