Swift SDK
Install and use the Misar.IO Swift SDK
Installation
Add to Package.swift:
dependencies: [
.package(url: "https://github.com/misarai/misario-swift.git", from: "1.0.0"),
],
targets: [
.target(name: "MyApp", dependencies: [
.product(name: "MisarIO", package: "misario-swift"),
]),
]
Quick Start
import MisarIO
let client = MisarIOClient(apiKey: ProcessInfo.processInfo.environment["MISARIO_API_KEY"]!)
let profile = try await client.account.get()
print("Hello, \(profile.displayName)!")
Available Methods
| Method | Description |
|--------|-------------|
| client.account.get() | Get the current account profile |
| client.account.update(_ request:) | Update account details |
| client.sessions.list() | List active sessions |
| client.sessions.revoke(_ id:) | Revoke a session |
| client.keys.list() | List API keys |
| client.keys.create(_ request:) | Create an API key |
| client.keys.revoke(_ id:) | Revoke an API key |
| client.sso.token(_ request:) | Generate a cross-TLD SSO token |
Error Handling
import MisarIO
do {
let profile = try await client.account.get()
print("Hello, \(profile.displayName)!")
} catch let error as MisarIOAPIError {
print("API error \(error.statusCode): \(error.message)")
} catch {
print("Error: \(error.localizedDescription)")
}