Skip to content

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 ​

TargetPackage / ArtifactRegistryRole
Android (Kotlin)dev.mobra.connekt:connekt-sdk
dev.mobra.connekt:connekt-sdk-no-op
Maven CentralPeer SDK (+ Release No-Op)
iOS / macOS (Swift)Connekt / ConnektNoOp (https://github.com/K0ST/Connekt.git)SwiftPMPeer SDK (+ Release No-Op)
Browser / H5 (TS)@connekt/client/peer (or /sdk/connekt-peer.js)npmPeer SDK
PC TypeScript / Node@connekt/client & @connekt/client/sidecarnpmControl SDK & Sidecar
PC Python 3.9+connektPyPIControl SDK & Sidecar
PC Rustconnekt-corecrates.ioEmbedded Hub Core
PC Hub Binaryconnekt-hub & connekt-hub-headlessGitHub ReleasesStandalone Hub / Sidecar

2. Two SDK Roles & Argument Order ​

  1. 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 to second: post(data, to), send(data, to), request(data, to, timeoutMs). Stream opening takes openStream(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(...) before start() / 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_STANDBY provides seamless unplug failover.
  2. Control SDKs (Rust connekt-core, TypeScript @connekt/client, Python connekt)

    • Run on the Hub side with no implicit PC default; therefore explicit target to always comes first: send(to, data), request(to, data, timeoutMs), openStream(to, meta).

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(...), and Payload.EMPTY.
  • PeerInfo: platform is "android" | "ios" | "web"; active_transport is "adb" | "usbmux" | "lan" | "relay".
  • Subscription: Idempotent cancel().

4. Cross-Platform API Comparison Matrix ​

OperationAndroid (Kotlin)iOS (Swift)H5 Peer (@connekt/client/peer)PC Control (@connekt/client)Python (connekt)Rust (connekt-core)
Start / ConnectConnekt.init(ctx)Connekt.start()await Connekt.connect()await ConnektClient.connect()with ConnektClient() as c:ConnektHub::builder().start().await
Channel handleConnekt.channel("x")Connekt.channel("x")Connekt.channel("x")c.channel("x")c.channel("x")hub.channel("x")
Non-blocking sendch.post("hi")ch.post("hi")ch.post("hi")(use send)(use send)(use send)
Reliable sendch.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 / Responsech.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 messagesch.onMessage { }ch.onMessage { }ch.onMessage(() => {})ch.onMessage(() => {})ch.on_message(fn)ch.on_message(fn).await
Handle requestsch.onRequest { }ch.onRequest { }ch.onRequest(() => ...)ch.onRequest(() => ...)ch.on_request(fn)ch.on_request(fn).await
Open streamch.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 streamch.onStream { }ch.onStream { }ch.onStream(async s => {})ch.onStream(async s => {})ch.on_stream(fn)ch.on_stream(fn).await
Stop / CloseConnekt.stop()Connekt.stop()Connekt.disconnect()c.close()c.close()hub.shutdown()

Released under the MIT License.