Skip to content
fluxerappPublic

About

Fluxer Swift SDK (OpenAPI-generated via apple/swift-openapi-generator)

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Fluxer graphic logo

Donate Documentation AGPLv3 License

Fluxer Swift SDK

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.

Requirements

Installation

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"),

Getting started

import Fluxer

let fluxer = FluxerClient(
    authorizationHeaderValue: FluxerClient.bearerAuthorization(token: sessionToken)
)

let response = try await fluxer.client.getCurrentUser()
let user = try response.ok.body.json

Self-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).

Authentication

Pass the full Authorization header value. The SDK does not manage auth state.

FluxerClient.bearerAuthorization(token: sessionToken) // user session
FluxerClient.botAuthorization(token: botToken)          // bot

You can also construct FluxerClient without authorizationHeaderValue and add your own ClientMiddleware.

Generated API

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.

Gateway (WebSocket)

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()

License

AGPL-3.0 — see LICENSE.

About

Fluxer Swift SDK (OpenAPI-generated via apple/swift-openapi-generator)

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages