Skip to main content

commerceforai (Python)

Products, inventory, Stripe checkout, orders, shipping, returns, subscriptions and gift cards, on the merchant's own Stripe account. No dependencies.

pip install commerceforai
from commerceforai import Commerce, CommerceError, create_test_store

store = create_test_store("My shop")     # a free test store, no sign-up; keep store["api_key"]
commerce = Commerce(store["api_key"])    # or Commerce() with COMMERCEFORAI_API_KEY set

product = commerce.products.create(name="Trail Tee", price=3600, inventory=25)
variant = product["variants"][0]["id"]

checkout = commerce.checkouts.create(items=[{"variant_id": variant, "quantity": 1}], success_url="https://example.com/thanks")
print(checkout["url"])                   # send the customer here

# Test stores can run the whole purchase without a browser:
order = commerce.store.simulate_order(items=[{"variant_id": variant, "quantity": 1}])["order"]
commerce.orders.fulfill(order["id"], carrier="USPS", tracking_number="9400100000000000000000")

try:
    commerce.orders.refund(order["id"], amount=500)
except CommerceError as e:
    print(e.type, e.message)             # e.g. permission_error when the key has a refund cap

Responses are plain dicts and lists. Money is an integer in cents. Errors raise CommerceError with type, message and extra fields such as param or available.

Resources: products, variants, inventory, checkouts, orders, returns, collections, discounts, customers, draft_orders, gift_cards, subscriptions, store, events, webhooks, reports. Anything else: commerce.request("GET", "/v1/...") (OpenAPI).

Webhooks (Flask example):

from commerceforai import verify_webhook

event = verify_webhook(request.get_data(), request.headers, os.environ["COMMERCEFORAI_WEBHOOK_SECRET"])
if event["type"] == "order.paid": ...

Docs: https://commerceforai.com/docs · Agent guide: https://commerceforai.com/llms.txt · MIT licensed.

Metadata

Release files for commerceforai 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for commerceforai 0.1.0
File Size Uploaded Provenance Actions
commerceforai-0.1.0.tar.gz 7.0 kB Without provenance Details for commerceforai-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for commerceforai 0.1.0
File Interpreter ABI Platform Actions
commerceforai-0.1.0-py3-none-any.whl Python 3 none any Details for commerceforai-0.1.0-py3-none-any.whl

Total release size: 14.2 kB

Release files / commerceforai-0.1.0.tar.gz

Download URL commerceforai-0.1.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e31caff54826150054f64bce2a178012b73721ed0b2e126b25560f668bd0abd8
BLAKE2b-256 checksum
How to use checksums
c3b4723e7c019a6126cbb5f0c3d58c4861738fb3c17961e772ca896632b23cd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / commerceforai-0.1.0-py3-none-any.whl

Download URL commerceforai-0.1.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d5153407730a1ab5606f4d281c01b7cf342709adc0660db94c626244b7962fdb
BLAKE2b-256 checksum
How to use checksums
4173c0b6d39dd09b147004540c5c7a2c5ed1a7b21a2fa7cd34cc79dc7225eeb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for commerceforai 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page