Skip to main content
Use this topic to understand how to use API wrappers to properly call Microsoft Game Development Kit (GDK) and XBOX services APIs from managed code.

Accessing Microsoft Game Development Kit (GDK) APIs

After you’ve imported the Microsoft GDK API package from Unity, its functionality is available under the XGamingRuntime namespace. All Gaming Runtime APIs are available via static methods on the SDK class. All XBOX services APIs are available via static methods on the SDK.XBL class. The following example shows this availability.

API coverage and conventions

Not every API is available via the package. For a complete list of these APIs, see the Microsoft Game Development Kit (GDK) and XBOX services API lists later in this topic.
Conventions:
  • API names match their GDK counterparts where possible.
  • No exceptions. Errors are communicated via HRESULTs.
  • Flat API surface with no object oriented encapsulation.
  • out parameters are used in APIs that set parameters.
  • Async methods use callbacks. For details, see the following section.

Asynchronous programming model

Most async APIs take a callback as their last parameter. An example is shown as follows.
Information about the threading model is as follows.
  • Async methods execute immediately, and the work is performed on an available thread in the thread pool.
    • The thread pool is initialized internally after a call is made to SDK.XGameRuntimeInitialize().
    • No thread pool configuration options are exposed.
  • The result callback is invoked after dispatch is called (that is, SDK.XTaskQueueDispatch()). As a result, it’s important that dispatch is called frequently, ideally, during your game’s update loop.
  • The result callback is executed on the thread that invoked dispatch.

Example differences between native APIs and managed wrappers

Native APIs and managed wrappers have minimal differences. For reference, the following two examples show signature and call functions of XUserAddAsync and XblAchievementsUpdateAchievementAsync in managed and native code.

XUserAddAsync example

The native signature for XUserAddAsync is as follows.
Where the managed signature for XUserAddAsync is:
An example of how to call functions of XUserAddAsync in native code is as follows.
Where the managed example of calling XUserAddAsync functions is:
If you prefer to use a custom queue, or if the API doesn’t include a callback implementation, the following example illustrates how to create an XAsyncBlock. You must also ensure the proper dispatching and completion of the queue. For more information, see XTaskQueue library overview.

XblAchievementsUpdateAchievementAsync example

The native signature for XblAchievementsUpdateAchievementAsync is as follows.
Where the managed signature for XblAchievementsUpdateAchievementAsync is:
An example of how to call functions of XblAchievementsUpdateAchievementAsync in native code is as follows.
Where the managed example of calling XblAchievementsUpdateAchievementAsync functions is:

Initializing XBOX Services API (XSAPI) in managed code

For reference, the following is an initialization of XSAPI in managed code. This is the XSAPI signature in managed code.
The following is an example of the XSAPI call pattern in managed code.

List of Microsoft Game Development Kit (GDK) APIs in managed wrappers

The following Microsoft Game Development Kit (GDK) APIs are included in managed wrappers within the GDK Unity package. For more information about Microsoft Game Development Kit (GDK) APIs, see System API reference.
  • XAccessibility
    • XClosedCaptionGetProperties
    • XClosedCaptionSetEnabled
    • XHighContrastGetMode
    • XSpeechToTextSendString
    • XSpeechToTextSetPositionHint
    • XSpeechToTextBeginHypothesisString
    • XSpeechToTextUpdateHypothesisString
    • XSpeechToTextFinalizeHypothesisString
    • XSpeechToTextCancelHypothesisString
  • XAppCapture
    • XAppBroadcastGetStatus
    • XAppBroadcastIsAppBroadcasting
    • XAppBroadcastShowUI
    • XAppBroadcastRegisterIsAppBroadcastingChanged
    • XAppCaptureCloseLocalStream
    • XAppCaptureCloseScreenshotStream
    • XAppCaptureEnableRecord
    • XAppCaptureDisableRecord
    • XAppBroadcastUnregisterIsAppBroadcastingChanged
    • XAppCaptureMetadataAddStringEvent
    • XAppCaptureMetadataAddInt32Event
    • XAppCaptureMetadataAddDoubleEvent
    • XAppCaptureMetadataStartStringState
    • XAppCaptureMetadataStartInt32State
    • XAppCaptureMetadataStartDoubleState
    • XAppCaptureMetadataStopState
    • XAppCaptureMetadataStopAllStates
    • XAppCaptureMetadataRemainingStorageBytesAvailable
    • XAppCaptureOpenScreenshotStream
    • XAppCaptureReadScreenshotStream
    • XAppCaptureRecordDiagnosticClip
    • XAppCaptureTakeDiagnosticScreenshot
    • XAppCaptureTakeScreenshot
    • XAppCaptureRegisterMetadataPurged
    • XAppCaptureUnRegisterMetadataPurged
    • XAppCaptureReadLocalStream
    • XAppCaptureRecordTimespan
    • XAppCaptureGetVideoCaptureSettings
  • XAsync
    • XAsyncGetStatus
    • XAsyncGetResultSize
    • XAsyncCancel
    • XAsyncRun
  • XDisplay
    • XDisplayTryEnableHdrMode
    • XDisplayAcquireTimeoutDeferral
    • XDisplayCloseTimeoutDeferralHandle
  • XError
    • XErrorSetCallback
    • XErrorSetOptions
  • XGameEvent
    • XGameEventWrite
  • XGame
    • XGameGetXboxTitleId
    • XLaunchNewGame
    • XLaunchRestartOnCrash
  • XGameInvite
    • XGameInviteRegisterForEvent
    • XGameInviteUnregisterForEvent
  • XGameProtocol
    • XGameProtocolRegisterForActivation
    • XGameProtocolUnregisterForActivation
  • XGameRuntimeFeature
    • XGameRuntimeIsFeatureAvailable
  • XGameRuntimeInit
    • XGameRuntimeInitialize
    • XGameRuntimeUninitialize
  • XGameSave
    • XGameSaveInitializeProvider
    • XGameSaveInitializeProviderAsync
    • XGameSaveInitializeProviderResult
    • XGameSaveCloseProvider
    • XGameSaveGetRemainingQuota
    • XGameSaveGetRemainingQuotaAsync
    • XGameSaveGetRemainingQuotaResult
    • XGameSaveDeleteContainer
    • XGameSaveDeleteContainerAsync
    • XGameSaveDeleteContainerResult
    • XGameSaveCreateContainer
    • XGameSaveCloseContainer
    • XGameSaveGetContainerInfo
    • XGameSaveEnumerateContainerInfo
    • XGameSaveEnumerateContainerInfoByName
    • XGameSaveEnumerateBlobInfo
    • XGameSaveEnumerateBlobInfoByName
    • XGameSaveReadBlobData
    • XGameSaveReadBlobDataAsync
    • XGameSaveReadBlobDataResult
    • XGameSaveCreateUpdate
    • XGameSaveCloseUpdateHandle
    • XGameSaveSubmitBlobWrite
    • XGameSaveSubmitBlobDelete
    • XGameSaveSubmitUpdate
    • XGameSaveSubmitUpdateAsync
    • XGameSaveSubmitUpdateResult
  • XGameSaveFiles
    • XGameSaveFilesGetFolderWithUiAsync
    • XGameSaveFilesGetFolderWithUiResult
    • XGameSaveFilesGetRemainingQuota
  • XGameStreaming
    • XGameStreamingInitialize
    • XGameStreamingUninitialize
    • XGameStreamingIsStreaming
    • XGameStreamingGetClientCount
    • XGameStreamingGetClients
    • XGameStreamingGetConnectionState
    • XGameStreamingRegisterConnectionStateChanged
    • XGameStreamingUnregisterConnectionStateChanged
    • XGameStreamingHideTouchControls
    • XGameStreamingHideTouchControlsOnClient
    • XGameStreamingShowTouchControlLayout
    • XGameStreamingShowTouchControlLayoutOnClient
    • XGameStreamingRegisterClientPropertiesChanged
    • XGameStreamingUnregisterClientPropertiesChanged
    • XGameStreamingGetStreamPhysicalDimensions
    • XGameStreamingGetStreamAddedLatency
    • XGameStreamingGetServerLocationNameSize
    • XGameStreamingGetServerLocationName
    • XGameStreamingIsTouchInputEnabled
    • XGameStreamingGetLastFrameDisplayed
    • XGameStreamingUpdateTouchControlsState
    • XGameStreamingUpdateTouchControlsStateOnClient
    • XGameStreamingShowTouchControlsWithStateUpdate
    • XGameStreamingShowTouchControlsWithStateUpdateOnClient
    • XGameStreamingGetTouchBundleVersionNameSize
    • XGameStreamingGetTouchBundleVersion
    • XGameStreamingGetClientIPAddress
    • XGameStreamingGetSessionId
    • XGameStreamingGetDisplayDetails
    • XGameStreamingSetResolution
  • XGameUI
    • XGameUIShowAchievementsAsync
    • XGameUIShowAchievementsResult
    • XGameUIShowMessageDialogAsync
    • XGameUIShowMessageDialogResult
    • XGameUIShowErrorDialogAsync
    • XGameUIShowErrorDialogResult
    • XGameUIShowTextEntryAsync
    • XGameUIShowTextEntryResultSize
    • XGameUIShowTextEntryResult
    • XGameUITextEntryClose
    • XGameUITextEntryGetExtents
    • XGameUITextEntryOpen
    • XGameUITextEntryGetState
    • XGameUITextEntryUpdatePositionHint
    • XGameUITextEntryUpdateVisibility
    • XGameUISetNotificationPositionHint
    • XGameUIShowSendGameInviteAsync
    • XGameUIShowSendGameInviteResult
    • XGameUIShowMultiplayerActivityGameInviteAsync
    • XGameUIShowMultiplayerActivityGameInviteResult
    • XGameUIShowWebAuthenticationAsync
    • XGameUIShowWebAuthenticationResult
    • XGameUIShowWebAuthenticationWithOptionsAsync
    • XGameUIShowWebAuthenticationResultSize
    • XGameUIShowPlayerProfileCardAsync
    • XGameUIShowPlayerProfileCardResult
    • XGameUIShowPlayerPickerAsync
    • XGameUIShowPlayerPickerResultCount
    • XGameUIShowPlayerPickerResult
  • XLauncher
    • XLaunchUri
  • XNetworking
    • XNetworkingGetConnectivityHint
    • XNetworkingQueryConfigurationSetting
    • XNetworkingQueryPreferredLocalUdpMultiplayerPort
    • XNetworkingQueryPreferredLocalUdpMultiplayerPortAsync
    • XNetworkingQueryPreferredLocalUdpMultiplayerPortAsyncResult
    • XNetworkingQuerySecurityInformationForUrlAsync
    • XNetworkingQuerySecurityInformationForUrlAsyncResultSize
    • XNetworkingQuerySecurityInformationForUrlAsyncResult
    • XNetworkingQuerySecurityInformationForUrlUtf16Async
    • XNetworkingQuerySecurityInformationForUrlUtf16AsyncResultSize
    • XNetworkingQuerySecurityInformationForUrlUtf16AsyncResult
    • XNetworkingQueryStatistics
    • XNetworkingRegisterConnectivityHintChanged
    • XNetworkingUnregisterConnectivityHintChanged
    • XNetworkingRegisterPreferredLocalUdpMultiplayerPortChanged
    • XNetworkingUnregisterPreferredLocalUdpMultiplayerPortChanged
    • XNetworkingVerifyServerCertificate
  • XPackage
    • XPackageGetCurrentProcessPackageIdentifier
    • XPackageIsPackagedProcess
    • XPackageGetUserLocale
    • XPackageEnumeratePackages
    • XPackageFindChunkAvailability
    • XPackageChangeChunkInstallOrder
    • XPackageInstallChunks
    • XPackageUninstallChunks
    • XPackageInstallChunksAsync
    • XPackageInstallChunksResult
    • XPackageRegisterPackageInstalled
    • XPackageUnregisterPackageInstalled
    • XPackageEnumerateFeatures
    • XPackageEnumerateChunkAvailability
    • XPackageMount
    • XPackageMountWithUiAsync
    • XPackageMountWithUiResult
    • XPackageGetMountPath
    • XPackageGetMountPathSize
    • XPackageCloseMountHandle
    • XPackageCreateInstallationMonitor
    • XPackageCloseInstallationMonitorHandle
    • XPackageGetInstallationProgress
    • XPackageUpdateInstallationMonitor
    • XPackageRegisterInstallationProgressChanged
    • XPackageUnregisterInstallationProgressChanged
    • XPackageEstimateDownloadSize
    • XPackageGetWriteStats
    • XPackageUninstallUWPInstance
    • XPackageUninstallPackage
  • XPersistentLocalStorage
    • XPersistentLocalStorageGetPathSize
    • XPersistentLocalStorageGetPath
    • XPersistentLocalStorageGetSpaceInfo
    • XPersistentLocalStoragePromptUserForSpaceAsync
    • XPersistentLocalStoragePromptUserForSpaceResult
  • XSpeechSynthesizer
    • XSpeechSynthesizerEnumerateInstalledVoices
    • XSpeechSynthesizerCreate
    • XSpeechSynthesizerCloseHandle
    • XSpeechSynthesizerSetDefaultVoice
    • XSpeechSynthesizerSetCustomVoice
    • XSpeechSynthesizerCreateStreamFromText
    • XSpeechSynthesizerCreateStreamFromSsml
    • XSpeechSynthesizerCloseStreamHandle
    • XSpeechSynthesizerGetStreamDataSize
    • XSpeechSynthesizerGetStreamData
  • XStore
    • XStoreCreateContext
    • XStoreCloseContextHandle
    • XStoreIsAvailabilityPurchasable
    • XStoreAcquireLicenseForPackageAsync
    • XStoreAcquireLicenseForPackageResult
    • XStoreCanAcquireLicenseForPackageAsync
    • XStoreCanAcquireLicenseForPackageResult
    • XStoreCanAcquireLicenseForStoreIdAsync
    • XStoreCanAcquireLicenseForStoreIdResult
    • XStoreCloseLicenseHandle
    • XStoreIsLicenseValid
    • XStoreQueryAddOnLicensesAsync
    • XStoreQueryAddOnLicensesResultCount
    • XStoreQueryAddOnLicensesResult
    • XStoreQueryGameLicenseAsync
    • XStoreQueryGameLicenseResult
    • XStoreQueryLicenseTokenAsync
    • XStoreQueryLicenseTokenResultSize
    • XStoreQueryLicenseTokenResult
    • XStoreRegisterGameLicenseChanged
    • XStoreUnregisterGameLicenseChanged
    • XStoreRegisterPackageLicenseLost
    • XStoreUnregisterGameLicenseChanged
    • XStoreUnregisterPackageLicenseLost
    • XStoreAcquireLicenseForDurablesAsync
    • XStoreQueryGameAndDlcPackageUpdatesAsync
    • XStoreQueryGameAndDlcPackageUpdatesResultCount
    • XStoreQueryGameAndDlcPackageUpdatesResult
    • XStoreDownloadAndInstallPackagesAsync
    • XStoreDownloadAndInstallPackagesResultCount
    • XStoreDownloadAndInstallPackagesResult
    • XStoreDownloadAndInstallPackageUpdatesAsync
    • XStoreDownloadAndInstallPackageUpdatesResult
    • XStoreDownloadPackageUpdatesAsync
    • XStoreDownloadPackageUpdatesResult
    • XStoreQueryPackageIdentifier
    • XStoreShowRedeemTokenUIAsync
    • XStoreShowRedeemTokenUIResult
    • XStoreShowRateAndReviewUIAsync
    • XStoreShowRateAndReviewUIResult
    • XStoreShowPurchaseUIAsync
    • XStoreShowPurchaseUIResult
    • XStoreQueryConsumableBalanceRemainingAsync
    • XStoreQueryConsumableBalanceRemainingResult
    • XStoreReportConsumableFulfillmentAsync
    • XStoreReportConsumableFulfillmentResult
    • XStoreGetUserCollectionsIdAsync
    • XStoreGetUserCollectionsIdResultSize
    • XStoreGetUserCollectionsIdResult
    • XStoreGetUserPurchaseIdAsync
    • XStoreGetUserPurchaseIdResultSize
    • XStoreGetUserPurchaseIdResult
    • XStoreQueryAssociatedProductsAsync
    • XStoreQueryAssociatedProductsResult
    • XStoreQueryEntitledProductsAsync
    • XStoreQueryEntitledProductsResult
    • XStoreQueryProductForCurrentGameAsync
    • XStoreQueryProductForCurrentGameResult
    • XStoreQueryProductForPackageAsync
    • XStoreQueryProductForPackageResult
    • XStoreQueryProductsAsync
    • XStoreQueryProductsResult
    • XStoreProductsQueryNextPageAsync
    • XStoreCloseProductsQueryHandle
    • XStoreAcquireLicenseForDurablesResult
    • XStoreEnumerateProductsQuery
    • XStoreProductsQueryHasMorePages
    • XStoreProductsQueryNextPageResult
    • XStoreShowAssociatedProductsUIAsync
    • XStoreShowAssociatedProductsUIResult
    • XStoreShowProductPageUIAsync
    • XStoreShowProductPageUIResult
  • XSystem
    • XSystemGetAnalyticsInfo
    • XSystemGetAppSpecificDeviceId
    • XSystemGetConsoleId
    • XSystemGetDeviceType
    • XSystemGetXboxLiveSandboxId
    • XSystemGetRuntimeInfo
    • XSystemIsHandleValid
    • XSystemHandleTrack
  • XTaskQueue
    • XTaskQueueCloseHandle
    • XTaskQueueCreate
    • XTaskQueueCreateComposite
    • XTaskQueueDispatch
    • XTaskQueueDuplicateHandle
    • XTaskQueueGetCurrentProcessTaskQueue
    • XTaskQueueGetPort
    • XTaskQueueRegisterMonitor
    • XTaskQueueRegisterWaiter
    • XTaskQueueSetCurrentProcessTaskQueue
    • XTaskQueueSubmitCallback
    • XTaskQueueSubmitDelayedCallback
    • XTaskQueueTerminate
    • XTaskQueueUnregisterMonitor
    • XTaskQueueUnregisterWaiter
  • XThread
    • XThreadIsTimeSensitive
    • XThreadSetTimeSensitive
    • XThreadAssertNotTimeSensitive
  • XUser
    • XUserDuplicateHandle
    • XUserCloseHandle
    • XUserCompare
    • XUserGetMaxUsers
    • XUserAddAsync
    • XUserAddResult
    • XUserAddByIdWithUiAsync
    • XUserAddByIdWithUiResult
    • XUserGetId
    • XUserFindUserById
    • XUserGetLocalId
    • XUserFindUserByLocalId
    • XUserGetIsGuest
    • XUserGetState
    • XUserGetGamertag
    • XUserGetGamerPictureAsync
    • XUserGetAgeGroup
    • XUserCheckPrivilege
    • XUserResolvePrivilegeWithUiAsync
    • XUserResolvePrivilegeWithUiResult
    • XUserGetTokenAndSignatureUtf16Async
    • XUserResolveIssueWithUiUtf16Async
    • XUserResolveIssueWithUiUtf16Result
    • XUserRegisterForChangeEvent
    • XUserUnregisterForChangeEvent
    • XUserCloseSignOutDeferralHandle
    • XUserFindControllerForUserWithUiAsync
    • XUserFindControllerForUserWithUiResult
    • XUserFindForDevice
    • XUserGetDefaultAudioEndpointUtf16
    • XUserGetGamerPictureResultSize
    • XUserGetGamerPictureResult
    • XUserGetSignOutDeferral
    • XUserGetTokenAndSignatureAsync
    • XUserGetTokenAndSignatureResultSize
    • XUserGetTokenAndSignatureResult
    • XUserGetTokenAndSignatureUtf16ResultSize
    • XUserGetTokenAndSignatureUtf16Result
    • XUserIsStoreUser
    • XUserRegisterForDefaultAudioEndpointUtf16Changed
    • XUserRegisterForDeviceAssociationChanged
    • XUserResolveIssueWithUiAsync
    • XUserResolveIssueWithUiResult
    • XUserUnregisterForDefaultAudioEndpointUtf16Changed
    • XUserUnregisterForDeviceAssociationChanged

List of XBOX services APIs in managed wrappers

The following XBOX services APIs are included in managed wrappers within the GDK Unity package. For more information about XBOX services APIs, see XBOX Live API reference.

Reference API documentation

See also

Get started with Unity for PC development
Last modified on August 20, 2026