Build a Fed decision countdown in JavaScript

A Fed decision countdown needs an authenticated server request for the next recorded FOMC release and a local browser timer. Keep the Finance Calendar account key on your server; do not call the API anonymously or publish the key in browser JavaScript.

Detail of the Federal Reserve building in Washington, DC
Federal Reserve building, Washington, DC. Credit: iStock.com/amedved.
Contents

This countdown example uses the paid /next endpoint to find a recorded FOMC release. A custom countdown can instead consume Free Developer’s permitted /calendar or /today schedule JSON when the event falls inside its seven-date window; Free does not enable /next or a series filter.

Account and API key required

Use a verified account key for authenticated data requests, in X-API-Key or Authorization: Bearer. Choose Free Developer for its bounded schedule JSON or a paid plan for numerical figures, wider dates, richer routes and tools. The OpenAPI schema, current product offer and fixed recorded sample are public without a key. Create and manage keys in your account; anonymous key creation is not supported.

Browse the public economic calendar free. Connect apps and AI tools with paid API access from US$19.99/year. Starter includes 1,000 requests per UTC day and 25,000 per UTC calendar month. Build is US$9.99/month or US$95.90/year, with 100,000 requests per UTC day. Scale is US$29.00/month or US$278.40/year, with 1,000,000 requests per UTC day and the complete current dataset download. Free Developer provides 100 successful schedule JSON responses per UTC calendar month, up to 10 per UTC day, with one key issued after approval of your request (allow up to 48 hours for review). Use /calendar and /today for economic-release and central-bank schedules from UTC today through today+6, with country/impact filters, bounded date narrowing and up to 20 records per response. The allowance renews monthly; no card, fixed expiry or automatic paid subscription. Figures, history, wider dates/routes, CSV/ICS, hosted MCP, Data explorer and webhooks require a paid plan. Personal and customer-facing projects are allowed within these limits and applicable source terms. Annual prices are charged upfront. Paid plans renew at their selected interval until cancelled; applicable tax is included. Linked keys share one account allowance.

Inspect the recorded sample · Compare current plans. Existing subscription agreements and paid-through migration access retain their confirmed terms.

Keep keys in private server or application configuration. Do not put them in public HTML, client JavaScript, spreadsheet cells, iframe URLs or query strings. For the shell examples below, enter your real key privately:

read -r -s FC_API_KEY
export FC_API_KEY

Missing or invalid credentials return 401; revoked or disallowed access returns 403; exhausted allowance returns 429. Key validation or data unavailability can return 503. Respect Retry-After when supplied. Credentialed responses are private/no-store; do not treat them as public CDN content. Retain Finance Calendar attribution and each record’s source rights.

The API key authenticates the website or application owner. People viewing a public server-rendered calendar do not need Finance Calendar accounts. Public commercial display is allowed with the required attribution and applicable source terms. The signed-in guard in the example below is an optional private-application pattern, not an additional Finance Calendar licensing requirement. For a public display, fetch the approved records on your server with your owner key and render the data and credits without exposing the key or creating an unrestricted API relay.

1. Fetch on an authenticated server

Use Node.js 20 or newer. The private-application helper below uses an example server-verified user guard and reads the owner’s key from private FC_API_KEY configuration. Public server-rendered displays may instead load permitted data under the owner’s account without requiring Finance Calendar accounts for visitors. Integrate it into your existing application; the helper does not create a public endpoint.

// Node.js 20+ server helper; call behind your existing session/authorization checks.
export async function nextReleaseForUser(authenticatedUser, series = "fomc") {
  if (!authenticatedUser?.id) throw new Error("Sign in to continue");
  if (!["fomc", "us-cpi", "us-nfp", "ecb", "boe"].includes(series)) throw new Error("Unsupported series");
  const key = process.env.FC_API_KEY;
  if (!key) throw new Error("FC_API_KEY is required on the server");
  const response = await fetch("https://www.financecalendar.com/wp-json/fc/v1/next?series=" + encodeURIComponent(series), {
    headers: { "X-API-Key": key }, cache: "no-store"
  });
  if (!response.ok) throw new Error("Calendar API returned HTTP " + response.status);
  return response.json(); // Retain attribution and the event's source/rights metadata.
}

The user identity must come from your trusted session, never from an incoming query or JSON field. For the private-application example shown, the backend route must reject unauthenticated application callers, validate filters, enforce its own access/rate limits and return private/no-store responses. This example guard does not impose Finance Calendar account requirements on visitors to a permitted public display. Never return the API key.

2. Count down in the browser

Provide an element such as <div id="countdown"></div>. After implementing your own protected /api/fc-next route, use this browser code. It contains no Finance Calendar credential:

// Your own protected application route, implemented with the server helper above.
const response = await fetch("/api/fc-next?series=fomc", { credentials: "same-origin", cache: "no-store" });
if (!response.ok) throw new Error("Could not load an authorized release");
const data = await response.json();
const release = data.next;
const output = document.getElementById("countdown");
const exact = release?.time_precision === "exact" || release?.time_precision === "minute" || release?.time_precision === "second";
const instant = exact && release?.release_at_utc ? Date.parse(release.release_at_utc) : NaN;
if (!Number.isFinite(instant)) {
  output.textContent = "Exact announcement time is not confirmed";
} else {
  function render() {
    const remaining = instant - Date.now();
    if (remaining <= 0) { output.textContent = "Scheduled time reached; check the publisher for results"; return; }
    const seconds = Math.floor(remaining / 1000);
    const days = Math.floor(seconds / 86400);
    const hours = Math.floor(seconds / 3600) % 24;
    const minutes = Math.floor(seconds / 60) % 60;
    output.textContent = `${days}d ${hours}h ${minutes}m ${seconds % 60}s`;
  }
  render();
  window.setInterval(render, 1000); // Updates the display, not the API.
}

3. Preserve uncertain timing

Only an explicitly reported exact release instant can support a countdown. Date-only events, unconfirmed times, publication windows and estimated date windows must remain labelled as such; do not convert a date to midnight or use a range start as an exact deadline. A countdown reaching zero does not establish that a decision was published or that an actual result has been captured.

4. Change the series and inspect results

The server allowlist includes FOMC, US CPI, US jobs, ECB and Bank of England series. Extend it deliberately using the authenticated series directory. For recorded past results use authenticated history or observation queries from your server. Actuals, consensus and prior values vary by source and may remain null; never infer them from elapsed time.

5. Limits and error handling

Starter includes 1,000 requests per day and 25,000 per UTC calendar month; Build includes 100,000 per day; Scale includes 1,000,000 per day. All account keys share the effective allowance; older grandfathered accounts and keys retain their earlier allowance. One server fetch can supply a local timer for the chosen application view or permitted server-rendered public display. Do not make a new API call every second. Keep credentialed upstream responses out of public caches. For the shown private application, protect its derived cache with the same access controls. A permitted public display can render selected records and credits from an owner-controlled server process; inspect generation/source freshness and never cache or expose the credential.

Handle 401/403 by resolving account credentials or permissions, 404 as no matching upcoming event in current coverage, 429 using Retry-After, and 503 as temporary authentication/data unavailability. Display an honest unavailable state rather than an invented date.

6. Attribution and alternatives

Keep a visible Finance Calendar link beside your display and retain publisher source/rights metadata. A server-side widget integration uses the same required key; the old anonymous script/iframe embed is not supported. If your site cannot keep the owner’s credential private, link to the FOMC schedule page instead.

About Finance Calendar

Economic release schedules, market calendars and practical guides to using the data.

About the site
Back to Resources

Keep reading

All articles

From Resources

From Resources

From Resources