DOGE Price Widget

A cached, embeddable price + conversion widget for any site.

Beginner An evening PHP (any shared host)vanilla JSCoinGecko free API

A tiny server-side proxy that caches CoinGecko's free API (so a thousand visitors cost you one upstream call) and a self-contained JS widget showing the DOGE price and a two-way USD converter. Utility, not a ticker for speculation - and it runs on any shared PHP host.

What you'll have when it works

  • price.php proxy: fetches CoinGecko, caches JSON to disk for 5 minutes, serves it with CORS headers
  • widget.js: renders current price + a USD ⇄ DOGE converter, refreshes every 5 minutes
  • A copy-paste embed snippet: one script tag + one div

The prompt

Paste this into Claude Code in an empty project folder. It's a full spec, not a wish – the constraints in it (integer koinu, idempotent crediting, testnet asserts) are the difference between a demo and something trustworthy. Read what comes back before you run it.

claude-code prompt · price-widget
Build an embeddable Dogecoin price widget with a PHP caching proxy. It must run on ordinary shared PHP hosting (PHP 8.x, no composer, no database) and make very few upstream API calls. Read the whole spec first.

PART 1 - price.php (the proxy)
- Fetches https://api.coingecko.com/api/v3/simple/price?ids=dogecoin&vs_currencies=usd&include_24hr_change=true using file_get_contents with a stream context (10s timeout, a descriptive User-Agent).
- Caches the raw JSON to a file (doge-price-cache.json next to the script) and serves from cache when it is younger than 300 seconds. If the upstream call fails but a stale cache exists, serve the stale cache with "stale": true added. Never let visitors trigger unlimited upstream calls.
- Responds with Content-Type: application/json and Access-Control-Allow-Origin: * so other sites can embed the widget. Include fetched_at (unix time) in the response.
- Write the cache atomically (write temp file then rename) so concurrent requests never read a half-written file.

PART 2 - widget.js
- Self-contained IIFE, no dependencies, no external CSS. Site owners embed:
  <div id="doge-price"></div><script src="widget.js" data-api="https://example.com/price.php"></script>
  (read the API URL from the script tag's data-api, with a sensible default of same-origin price.php).
- Renders into #doge-price: the DOGE/USD price (4 decimals), the 24h change with a subtle up/down arrow (muted green/red, nothing flashy), "data by CoinGecko" attribution (required by their free tier), and a two-way converter: a USD input and a DOGE input that update each other live.
- Fetches once on load and every 5 minutes; if the fetch fails, keep showing the last numbers with a small "as of HH:MM" note. Inline all styles via a <style> tag the script injects, scoped under #doge-price. Look: clean card, dark-friendly, one gold accent (#E8B93B).

PART 3 - demo.html showing the embed exactly as a site owner would paste it.

Tone constraint: this is a utility widget. No rocket emojis, no "to the moon", no buy prompts.
Deliverables: price.php, widget.js, demo.html, README with embed instructions and the cache behavior explained.

The walkthrough

  1. Paste the prompt into Claude Code; upload the three files to any PHP host (or php -S localhost:8080 to test).
  2. Open demo.html and confirm price + converter render.
  3. Reload rapidly and check doge-price-cache.json's timestamp: one upstream call per 5 minutes, no matter the traffic.
  4. Embed the snippet on a second site to prove the CORS story.

Before this touches real DOGE

  • Keep the 5-minute cache (or longer) - it's what keeps you inside CoinGecko's free tier at any traffic level.
  • Keep the attribution: it's required by CoinGecko's terms for free API use.
  • Resist turning it into a trading ticker; utility widgets age better and communities respect them.

The lessons behind this kit: How Dogecoin actually works

On the map

Built something on Dogecoin? Put it on the map.

The directory is the page people link when someone says Dogecoin has no developers. If you maintain a library, wallet, tool, or app – even a small one – it belongs here.