Libraries & SDKs

Official libraries for Python and Node, and how to call the API over plain HTTPS.

Not live yet — api.baynoy.com does not resolve, so the examples below will not run today. They describe the contract we are building to, and the shapes on this page may still change.

Official libraries

Python: pip install baynoy (Python 3.9+, requests only), on PyPI. Node: npm install @baynoy/sdk (Node 18+, ESM and CommonJS, no dependencies), on npm. Both sign money-moving requests when given the key's id and signing secret, put an Idempotency-Key on every POST and reuse it on retries, refuse float amounts before sending, raise typed errors carrying code and requestId, and verify webhooks with webhooks.constructEvent.

Node SDK
// npm install @baynoy/sdk
import { Baynoy } from "@baynoy/sdk";

const baynoy = new Baynoy(process.env.BAYNOY_SECRET_KEY, {
  keyId: process.env.BAYNOY_KEY_ID,                 // signs money-moving requests
  signingSecret: process.env.BAYNOY_SIGNING_SECRET,
});
// amounts are strings of integer minor units — a float is refused before sending
const { slug } = await baynoy.paymentLinks.create({ title: "Design retainer", amountMinor: "4900", assetKey: "fiat:EUR" });
console.log(`https://baynoy.com/pay/${slug}`);
Python SDK
# pip install baynoy
import os, baynoy

client = baynoy.Baynoy(
    os.environ["BAYNOY_SECRET_KEY"],
    key_id=os.environ["BAYNOY_KEY_ID"],                 # signs money-moving requests
    signing_secret=os.environ["BAYNOY_SIGNING_SECRET"],
)
link = client.payment_links.create(title="Design retainer", amount_minor="4900", asset_key="fiat:EUR")
print("https://baynoy.com/pay/" + link["slug"])

Calling without an SDK

Plain HTTPS does everything the libraries do: Bearer authentication, JSON bodies, an Idempotency-Key on money-moving POSTs, and a Baynoy-Signature on the ones that require it. The same call in three shapes.

cURL
curl https://api.baynoy.com/v1/catalog/links \
  -H "Authorization: Bearer bk_test_..." \
  -H "Content-Type: application/json" \
  -d '{"title": "Design retainer", "amountMinor": "4900", "assetKey": "fiat:EUR"}'

# -> {"id": "lnk_...", "slug": "k3x9q2"}  — the page is https://baynoy.com/pay/k3x9q2
Node
// Node 18+, no package needed
const res = await fetch("https://api.baynoy.com/v1/catalog/links", {
  method: "POST",
  headers: {
    authorization: `Bearer ${process.env.BAYNOY_SECRET_KEY}`,
    "content-type": "application/json",
  },
  // amounts are strings of integer minor units — never floats
  body: JSON.stringify({ title: "Design retainer", amountMinor: "4900", assetKey: "fiat:EUR" }),
});
const { slug } = await res.json();
console.log(`https://baynoy.com/pay/${slug}`);
Python
import os, requests

r = requests.post(
    "https://api.baynoy.com/v1/catalog/links",
    headers={"Authorization": f"Bearer {os.environ['BAYNOY_SECRET_KEY']}"},
    json={"title": "Design retainer", "amountMinor": "4900", "assetKey": "fiat:EUR"},
)
print("https://baynoy.com/pay/" + r.json()["slug"])