Skip to main content
Reference

C++ API

Add the module to your .Build.cs:

PrivateDependencyModuleNames.AddRange(new string[] { "SteamCoreWeb" });

Calling a function​

Get the subsystem from the Game Instance and call the function. The callback is a dynamic delegate, so bind it to a UFUNCTION.

#include "SteamUser/WebSteamUser.h"
#include "SteamCoreWeb/SteamWebUtilities.h"

void UMyFriendsComponent::RequestPlayerSummaries(const TArray<FString>& SteamIds)
{
UWebSteamUser* SteamUser = GetWorld()->GetGameInstance()->GetSubsystem<UWebSteamUser>();
if (!SteamUser)
{
return;
}

FOnSteamCoreWebCallback Callback;
Callback.BindUFunction(this, GET_FUNCTION_NAME_CHECKED(UMyFriendsComponent, OnPlayerSummaries));

SteamUser->GetPlayerSummaries(Callback, USteamWebUtilities::GetProjectKey(), SteamIds);
}

void UMyFriendsComponent::OnPlayerSummaries(const FString& Data, bool bWasSuccessful)
{
if (!bWasSuccessful)
{
return;
}

TArray<FString> Names;
ESteamJsonResult Result;
USteamWebUtilities::FindJsonStrings(Data, TEXT("personaname"), Names, Result);
}

Declare the callback as a UFUNCTION:

UFUNCTION()
void OnPlayerSummaries(const FString& Data, bool bWasSuccessful);

The callback is called on the game thread. If the object is destroyed before Steam responds, the callback is not called.

Parsing the response with Unreal's JSON module​

For more control than the JSON helpers give, parse Data with Unreal's JSON module. Add "Json" to your .Build.cs as well.

#include "Dom/JsonObject.h"
#include "Serialization/JsonReader.h"
#include "Serialization/JsonSerializer.h"

TSharedPtr<FJsonObject> Root;
const TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Data);

if (FJsonSerializer::Deserialize(Reader, Root) && Root.IsValid())
{
const TSharedPtr<FJsonObject>* Response;
if (Root->TryGetObjectField(TEXT("response"), Response))
{
const TArray<TSharedPtr<FJsonValue>>* Players;
if ((*Response)->TryGetArrayField(TEXT("players"), Players))
{
for (const TSharedPtr<FJsonValue>& Player : *Players)
{
const FString Name = Player->AsObject()->GetStringField(TEXT("personaname"));
}
}
}
}

Subsystem classes​

ClassHeader
UWebAppsApps/WebApps.h
UWebBroadcastServiceBroadcastService/WebBroadcastService.h
UWebCheatReportingCheatReporting/WebCheatReporting.h
UWebEconMarketServiceEconMarket/WebEconMarketService.h
UWebEconServiceEconService/WebEconService.h
UWebGameInventoryGameInventory/WebGameInventory.h
UWebGameNotificationsServiceGameNotificationsService/WebGameNotificationsService.h
UWebGameServersServiceGameServersService/WebGameServersService.h
UWebInventoryServiceInventoryService/WebInventoryService.h
UWebLeaderboardsLeaderboards/WebLeaderboards.h
UWebLobbyMatchmakingServiceLobbyMatchmakingService/WebLobbyMatchmakingService.h
UWebMicroTxnMicroTxn/WebMicroTxn.h
UWebPlayerServicePlayerService/WebPlayerService.h
UWebPublishedFileServicePublishedFileService/WebPublishedFileService.h
UWebSteamPublishedItemSearchPublishedItemSearch/WebPublishedItemSearch.h
UWebPublishedItemVotingPublishedItemVoting/WebPublishedItemVoting.h
UWebSteamCommunitySteamCommunity/WebSteamCommunity.h
UWebSteamEconomySteamEconomy/WebSteamEconomy.h
UWebSteamGameServerStatsSteamGameServerStats/WebSteamGameServerStats.h
UWebSteamNewsSteamNews/WebSteamNews.h
UWebRemoteStorageSteamRemoteStorage/WebRemoteStorage.h
UWebSteamUserSteamUser/WebSteamUser.h
UWebSteamWebAPIUtilWebAPIUtil/WebSteamWebAPIUtil.h
UWebStoreServiceStoreService/WebStoreService.h
UWebUserAuthSteamUserAuth/WebUserAuth.h
UWebUserStatsSteamUserStats/WebUserStats.h
UWebWishlistServiceWishlistService/WebWishlistService.h
UWebWorkshopWorkshop/WebWorkshop.h