SwiftAuth SDKs
Official client libraries for every major language. Full API coverage, WebSocket support, and type safety out of the box.
Python
v1.0.0 · Python 3.9+Synchronous + async support. Zero config WebSocket client with auto-reconnect.
Node.js
v1.0.0 · Node 18+Promise-based API with built-in event emitter for WebSocket and real-time features.
C# / .NET
v1.0.0 · .NET 8+Fully async with native WebSocket support. Works with WPF, WinForms, and console apps.
C++
v1.0.0 · C++17Header-friendly library using libcurl. Ideal for game cheats, desktop tools, and native apps.
Go
v0.1.0 · Go 1.21+Idiomatic Go client with goroutine-safe WebSocket and full file decryption support.
Rust
v0.1.0 · Rust 2021Synchronous Rust client built on reqwest::blocking. Full type safety with serde and file decryption.
Java
v1.0.0 · Java 17+Modern Java client using HttpClient and built-in WebSocket. Zero external dependencies.
Kotlin
v1.0.0 · Kotlin 1.9+Idiomatic Kotlin with lambdas, data classes, and null safety. JVM 17+ compatible.
Ruby
v1.0.0 · Ruby 3.0+Clean Ruby API with keyword arguments, Struct-based models, and file decryption.
PHP
v1.0.0 · PHP 8.1+Type-safe PHP client with Composer support. Full file decryption and GMP-based crypto.
Swift
v1.0.0 · Swift 5.9+Native Swift client using CryptoKit and Foundation. SPM package for macOS and iOS.
Lua
v1.0.0 · Lua 5.1+Lightweight Lua client using LuaSocket and lua-cjson. Great for game scripting.
Python
The Python SDK supports Python 3.9+ with both synchronous and async/await patterns.
Installation
Or install from source:
Quick Start
from swiftauth import SwiftAuthClient client = SwiftAuthClient("https://api.swiftauth.net", "YOUR_SECRET", "1.0.0") client.init() client.login("user", "pass") print(f"Welcome {client.user.key}, level {client.user.level}") # Variables config = client.get_variable("app_config") # Real-time WebSocket client.on("chat", lambda evt: print(f"Chat: {evt}")) client.connect_ws() # Clean up client.end_session()
Node.js
The Node.js SDK supports Node 18+ with ESM and CommonJS modules.
Installation
Quick Start
const { SwiftAuthClient } = require("swiftauth-sdk"); const client = new SwiftAuthClient({ baseUrl: "https://api.swiftauth.net", appSecret: "YOUR_SECRET", appVersion: "1.0.0", }); await client.init(); await client.login("user", "pass"); console.log(`Welcome ${client.user.key}, level ${client.user.level}`); // Real-time WebSocket client.on("ws:chat", (data) => console.log("Chat:", data)); client.connectWs(); // Clean up await client.endSession();
C# / .NET
The C# SDK requires .NET 8+ and provides a fully async API.
Installation
Quick Start
using SwiftAuth; var client = new SwiftAuthClient("https://api.swiftauth.net", "YOUR_SECRET", "1.0.0"); await client.InitAsync(); await client.LoginAsync("user", "pass"); Console.WriteLine($"Welcome {client.CurrentUser.Key}, level {client.CurrentUser.Level}"); // Real-time WebSocket client.OnChat += evt => Console.WriteLine($"Chat: {evt.Data}"); await client.ConnectWebSocketAsync(); // Clean up await client.EndSessionAsync();
C++
The C++ SDK requires C++17 and CMake 3.16+. Uses libcurl for HTTP.
Installation (CMake)
target_link_libraries(your_app PRIVATE swiftauth)
Quick Start
#include "swiftauth/swiftauth.hpp" int main() { swiftauth::Client client("https://api.swiftauth.net", "YOUR_SECRET", "1.0.0"); auto init = client.init(); auto login = client.login("user", "pass"); std::cout << "Welcome " << client.user().key << ", level " << client.user().level << "\n"; // Clean up client.end_session(); return 0; }
Go
The Go SDK provides an idiomatic Go client with goroutine-safe WebSocket handling and full file decryption. Requires Go 1.21+.
Installation
Quick Start
package main import ( "fmt" "log" swiftauth "github.com/SwiftAuth/SwiftSDK/go" ) func main() { client := swiftauth.NewClient("https://api.swiftauth.net", "YOUR_SECRET", "1.0.0", "") // Initialize session _, err := client.Init() if err != nil { log.Fatal(err) } // Authenticate _, err = client.Login("user", "pass", "", "") if err != nil { log.Fatal(err) } fmt.Printf("Welcome %s, level %d\n", client.User.Key, client.User.Level) // Get variables v, _ := client.GetVariable("app_config") fmt.Println("Config:", v.Value) // WebSocket client.On("chat", func(evt map[string]any) { fmt.Println("Chat:", evt) }) client.ConnectWs() // Heartbeat client.Heartbeat() // Clean up defer client.EndSession() }
Error Handling
import "errors" _, err := client.Login("user", "wrong_pass", "", "") if err != nil { var apiErr *swiftauth.SwiftAuthError if errors.As(err, &apiErr) { fmt.Printf("API error [%s]: %s\n", apiErr.Code, apiErr.Message) // API error [UNAUTHORIZED]: Invalid credentials } }
Rust
The Rust SDK uses synchronous reqwest::blocking with full file decryption support. Requires Rust 2021 edition.
Installation
Or add to Cargo.toml:
swiftauth = "0.1"
Quick Start
use swiftauth::SwiftAuthClient; fn main() -> Result<(), Box<dyn std::error::Error>> { let mut client = SwiftAuthClient::new( "https://api.swiftauth.net", "YOUR_SECRET", "1.0.0", None, ); // Initialize session client.init()?; // Authenticate client.login("user", "pass", "", "")?; let user = client.user.as_ref().unwrap(); println!("Welcome {}, level {}", user.key, user.level); // Get variables let config = client.get_variable("app_config")?; println!("Config: {} = {}", config.key, config.value); // License-scoped variables let max_seats = client.get_license_variable("max_seats")?; println!("Max seats: {}", max_seats.value); // User-scoped variables client.set_user_variable("theme", "dark")?; let theme = client.get_user_variable("theme")?; println!("Theme: {}", theme.value); // Heartbeat client.heartbeat()?; // Clean up client.end_session()?; Ok(()) }
Error Handling
use swiftauth::{SwiftAuthClient, SwiftAuthError}; match client.login("user", "wrong_pass", "", "") { Ok(_) => { let user = client.user.as_ref().unwrap(); println!("Logged in as {}", user.key); } Err(e) => { eprintln!("API error [{}]: {}", e.code, e.message); } }
Java
The Java SDK uses the modern java.net.http.HttpClient (Java 17+). Compatible with Maven and Gradle.
Installation (Maven)
Installation (Gradle)
Quick Start
import net.swiftauth.SwiftAuthClient; public class Main { public static void main(String[] args) throws Exception { var client = new SwiftAuthClient("https://api.swiftauth.net", "YOUR_SECRET", "1.0.0"); // Initialize session client.init(); // Authenticate client.login("user", "pass"); System.out.println("Welcome " + client.getUser().key() + ", level " + client.getUser().level()); // Get variables var config = client.getVariable("app_config"); System.out.println("Config: " + config.get("value")); // WebSocket client.on("chat", evt -> System.out.println("Chat: " + evt) ); client.connectWs(); // Heartbeat client.heartbeat(); // Clean up client.endSession(); } }
Error Handling
import net.swiftauth.SwiftAuthException; try { client.login("user", "wrong_pass"); } catch (SwiftAuthException e) { System.err.println("API error [" + e.getCode() + "]: " + e.getMessage()); // API error [UNAUTHORIZED]: Invalid credentials }
Kotlin
The Kotlin SDK runs on JVM 17+ and provides idiomatic Kotlin with data classes, lambdas, and null safety.
Installation (Gradle)
Quick Start
import net.swiftauth.SwiftAuthClient fun main() { val client = SwiftAuthClient("https://api.swiftauth.net", "YOUR_SECRET", "1.0.0") // Initialize session client.init() // Authenticate client.login("user", "pass") println("Welcome ${client.user!!.key}, level ${client.user!!.level}") // Variables val vars = client.getAllVariables() // WebSocket client.on("chat") { evt -> println("Chat: $evt") } client.connectWs() // Clean up client.endSession() }
Ruby
The Ruby SDK supports Ruby 3.0+ using only stdlib (net/http, openssl, json). No external gems required.
Installation
Quick Start
require "swiftauth" client = SwiftAuth::Client.new( base_url: "https://api.swiftauth.net", app_secret: "YOUR_SECRET", app_version: "1.0.0", ) # Initialize session client.init # Authenticate client.login("user", "pass") puts "Welcome #{client.user.key}, level #{client.user.level}" # Variables vars = client.get_all_variables vars.each { |v| puts "#{v.key} = #{v.value}" } # License variables max_seats = client.get_license_variable("max_seats") puts "Max seats: #{max_seats.value}" # User variables client.set_user_variable("theme", "dark") # Clean up client.end_session
PHP
The PHP SDK requires PHP 8.1+ with openssl, json, gmp, and zlib extensions.
Installation (Composer)
Quick Start
use SwiftAuth\SwiftAuthClient; $client = new SwiftAuthClient("https://api.swiftauth.net", "YOUR_SECRET", "1.0.0"); // Initialize session $client->init(); // Authenticate $client->login("user", "pass"); echo "Welcome {$client->user['key']}, level {$client->user['level']}\n"; // Variables $vars = $client->getAllVariables(); // License variables $seats = $client->getLicenseVariable("max_seats"); // User variables $client->setUserVariable("theme", "dark"); // Clean up $client->endSession();
Swift
The Swift SDK uses CryptoKit and Foundation. Works with Swift Package Manager on macOS 12+ and iOS 15+.
Installation (SPM)
Quick Start
import SwiftAuth let client = SwiftAuthClient( baseURL: "https://api.swiftauth.net", appSecret: "YOUR_SECRET", appVersion: "1.0.0" ) // Initialize session let data = try client.initialize() // Authenticate try client.login(username: "user", password: "pass") print("Welcome \(client.user!.key), level \(client.user!.level)") // Variables let vars = try client.getAllVariables() // User variables try client.setUserVariable(key: "theme", value: "dark") // Clean up try client.endSession()
Lua
The Lua SDK uses LuaSocket and lua-cjson. Great for game development, embedded scripting, and lightweight tools.
Installation
Quick Start
local SwiftAuth = require("swiftauth") local client = SwiftAuth.new( "https://api.swiftauth.net", "YOUR_SECRET", "1.0.0" ) -- Initialize session client:init() -- Authenticate client:login("user", "pass") print("Welcome " .. client.user.key .. ", level " .. client.user.level) -- Variables local vars = client:get_all_variables() -- License variables local seats = client:get_license_variable("max_seats") print("Max seats: " .. seats.value) -- User variables client:set_user_variable("theme", "dark") -- Clean up client:end_session()
Discord Avatar / Profile Picture
If a user has a Discord ID linked (set via license or dashboard), you can retrieve their Discord profile picture — including animated GIFs — through the getUser() method.
The getUser() response includes two Discord-related fields:
avatarUrl— Full CDN URL to the user's Discord profile picture (PNG or GIF). Falls back to the default Discord avatar if none is set.discordId— The user's Discord ID (snowflake string).
Animated avatars (GIFs) are automatically detected — if the avatar hash starts with a_, the URL uses .gif extension, otherwise .png.
Python
from swiftauth import SwiftAuthClient client = SwiftAuthClient("https://api.swiftauth.net", "YOUR_SECRET", "1.0.0") client.init() client.login("user", "pass") # Fetch full user profile (includes Discord data) client.get_user() if client.user.avatar_url: print(f"Discord avatar: {client.user.avatar_url}") print(f"Discord ID: {client.user.discord_id}") # Check if it's an animated GIF if client.user.avatar_url.endswith(".gif?size=256"): print("Animated avatar!") else: print("No Discord avatar linked")
Node.js
const { SwiftAuthClient } = require("swiftauth-sdk"); const client = new SwiftAuthClient({ baseUrl: "https://api.swiftauth.net", appSecret: "YOUR_SECRET", }); await client.init(); await client.login("user", "pass"); // Fetch full user profile (includes Discord data) await client.getUser(); if (client.user.avatarUrl) { console.log(`Discord avatar: ${client.user.avatarUrl}`); console.log(`Discord ID: ${client.user.discordId}`); // Check if it's an animated GIF if (client.user.avatarUrl.includes(".gif")) { console.log("Animated avatar!"); } } else { console.log("No Discord avatar linked"); }
How It Works
Discord IDs can be attached to licenses in the dashboard. When a user activates a license that has a Discord ID, that ID is linked to their account. The server resolves the Discord avatar URL automatically via the Discord API.
Avatar URLs follow the Discord CDN format:
// Standard avatar (PNG) https://cdn.discordapp.com/avatars/{discord_id}/{hash}.png?size=256 // Animated avatar (GIF) — hash starts with "a_" https://cdn.discordapp.com/avatars/{discord_id}/{hash}.gif?size=256 // Default fallback (no custom avatar set) https://cdn.discordapp.com/embed/avatars/0.png
Feature Comparison
| Feature | Python | Node.js | C# | C++ | Go | Rust | Java | Kotlin | Ruby | PHP | Swift | Lua |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Init / Login / Register | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| License Auth | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Variables (App + User) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| File Downloads + Decrypt | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — |
| Heartbeat / Sessions | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Discord Avatar / Profile Picture | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| WebSocket Real-time | ✓ | ✓ | ✓ | — | ✓ | — | ✓ | ✓ | — | — | — | — |
| Type Safety | Hints | JSDoc | Full | Full | Full | Full | Full | Full | Duck | Strict | Full | Duck |
Method Reference
Every SDK method maps 1:1 to the SwiftAuth Client API:
| Method | Description |
|---|---|
| init | Initialize session with app secret |
| login | Authenticate with username/password |
| register | Create new user account |
| licenseLogin | Authenticate with license key only |
| activate | Activate a license on current user |
| checkLicense | Check if a license key is valid without activating it |
| validateToken | Validate a pre-auth access token |
| getVariable | Fetch a single app variable |
| getAllVariables | Fetch all app variables |
| getLicenseVariable | Fetch a license-scoped variable |
| getAllLicenseVariables | Fetch all license-scoped variables |
| getUserVariable | Fetch a user-scoped variable |
| getAllUserVariables | Fetch all user-scoped variables |
| setUserVariable | Set/update a user-scoped variable |
| deleteUserVariable | Delete a user-scoped variable |
| downloadFile | Download a file by name |
| checkUpdate | Check for app version updates |
| heartbeat | Keep session alive (nonce required) |
| checkSession | Verify session is still valid |
| endSession | End and invalidate the session |
| getUser | Get current user profile info (includes Discord avatar URL and Discord ID) |
| changePassword | Change the current user's password |
| requestReset | Request HWID/IP reset email |
| log | Send a client-side log entry |
WebSocket Events
| Event | Direction | Description |
|---|---|---|
| ping / pong | Both | Keep-alive |
| set_status | Client → Server | Set user online status |
| chat | Both | Chat messages |
| typing | Both | Typing indicators |
| set_metadata | Client → Server | Attach metadata to session |
| force_logout | Server → Client | Forced disconnect |
| command | Server → Client | Custom command from dashboard |
| custom | Server → Client | Custom JSON payload |
| message | Server → Client | Broadcast messages |
Error Codes
| Code | Meaning |
|---|---|
| UNAUTHORIZED | Invalid secret, credentials, or expired session |
| NONCE_REQUIRED | Heartbeat/login requires a fresh nonce |
| HWID_LOCKED | Device doesn't match the locked HWID |
| IP_LOCKED | IP doesn't match the locked IP |
| DEVICE_LIMIT | Too many devices for this user |
| BANNED | User or license is banned |
| EXPIRED | Subscription or license has expired |
| VERSION_MISMATCH | Client version doesn't match app version |
| PLAN_FEATURE | Feature requires a higher plan |