Skip to content
BillionaireTracker

How to build a live billionaire net worth tracker

In this tutorial you'll build the classic “Elon Musk has made $X since you opened this page” counter. It takes one request to the free Billionaire Tracker API and about 30 lines of JavaScript.

1. Get the data

Each person in the API has a perSecondUsd field: for billionaires it is the average change in net worth per second since Forbes' last annual list. Free requests cover the top 25.

cURLcurl "https://billionairetracker.us/api/v1/people/elon-musk"

2. Plain JavaScript

HTML<p>Since you opened this page, <strong id="name">…</strong> made
  <strong id="made">$0.00</strong></p>
<small>Data: <a href="https://billionairetracker.us">Billionaire Tracker</a></small>

<script type="module">
  const res = await fetch('https://billionairetracker.us/api/v1/people/elon-musk');
  const { data: p } = await res.json();
  document.getElementById('name').textContent = p.name;

  const start = performance.now();
  const fmt = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' });
  (function tick() {
    const seconds = (performance.now() - start) / 1000;
    document.getElementById('made').textContent = fmt.format(p.perSecondUsd * seconds);
    requestAnimationFrame(tick);
  })();
</script>

3. React version

Reactimport { useEffect, useState } from 'react';

export function LiveEarnings({ slug = 'elon-musk' }) {
  const [person, setPerson] = useState(null);
  const [elapsed, setElapsed] = useState(0);

  useEffect(() => {
    fetch(`https://billionairetracker.us/api/v1/people/${slug}`)
      .then((r) => r.json())
      .then(({ data }) => setPerson(data));
  }, [slug]);

  useEffect(() => {
    const start = performance.now();
    let raf;
    const tick = (t) => { setElapsed((t - start) / 1000); raf = requestAnimationFrame(tick); };
    raf = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(raf);
  }, []);

  if (!person) return null;
  const made = (person.perSecondUsd * elapsed).toLocaleString('en-US', { style: 'currency', currency: 'USD' });
  return (
    <p>
      Since you opened this page, {person.name} made <strong>{made}</strong>.{' '}
      <small>Data: <a href="https://billionairetracker.us">Billionaire Tracker</a></small>
    </p>
  );
}

4. Go further

  • Show the live ranking with /api/v1/rankings?limit=10.
  • Add daily winners and losers with /api/v1/movers (Starter plan).
  • Chart a fortune over time using history from /api/v1/people/{slug} (Starter plan).
  • Cache responses for a minute or two — the data refreshes every 15 minutes, so there's no need to call it on every page view.

See the full API reference or the billionaire net worth API guide. Want to see the finished thing? It's what powers our Elon Musk live tracker.

Try the Billionaire Tracker API

Free tier, no signup. Live data for 3,400+ billionaires on paid plans from $29/month.

Read the docs →

Frequently asked questions

How do I show how much a billionaire makes per second?

Fetch the person from the Billionaire Tracker API, read perSecondUsd, and multiply it by the seconds since the page loaded on every animation frame.

Is the billionaire API free?

The free tier needs no key and covers the 25 richest people, which is enough for most counters and widgets. Paid plans unlock everyone, history and higher limits.

Do I need to credit the data?

Yes — show “Data: Billionaire Tracker” with a link to billionairetracker.us near the widget.