SteamAPI

Swift
public final class SteamAPI: SteamBaseAPI, Sendable

An instance of the Steamworks user API

Create and retain one of these to access and use the Steamworks APIs.

Steamworks ref: steam_api.h


Topics

Lifecycle

init?(appID: AppID, fakeAppIdTxtFile: Bool)

Initialize the Steamworks API.

Calls SteamAPI_RestartAppIfNecessary() and SteamAPI_Init().

If you installed a hook with installCEGHooks(initCEG:termCEG:) then the hook is called before SteamAPI_Init().

If you set fakeAppIdTxtFile to true then the system behaves as though you have a steam_appid.txt file in the correct location containing your appID:

  1. SteamAPI_RestartAppIfNecessary() never returns true;
  2. SteamAPI_Init() uses the passed-in App ID. …so it’s a development assist to stop you having to manage the text file.

The Steamworks API is shut down when this object goes out of scope.

Declaration
Swift
public init?(appID: AppID, fakeAppIdTxtFile: Bool = false)
Return Value

nil if the Steam API connection failed or app restart is necessary.

var isSteamRunning: Bool

Calls SteamAPI_IsSteamRunning().

Declaration
Swift
public var isSteamRunning: Bool { get }

Interfaces

var appList: SteamAppList

Access the Steamworks ISteamAppList interface

Declaration
Swift
public let appList: SteamAppList

var apps: SteamApps

Access the Steamworks ISteamApps interface

Declaration
Swift
public let apps: SteamApps

var friends: SteamFriends

Access the Steamworks ISteamFriends interface

Declaration
Swift
public let friends: SteamFriends

var gameSearch: SteamGameSearch

Access the Steamworks ISteamGameSearch interface

Declaration
Swift
public let gameSearch: SteamGameSearch

var htmlSurface: SteamHTMLSurface

Access the Steamworks ISteamHTMLSurface interface

Declaration
Swift
public let htmlSurface: SteamHTMLSurface

var input: SteamInput

Access the Steamworks ISteamInput interface

Declaration
Swift
public let input: SteamInput

var matchmaking: SteamMatchmaking

Access the Steamworks ISteamMatchmaking interface

Declaration
Swift
public let matchmaking: SteamMatchmaking

var matchmakingServers: SteamMatchmakingServers

Access the Steamworks ISteamMatchmakingServers interface

Declaration
Swift
public let matchmakingServers: SteamMatchmakingServers

var music: SteamMusic

Access the Steamworks ISteamMusic interface

Declaration
Swift
public let music: SteamMusic

var musicRemote: SteamMusicRemote

Access the Steamworks ISteamMusicRemote interface

Declaration
Swift
public let musicRemote: SteamMusicRemote

var parentalSettings: SteamParentalSettings

Access the Steamworks ISteamParentalSettings interface

Declaration
Swift
public let parentalSettings: SteamParentalSettings

var parties: SteamParties

Access the Steamworks ISteamParties interface

Declaration
Swift
public let parties: SteamParties

var remotePlay: SteamRemotePlay

Access the Steamworks ISteamRemotePlay interface

Declaration
Swift
public let remotePlay: SteamRemotePlay

var remoteStorage: SteamRemoteStorage

Access the Steamworks ISteamRemoteStorage interface

Declaration
Swift
public let remoteStorage: SteamRemoteStorage

var screenshots: SteamScreenshots

Access the Steamworks ISteamScreenshots interface

Declaration
Swift
public let screenshots: SteamScreenshots

var user: SteamUser

Access the Steamworks ISteamUser interface

Declaration
Swift
public let user: SteamUser

var userStats: SteamUserStats

Access the Steamworks ISteamUserStats interface

Declaration
Swift
public let userStats: SteamUserStats

var video: SteamVideo

Access the Steamworks ISteamVideo interface

Declaration
Swift
public let video: SteamVideo

CEG

static func installCEGHooks(initCEG: () -> Bool, termCEG: () -> Void)

Initialize Steam DRM hooks.

You can call the hooks manually or pass them in here to let the library call them at the right time around SteamAPI_Init() and SteamAPI_Term().

Call this before actually creating a SteamAPI or SteamGameServerAPI.

Declaration
Swift
public static func installCEGHooks(
    initCEG: @escaping () -> Bool, termCEG: @escaping () -> Void)