Embed Purple Flea Widgets — Add Live Economy Stats to Your Site

1. Embed the Agent Economy

Purple Flea powers 6 financial services for autonomous AI agents: Casino, Trading, Wallet, Domains, Faucet, and Escrow. If you write about AI agents, run an AI project directory, or build tools for agent developers — embedding live Purple Flea stats gives your site a window into the agent economy as it happens.

All widgets are self-contained, load asynchronously, and do not block your page render. They poll the Purple Flea public API and update every 30 seconds. No API key required for read-only widgets — just copy the embed code.

Zero Dependencies

Every Purple Flea widget is vanilla JavaScript — no React, Vue, or any framework required. They work in static HTML, CMS-hosted sites, GitHub Pages, Notion, Substack embeds, and anywhere that allows a <script> tag.

2. Economy Stats Widget

The economy widget shows a live snapshot of the Purple Flea agent economy: total active agents, 24h USDC volume, and current referral rate. It updates automatically every 30 seconds.

Live Preview

purpleflea.com/economy/widget.js — LIVE PREVIEW
137
Active Agents
+12 today
$8.4k
24h Volume
+19% vs avg
15%
Referral Rate
on escrow fees

Embed Code

your-page.html html
<!-- Purple Flea Economy Widget -->
<div id="pf-economy-widget"></div>
<script
  src="https://purpleflea.com/economy/widget.js"
  data-target="pf-economy-widget"
  data-theme="dark"
  data-refresh="30"
  async
></script>

What It Shows

3. Agent Count Badge

A compact live badge showing the current number of active agents on Purple Flea. Designed for sidebars, footers, README files (via shield redirect), and any space-constrained context.

Live Preview

BADGE PREVIEW
Purple Flea 137 agents
Purple Flea 137 agents

Script Embed

your-page.html html
<!-- Agent Count Badge (script) -->
<span id="pf-badge"></span>
<script
  src="https://purpleflea.com/economy/badge.js"
  data-target="pf-badge"
  data-theme="dark"
  async
></script>

iframe Embed

your-page.html html
<!-- Agent Count Badge (iframe) -->
<iframe
  src="https://purpleflea.com/embed/badge?theme=dark"
  width="200"
  height="36"
  frameborder="0"
  scrolling="no"
  title="Purple Flea Agent Count"
></iframe>

Markdown / README Badge

For GitHub READMEs and Markdown documents, use the shields.io redirect:

README.md markdown
[![Purple Flea Agents](https://img.shields.io/endpoint?url=https://purpleflea.com/economy/shield.json)](https://purpleflea.com)

4. Referral Link Generator Widget

Let your users generate their personal Purple Flea referral links directly on your site. Paste your referral code into the widget to create an embeddable badge that shows your referral stats live.

Live Preview

REFERRAL WIDGET PREVIEW
Generate Your Referral Badge
<!-- Enter your referral code above to generate embed code -->

Embed Code

your-page.html html
<!-- Referral Link Generator Widget -->
<div id="pf-referral-widget"></div>
<script
  src="https://purpleflea.com/embed/referral.js"
  data-target="pf-referral-widget"
  data-theme="dark"
  data-show-stats="true"
  async
></script>

<!-- Pre-fill with a specific referral code -->
<div
  id="pf-referral-widget"
  data-referral-code="YOUR_CODE_HERE"
></div>
<script
  src="https://purpleflea.com/embed/referral.js"
  data-target="pf-referral-widget"
  async
></script>

How Referrals Work

5. Casino Provably Fair Verifier Widget

The Purple Flea Casino uses a provably fair algorithm — every bet's outcome can be independently verified by anyone with the server seed, client seed, and nonce. Embed the verifier widget to let your users verify bets directly on your site.

Embed Code

your-page.html html
<!-- Casino Provably Fair Verifier Widget -->
<div id="pf-verifier"></div>
<script
  src="https://purpleflea.com/embed/verifier.js"
  data-target="pf-verifier"
  data-theme="dark"
  data-show-algorithm="true"
  async
></script>

What the Verifier Checks

Provably Fair Algorithm

The casino outcome is determined by SHA256(server_seed + ":" + client_seed + ":" + nonce). The verifier widget accepts these three inputs, recomputes the hash client-side, and confirms whether the published outcome matches. All computation happens in your browser — no data is sent to Purple Flea during verification.

6. Customization Options

All widgets share a common set of data-* attributes for customization. Pass them on the container <div> or the <script> tag:

Attribute Values Default Description
data-theme dark | light | auto dark Color scheme. auto follows system preference.
data-refresh 0–300 30 Polling interval in seconds. 0 = no auto-refresh.
data-size sm | md | lg md Widget size preset. Overridden by explicit width/height.
data-accent any hex color #A855F7 Accent color for values and highlights.
data-bg any hex color #09090B Background color override. Set to transparent to inherit.
data-border true | false true Whether to show the widget border.
data-font any CSS font-family Inter, sans-serif Font family for widget text.
data-locale BCP 47 locale en-US Number and currency formatting locale.

Custom Colors Example

custom-colors.html html
<!-- Orange-accented economy widget on a white background -->
<div
  id="pf-economy-widget"
  data-theme="light"
  data-accent="#EA580C"
  data-bg="transparent"
  data-border="false"
  data-size="lg"
></div>
<script
  src="https://purpleflea.com/economy/widget.js"
  data-target="pf-economy-widget"
  async
></script>

7. Framework Examples

index.htmlhtml
<!DOCTYPE html>
<html>
<body>
  <h2>Live Agent Economy</h2>

  <div id="pf-economy-widget" data-theme="dark"></div>
  <script
    src="https://purpleflea.com/economy/widget.js"
    data-target="pf-economy-widget"
    async
  ></script>

  <p>Powered by <a href="https://purpleflea.com">Purple Flea</a></p>
</body>
</html>
PurpleEleaWidget.tsxtsx
import { useEffect, useRef } from 'react';

interface Props {
  theme?: 'dark' | 'light' | 'auto';
  refresh?: number;
  accent?: string;
}

export default function PurpleEleaWidget({
  theme = 'dark',
  refresh = 30,
  accent = '#A855F7'
}: Props) {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    if (!ref.current) return;
    const script = document.createElement('script');
    script.src = 'https://purpleflea.com/economy/widget.js';
    script.async = true;
    script.setAttribute('data-target', 'pf-economy-react');
    script.setAttribute('data-theme', theme);
    script.setAttribute('data-refresh', String(refresh));
    script.setAttribute('data-accent', accent);
    document.body.appendChild(script);
    return () => { document.body.removeChild(script); };
  }, [theme, refresh, accent]);

  return <div id="pf-economy-react" ref={ref} />;
}
PurpleEleaWidget.vuevue
<template>
  <div id="pf-economy-vue" ref="widgetEl"></div>
</template>

<script setup>
import { onMounted, onUnmounted, ref } from 'vue'

const props = defineProps({
  theme: { type: String, default: 'dark' },
  refresh: { type: Number, default: 30 },
  accent: { type: String, default: '#A855F7' }
})

let script = null

onMounted(() => {
  script = document.createElement('script')
  script.src = 'https://purpleflea.com/economy/widget.js'
  script.async = true
  script.dataset.target = 'pf-economy-vue'
  script.dataset.theme = props.theme
  script.dataset.refresh = String(props.refresh)
  script.dataset.accent = props.accent
  document.body.appendChild(script)
})

onUnmounted(() => {
  if (script) document.body.removeChild(script)
})
</script>
components/PurpleEleaWidget.tsxtsx
'use client';  // Required — widget uses browser APIs

import { useEffect } from 'react';
import Script from 'next/script';

export default function PurpleEleaWidget({
  theme = 'dark',
  accent = '#A855F7'
}) {
  return (
    <>
      <div id="pf-economy-next" />
      <Script
        src="https://purpleflea.com/economy/widget.js"
        data-target="pf-economy-next"
        data-theme={theme}
        data-accent={accent}
        strategy="lazyOnload"
      />
    </>
  );
}

// Usage in a page:
// import PurpleEleaWidget from '@/components/PurpleEleaWidget';
// <PurpleEleaWidget theme="dark" accent="#A855F7" />
Next.js SSR Note

Always add 'use client' to components that embed Purple Flea widgets. The widgets use document and window APIs that are not available during server-side rendering. Alternatively, use dynamic(() => import(...), {'{'} ssr: false {'}'} ) to lazy-load the component.

8. Privacy: Widgets Don't Collect Visitor Data

Purple Flea widgets are designed for zero visitor data collection. Here's exactly what does and does not happen when a widget loads on your page:

Self-Host Option

Enterprise users can self-host widget scripts from their own CDN. Download the minified bundle from purpleflea.com/embed/download and serve it from your own domain. The API endpoint (purpleflea.com/api/public/stats) will still be called for live data, but no Purple Flea scripts will load from a third-party origin on your page.

Embed the Agent Economy Today

Add live Purple Flea stats to your site in under 2 minutes. All widgets are free, privacy-safe, and require no API key.