SwiftAuth SDKs

Official client libraries for every major language. Full API coverage, WebSocket support, and type safety out of the box.

View on GitHub →

Py

Python

v1.0.0 · Python 3.9+

Synchronous + async support. Zero config WebSocket client with auto-reconnect.

JS

Node.js

v1.0.0 · Node 18+

Promise-based API with built-in event emitter for WebSocket and real-time features.

C#

C# / .NET

v1.0.0 · .NET 8+

Fully async with native WebSocket support. Works with WPF, WinForms, and console apps.

C+

C++

v1.0.0 · C++17

Header-friendly library using libcurl. Ideal for game cheats, desktop tools, and native apps.

Go

Go

v0.1.0 · Go 1.21+

Idiomatic Go client with goroutine-safe WebSocket and full file decryption support.

Rs

Rust

v0.1.0 · Rust 2021

Synchronous Rust client built on reqwest::blocking. Full type safety with serde and file decryption.

Jv

Java

v1.0.0 · Java 17+

Modern Java client using HttpClient and built-in WebSocket. Zero external dependencies.

Kt

Kotlin

v1.0.0 · Kotlin 1.9+

Idiomatic Kotlin with lambdas, data classes, and null safety. JVM 17+ compatible.

Rb

Ruby

v1.0.0 · Ruby 3.0+

Clean Ruby API with keyword arguments, Struct-based models, and file decryption.

PH

PHP

v1.0.0 · PHP 8.1+

Type-safe PHP client with Composer support. Full file decryption and GMP-based crypto.

Sw

Swift

v1.0.0 · Swift 5.9+

Native Swift client using CryptoKit and Foundation. SPM package for macOS and iOS.

Lu

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

$ pip install swiftauth

Or install from source:

$ pip install -e path/to/sdks/python

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

$ npm install swiftauth-sdk

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

$ dotnet add package SwiftAuth

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)

add_subdirectory(path/to/sdks/cpp)
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

$ go get github.com/SwiftAuth/SwiftSDK/go

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

$ cargo add swiftauth

Or add to Cargo.toml:

[dependencies]
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)

<dependency> <groupId>net.swiftauth</groupId> <artifactId>swiftauth-sdk</artifactId> <version>0.1.0</version> </dependency>

Installation (Gradle)

implementation 'net.swiftauth:swiftauth-sdk:0.1.0'

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)

implementation("net.swiftauth:swiftauth-sdk:1.0.0")

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

$ gem install swiftauth

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)

$ composer require swiftauth/swiftauth-php

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)

.package(url: "https://github.com/SwiftAuth/SwiftSDK", from: "1.0.0")

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

$ luarocks install lua-cjson luasocket

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:

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 HintsJSDocFullFullFullFullFullFullDuckStrictFullDuck

Method Reference

Every SDK method maps 1:1 to the SwiftAuth Client API:

MethodDescription
initInitialize session with app secret
loginAuthenticate with username/password
registerCreate new user account
licenseLoginAuthenticate with license key only
activateActivate a license on current user
checkLicenseCheck if a license key is valid without activating it
validateTokenValidate a pre-auth access token
getVariableFetch a single app variable
getAllVariablesFetch all app variables
getLicenseVariableFetch a license-scoped variable
getAllLicenseVariablesFetch all license-scoped variables
getUserVariableFetch a user-scoped variable
getAllUserVariablesFetch all user-scoped variables
setUserVariableSet/update a user-scoped variable
deleteUserVariableDelete a user-scoped variable
downloadFileDownload a file by name
checkUpdateCheck for app version updates
heartbeatKeep session alive (nonce required)
checkSessionVerify session is still valid
endSessionEnd and invalidate the session
getUserGet current user profile info (includes Discord avatar URL and Discord ID)
changePasswordChange the current user's password
requestResetRequest HWID/IP reset email
logSend a client-side log entry

WebSocket Events

EventDirectionDescription
ping / pongBothKeep-alive
set_statusClient → ServerSet user online status
chatBothChat messages
typingBothTyping indicators
set_metadataClient → ServerAttach metadata to session
force_logoutServer → ClientForced disconnect
commandServer → ClientCustom command from dashboard
customServer → ClientCustom JSON payload
messageServer → ClientBroadcast messages

Error Codes

CodeMeaning
UNAUTHORIZEDInvalid secret, credentials, or expired session
NONCE_REQUIREDHeartbeat/login requires a fresh nonce
HWID_LOCKEDDevice doesn't match the locked HWID
IP_LOCKEDIP doesn't match the locked IP
DEVICE_LIMITToo many devices for this user
BANNEDUser or license is banned
EXPIREDSubscription or license has expired
VERSION_MISMATCHClient version doesn't match app version
PLAN_FEATUREFeature requires a higher plan