REST API에서 임베드 가능한 계산기 위젯 만들기: ReceiptEdit이 판매세를 iframe으로 배송하는 방법

작성자

카테고리:

← 피드로
DEV Community · Ishwar Sirvi · 2026-07-26 개발(SW)

Ishwar Sirvi

Continuing the open sales-tax dataset thread — the useful trick I did not think would matter as much as it did: shipping the data as an embeddable iframe widget, not just a REST API.

The API alone is at receiptedit.com/api/sales-tax — clean JSON, no auth, CORS. But an API needs a developer to consume it. A widget just needs someone to paste an iframe:

<iframe
  src="https://receiptedit.com/api/embed/sales-tax/california"
  width="380" height="540"
  style="border:0;max-width:100%"
  loading="lazy"
  title="California Sales Tax Calculator">
</iframe>

Enter fullscreen mode Exit fullscreen mode

Swap california for any state slug in our 50-state directory and you get the exact same calculator, live, on their page.

Why an iframe wins over a JS SDK

  1. Zero JS on their side. No npm install, no webpack, no CSP conflicts. Blogs on Medium, WordPress, Ghost all accept iframes.
  2. Style isolation. Their CSS cannot break my calculator; my CSS cannot break their page. Same-origin cookies stay separate.
  3. Instant updates. When 2027 rates change I re-render the embed on my server; every embedder gets the new data with zero action.
  4. Server-side render. First byte is HTML; renders before their JS even starts. No layout shift.

The endpoint shape

GET /api/sales-tax/:state
→ { state, code, state_sales_tax_pct, avg_combined_sales_tax_pct, grocery_taxed, lodging_taxes[...] }

GET /api/embed/sales-tax/:state
→ text/html with calculator + inline styles + a small vanilla-JS calc handler

Enter fullscreen mode Exit fullscreen mode

Both endpoints hit the same underlying dataset: github.com/receiptedit/us-sales-tax-2026 (MIT, ~29 KB JSON for all 50 states).

What I would do differently

Add a ?theme=dark and ?anchor=<affiliate-id> query. And ship a per-city variant, not just per-state.

Try it

API: https://receiptedit.com/api/sales-tax
Embed: https://receiptedit.com/api/embed/sales-tax/california
Source: https://github.com/receiptedit/us-sales-tax-2026
Product: https://receiptedit.com

Happy to answer questions on the widget architecture — it is genuinely simpler than it looks.

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다