Swift package for the Fluxer HTTP API. API types and the HTTP client are generated at build time from the Fluxer OpenAPI document using Swift OpenAPI Generator.
- Swift 6.0+
- macOS 13+, iOS 13+, or other supported platforms
Add the package dependency in Package.swift:
dependencies: [
.package(url: "https://github.com/fluxerapp/swift_sdk.git", from: "0.1.0"),
],
targets: [
.target(
name: "MyApp",
dependencies: [
.product(name: "Fluxer", package: "swift_sdk"),
]
),
]For local development, use a path dependency:
.package(path: "/path/to/swift_sdk"),import Fluxer
let fluxer = FluxerClient(
authorizationHeaderValue: FluxerClient.bearerAuthorization(token: sessionToken)
)
let response = try await fluxer.client.getCurrentUser()
let user = try response.ok.body.jsonSelf-hosted instances:
let fluxer = FluxerClient(
serverURL: URL(string: "https://api.your-domain.com/v1")!,
authorizationHeaderValue: FluxerClient.botAuthorization(token: botToken)
)The default base URL is https://fluxer.com/api/v1 (include the /v1 prefix).
Pass the full Authorization header value. The SDK does not manage auth state.
FluxerClient.bearerAuthorization(token: sessionToken) // user session
FluxerClient.botAuthorization(token: botToken) // botYou can also construct FluxerClient without authorizationHeaderValue and add your own ClientMiddleware.
FluxerClient.client is the generated Client type. It exposes one async method per OpenAPI operation (for example getCurrentUser(), listGuilds()). Request and response models live under Components.Schemas in the Fluxer module.
GatewayConnection connects to the Fluxer gateway with zstd-stream compression, heartbeat/resume, and typed dispatch events (Components.Schemas models via EventParser).
import Fluxer
let fluxer = FluxerClient(authorizationHeaderValue: FluxerClient.bearerAuthorization(token: token))
let gateway = GatewayConnection(token: token, fluxer: fluxer)
Task {
for try await event in gateway.events() {
// handle GatewayEvent
}
}
await gateway.connect()AGPL-3.0 — see LICENSE.
