Unified API Contract
This specification defines the shared public API across all six Connekt targets — Android (Kotlin), iOS (Swift), Browser / H5 (
@connekt/client/peer), PC TypeScript (@connekt/client), Python (connekt), and Rust (connekt-core). Together with Wire Protocol (CK v1) and PC Control API, it forms the single source of truth for the project.
1. Published SDK Packages
| Target | Package / Artifact | Registry | Role |
|---|---|---|---|
| Android (Kotlin) | dev.mobra.connekt:connekt-sdkdev.mobra.connekt:connekt-sdk-no-op | Maven Central | Peer SDK (+ Release No-Op) |
| iOS / macOS (Swift) | Connekt / ConnektNoOp (https://github.com/K0ST/Connekt.git) | SwiftPM | Peer SDK (+ Release No-Op) |
| Browser / H5 (TS) | @connekt/client/peer (or /sdk/connekt-peer.js) | npm | Peer SDK |
| PC TypeScript / Node | @connekt/client & @connekt/client/sidecar | npm | Control SDK & Sidecar |
| PC Python 3.9+ | connekt | PyPI | Control SDK & Sidecar |
| PC Rust | connekt-core | crates.io | Embedded Hub Core |
| PC Hub Binary | connekt-hub & connekt-hub-headless | GitHub Releases | Standalone Hub / Sidecar |
2. Two SDK Roles & Argument Order
Peer SDKs (
Android,iOS,Browser / H5 @connekt/client/peer)- Target the PC Hub by default (
Target.PC = "pc"/Target.pc). - Argument order puts data first, optional target
tosecond:post(data, to),send(data, to),request(data, to, timeoutMs). Stream opening takesopenStream(to, meta). - Provide both a zero-boilerplate singleton (
Connekt) and multi-instance clients (ConnektClient/ConnektPeer). - Pre-start listener safety: Both iOS and H5 singletons lazily initialize their routing tables so calling
Connekt.channel("x").onMessage(...)beforestart()/connect()never drops callbacks. - Privacy-first LAN default: Android and iOS enable USB by default and keep LAN opt-in (
enableLan = false) so pure USB sessions on iOS never trigger unsolicited Local Network permission prompts. When LAN is enabled,HOT_STANDBYprovides seamless unplug failover.
- Target the PC Hub by default (
Control SDKs (
Rust connekt-core,TypeScript @connekt/client,Python connekt)- Run on the Hub side with no implicit
PCdefault; therefore explicit targettoalways comes first:send(to, data),request(to, data, timeoutMs),openStream(to, meta).
- Run on the Hub side with no implicit
3. Shared Value Types (100% Semantic Parity)
Target:PC = "pc",ALL = "*"(Swift:Target.pc,Target.all).TransportKind:adb (100),usbmux (100),lan (50),custom (25),relay (10).ErrorCode:PEER_OFFLINE,TIMEOUT,NO_HANDLER,HANDLER_ERROR,INVALID_REQUEST,INTERNAL_ERROR,STREAM_REJECTED,STREAM_CANCELLED.Payload: Immutable byte container exposing.bytes,.text,.size,.isEmpty, JSON helpers,Payload.of(...), andPayload.EMPTY.PeerInfo:platformis"android" | "ios" | "web";active_transportis"adb" | "usbmux" | "lan" | "relay".Subscription: Idempotentcancel().
4. Cross-Platform API Comparison Matrix
| Operation | Android (Kotlin) | iOS (Swift) | H5 Peer (@connekt/client/peer) | PC Control (@connekt/client) | Python (connekt) | Rust (connekt-core) |
|---|---|---|---|---|---|---|
| Start / Connect | Connekt.init(ctx) | Connekt.start() | await Connekt.connect() | await ConnektClient.connect() | with ConnektClient() as c: | ConnektHub::builder().start().await |
| Channel handle | Connekt.channel("x") | Connekt.channel("x") | Connekt.channel("x") | c.channel("x") | c.channel("x") | hub.channel("x") |
| Non-blocking send | ch.post("hi") | ch.post("hi") | ch.post("hi") | (use send) | (use send) | (use send) |
| Reliable send | ch.send("hi", to) | try await ch.send("hi", to:) | await ch.send("hi", to) | await ch.send(to, "hi") | ch.send(to, "hi") | ch.send(to, b"hi").await |
| Request / Response | ch.request("q", to) | try await ch.request("q", to:) | await ch.request("q", to) | await ch.request(to, "q") | ch.request(to, "q") | ch.request(to, b"q", t).await |
| Receive messages | ch.onMessage { } | ch.onMessage { } | ch.onMessage(() => {}) | ch.onMessage(() => {}) | ch.on_message(fn) | ch.on_message(fn).await |
| Handle requests | ch.onRequest { } | ch.onRequest { } | ch.onRequest(() => ...) | ch.onRequest(() => ...) | ch.on_request(fn) | ch.on_request(fn).await |
| Open stream | ch.openStream(to, m) | try await ch.openStream(to:, meta:) | ch.openStream(to, m) | ch.openStream(to, m) | ch.open_stream(to, m) | ch.open_stream(to, m).await |
| Receive stream | ch.onStream { } | ch.onStream { } | ch.onStream(async s => {}) | ch.onStream(async s => {}) | ch.on_stream(fn) | ch.on_stream(fn).await |
| Stop / Close | Connekt.stop() | Connekt.stop() | Connekt.disconnect() | c.close() | c.close() | hub.shutdown() |