SDK — plug TaxVega into your checkout

Two files, zero dependencies: the JS checkout widget for the buyer-facing badge, and the Python client for your backend. Every answer carries the tv1_* digest of the rules snapshot. Fail-closed by design: if the engine is unreachable, you get no numbers — the code never invents a rate.

Downloads (served from this site)

Copy into your project or link directly — the widget is meant to be embedded in one line.

tv-widget.js tv_client.py README.md

JS checkout widget — one line

The script auto-scans data-tv-widget blocks and exposes TaxVega.calculate(). It shows a badge “VAT 19% · Germany · digest tv1_*” and returns the calculation to your JS. The widget never touches money — payment stays on your gateway.

Embed (one line)
<script src="https://your-site.example/sdk/tv-widget.js"
        data-engine="https://engine.example:8797"
        data-key="tv_..." data-lang="en"></script>

<!-- declarative badge anywhere on the page -->
<div data-tv-widget data-country="DE" data-buyer="b2c" data-amount="100"></div>
JS API — calculate() returns the calculation
TaxVega.calculate({amount: 100, country: 'DE', buyer: 'b2c'})
  .then(function (res) {
    // res.rate === 19, res.grossAmount === 119.00,
    // res.digest === 'tv1_bbadb83a17140ff66c1b1f56' — save it with the order
    console.log(res.regime, res.rate, res.taxAmount, res.digest);
  })
  .catch(function (e) {
    // e.code: 'network' | 'http_502' | 'bad_engine_answer' | 'bad_input'
    // fail-closed: no numbers are shown, checkout still works
  });
Live widget on this engine

Python SDK — stdlib only

Copy tv_client.py into your project (Python 3.8+, no pip installs). Retry 3× on network/429/5xx with backoff; 4xx raise immediately.

Install
curl -O https://your-site.example/sdk/tv_client.py
Quick start
from tv_client import TaxVegaClient, TaxVegaError

tv = TaxVegaClient("https://taxvega.makomemory.com", key="tv_your_key")

res = tv.resolve("DE", buyer="b2c", vat_valid=False)
print(res["regime"], res["rate"], res["rule_digest"])

rules = tv.public_rules("RU")          # rules as data + digest
res = tv.chain(participants=[{"id": "p0", "kind": "company", "country": "RU",
                              "role": "seller"},
                             {"id": "p1", "kind": "company", "country": "DE",
                              "role": "buyer"}],
               links=[{"from": "p0", "to": "p1", "type": "goods",
                       "amount": 100000}])

try:
    tv.resolve("DE")
except TaxVegaError as e:
    print(e.code, e.detail)            # fail-closed: no numbers on error

curl — the raw contract

The same endpoints the widget and the SDK call. Key goes in the header, never in the URL.

curl "http://engine.example:8797/v1/resolve?country=DE&buyer=b2c&vat_valid=0"
curl -H "Authorization: Bearer tv_..." \
     "http://engine.example:8797/v1/public/rules?country=RU"
curl -X POST -H "Content-Type: application/json" \
     -H "Authorization: Bearer tv_..." \
     -d '{"participants":[{"id":"p0","kind":"company","country":"RU","role":"seller"},
                          {"id":"p1","kind":"company","country":"DE","role":"buyer"}],
          "links":[{"from":"p0","to":"p1","type":"goods","amount":100000}]}' \
     "http://engine.example:8797/v1/chain"

Errors — fail-closed contract

No engine, no numbers. Every answer carries the digest; on failure you get a code and checkout continues without invented values.

codemeaning
200regime, rate, tv1_* digest
401endpoint needs the key (chain), key missing
402key unknown / demo quota over — sale possible, tax manually
429limit reached — SDK retries 3× with backoff
5xxengine down — SDK retries 3×, then raises; widget shows “unavailable”
Canon: the widget and the SDK compute and prove — they never move money. Payment always goes through your gateway; only calculation events (country, buyer type, amount) go through TaxVega.
TaxVega · beta · free during the test period