MembberSwift is a Swift package for iOS 16+ and macOS 13+, built on Apple's swift-openapi-generator. Every operation is an async/await method with idiomatic Swift names, generated from the platform contract.
Public Swift Package Manager distribution is planned. Today the package ships inside the Membber iOS workspace as a local SPM package, and we provide it directly to teams building with us: get in touch. Once public, it installs like any SPM dependency; the API on this page is the same either way.
URLSession; auth is a middleware that attaches your Bearer token from the tokenProvider closure on every request.import MembberSwift
let client = MembberClient(
serverURL: MembberClient.productionServerURL,
tokenProvider: { session.accessToken }
)
// A typed, authenticated read. .ok.body.json throws if the
// response is anything other than 200.
let state = try await client.api.getLoyaltyState(
query: .init(customerId: "<customer-id>")
).ok.body.jsonlet response = try await client.api.createOrder(
body: .json(.init(/* ... */))
)
switch response {
case .ok(let ok):
let order = try ok.body.json
// success
case .undocumented(let status, let payload):
// The unified error envelope arrives here with its status code.
// Decode { error: { code, message, requestId } } from payload.
print("request failed with status \(status)")
default:
break
}The generated output is an enum per operation: use the .ok shorthand when you only care about success, or switch over the cases to handle the error envelope deliberately. The idempotency and rate limit conventions apply unchanged.
Every operation in the API reference includes a generated Swift example: pick the Swift tab once and the whole reference shows Swift.