selectwin (Python)
Official Selectwin Python SDK — payments (credit card, PIX, boleto), subscriptions, wallets, webhooks and more. Sync and async, fully typed.
Status: early / work in progress (
0.1.0). Generated core (openapi-python-client, httpx sync+async) + a hand-written DX shell (typed errors, retries, idempotency, pagination, webhook verification).
pip install selectwin
Quickstart
import os
from selectwin import Selectwin, CardError
sw = Selectwin(api_key=os.environ["SELECTWIN_API_KEY"]) # sk_test_… / sk_live_…
# Create a PIX transaction (amounts in cents)
tx = sw.transactions.create({"amount": 9990, "payment": {"method": "pix", "currency": "BRL"}})
# id / id+body aliases
one = sw.transactions.retrieve("tra_…")
sw.subscriptions.pause("subs_…")
# Typed errors — branch on the class / error.code, never the message
try:
sw.transactions.create({...})
except CardError as e:
print(e.display_message, e.reversible) # buyer-facing + retryable
Async
import asyncio
from selectwin import AsyncSelectwin
async def main():
async with AsyncSelectwin(api_key="sk_test_…") as sw:
tx = await sw.transactions.create({"amount": 9990, "payment": {"method": "pix", "currency": "BRL"}})
async for t in sw.transactions.list(limit=100):
...
asyncio.run(main())
Pagination
Top-level list() methods return a pager that is both a page fetcher and an iterator:
# sync — stream every transaction across all pages
for tx in sw.transactions.list(limit=100):
...
first_page = sw.transactions.list(limit=20).first() # a page object (.data, .has_more, …)
some = sw.customers.list().to_list(max=500) # collect, optionally capped
# async
async for tx in sw.transactions.list(limit=100):
...
The full generated API (every operation_id) is always reachable via .raw:
from selectwin._core.api.transactions import create_transaction
# or the bound escape hatch:
sw.transactions.raw # the generated module for this resource
Webhooks
# raw_body MUST be the exact bytes/str received (do not re-serialize)
event = sw.webhooks.construct_event(
raw_body,
request.headers["x-selectwin-signature"],
os.environ["SELECTWIN_WEBHOOK_SECRET"], # whsec_…
)
if event.type == "transaction.approved":
obj = event.payload.object
WEBHOOK_EVENT_TYPES (the authoritative catalog) and is_webhook_event_type() are
exported for validation; WebhookEventType is a typing.Literal of every event type.
What the SDK adds over the raw generated client
The package is a generated core (openapi-python-client, from the OpenAPI v2.0.0 spec) + a hand-written DX shell:
- Typed clients —
Selectwin(api_key=…)(sync) andAsyncSelectwin(api_key=…)(async context manager) exposingsw.transactions,sw.subscriptions,sw.customers, … - Concise aliases per resource (
create/retrieve/update/list/delete+ custom verbs), accepting a dict or the generated body model;.rawexposes the full generated surface. - Typed errors by HTTP status /
error.code:CardError(402,display_message/reversible),ValidationError(params),RateLimitError(retry_after),AuthenticationError,PermissionDeniedError,NotFoundError,ConflictError,APIError,APIConnectionError. - Auto-retries (429/5xx/network) with exponential backoff, honouring
Retry-After. - Idempotency — an
X-Idempotency-Keyis added to every mutation (override per call). - Safe paths — a path parameter of
.or..is refused before the request is built (it would reach another endpoint); redirects are not followed. - Timeouts and one shared, pre-authenticated
httpxclient per SDK client. - Auto-pagination — sync (
for …) and async (async for …) iterators,.first(),.to_list(max=…),.pages(). - Webhook verification —
construct_event(HMAC-SHA256 of the raw body, constant-time).
Auth is the SelectKey header; the environment (sandbox/production) is resolved from the
key prefix (sk_test_ / sk_live_).
Architecture
src/selectwin/
_core/ # openapi-python-client output — DO NOT edit; synced from selectwin-sdks
resources.py # GENERATED resource namespaces (sync + async) — DO NOT edit
webhook_events.py # GENERATED webhook Event Catalog (types + guard) — DO NOT edit
errors.py # typed error hierarchy
http.py # httpx transport (retries/timeout) + hooks (idempotency, UA) + error mapping
pagination.py # SyncPager / AsyncPager
webhooks.py # construct_event (signature verification)
client.py # Selectwin / AsyncSelectwin — wire auth + the custom httpx client
Cross-cutting concerns are injected once into the httpx client shared by the generated core, so every endpoint inherits them and new endpoints work automatically on regen.
Development
pip install -e ".[dev]"
python scripts/sync_core.py # copy the generated core from selectwin-sdks + regen
python scripts/gen_resources.py # regenerate src/selectwin/resources.py
python scripts/gen_webhook_events.py # regenerate src/selectwin/webhook_events.py
pytest # unit suite
pytest -m integration # sandbox suite (needs SELECTWIN_SANDBOX_KEY; see tests/integration)
mypy src/selectwin # type-check the DX shell
Roadmap
- Publish to PyPI (Trusted Publishing / OIDC) once the API stabilises; CI on PRs.
Metadata
Release files for selectwin 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| selectwin-0.1.3.tar.gz | 396.2 kB | With provenance | Details for selectwin-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| selectwin-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for selectwin-0.1.3-py3-none-any.whl |
Total release size: 1.6 MB
Release files / selectwin-0.1.3.tar.gz
| Download URL | selectwin-0.1.3.tar.gz |
|---|---|
| Size | 396.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd10bf1cc75cf5a5641c4ea4f20af294c8dc360d19cc35d188e08651e5deb3cb
|
|
BLAKE2b-256 checksum How to use checksums |
1d92de13953d04c9b05ee7d2cf15d2eaf7956afd1c9bd656c9e57ebdac0e513d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logRelease files / selectwin-0.1.3-py3-none-any.whl
| Download URL | selectwin-0.1.3-py3-none-any.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f93be860b561a8fc8147c8a9ba56e9e37230f495c128f32be028c49750f1104
|
|
BLAKE2b-256 checksum How to use checksums |
fc3c24b39f71d73c238c52d56ad2af878b6fdf97974c22bda488b44931a01787
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logSecurity for selectwin 0.1.3
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for selectwin-0.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.
Transparency logA 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.