SDKs
Python (REST Examples)
Using the Bag API with Python's requests library.
Python (REST Examples)
This page is under construction. Check back soon, or reach out to us if you need help with this topic now.
Bag doesn't have an official Python SDK yet. In the meantime, you can use the REST API directly with the requests library. Every endpoint works the same way — Bearer auth, JSON bodies, JSON responses.
For working Python examples, see the Quickstart and Build a Custom Checkout guides, which include Python tabs for every code sample.
import os
import requests
API_KEY = os.environ["BAG_API_KEY"]
BASE_URL = "https://justusebag.xyz"
response = requests.get(
f"{BASE_URL}/api/payment-links",
headers={"Authorization": f"Bearer {API_KEY}"},
)
links = response.json()["data"]
for link in links:
print(f"{link['name']}: ${link['amount']}")