Last updated on June 17, 2025
Adding API Calls into the Unreal SDK
Introduction
AccelByte Gaming Services (AGS) Unreal SDK consist of an array of API calls. Integrating new API calls into an existing SDK is a critical step in extending its functionality and keeping it aligned with evolving backend services. This guide walks you through the process of seamlessly adding API endpoints to your AGS Unreal SDK.
Basic Information
SDK Directories to modify
Source/AccelByteUe4Sdk/Public/ApiSource/AccelByteUe4Sdk/Private/ApiSource/AccelByteUe4Sdk/Public/Models
SDK Directories to modify to expose functionality to UE Blueprint
Source/AccelByteUe4Sdk/Public/BlueprintsSource/AccelByteUe4Sdk/Private/Blueprints
File name formats
- Inside
Apidirectory:AccelByte<service name>Api.h - Inside
Blueprintsdirectory:AB<service name>.h - Inside
ModelsdirectoryAccelByte<service name>Models.h
General Steps
- Open the API Explorer and find which endpoint that you want to add
- Go to AccelByte SDK folder and then find and modify the files inside these directories, which file you modify will be based on the service endpoint that you want to call:
3.
Source/AccelByteUe4Sdk/Public/Api4.Source/AccelByteUe4Sdk/Private/Api5.Source/AccelByteUe4Sdk/Public/Models - To make the call available in Blueprint, go to AccelByte SDK folder and then find and modify the files inside these directories, which file you modify will be based on the service endpoint that you want to call:
7.
Source/AccelByteUe4Sdk/Public/Blueprints8.Source/AccelByteUe4Sdk/Private/Blueprints
Example
CASE: We want to add ListGlobalStatItem as a functionality of the SDK and we want it accessible from UE Blueprint.
Implement The change on SDK
NOTE: The directories of interest of this section are:
Source/AccelByteUe4Sdk/Public/ApiSource/AccelByteUe4Sdk/Private/ApiSource/AccelByteUe4Sdk/Public/Models
- Open API Explorer, go to "Storage" in the left hand side drop down menu and search for "List Global"
- You'll find List Global Stat Items Endpoint, we'll use the information from this page to implement our API call in the SDK.
- In AccelByte Unreal SDK, go to
Source/AccelByteUe4Sdk/Publicdirectory. In it you'll findApiandModelsdirectories, we'll need to modify the contents of both to add the functionality. For our case, the endpoint that we want to add is part of Statistics service, so we need to add function call toApi/AccelByteStatisticApi.h. Also, the model to receive data from service response is not present yet, so we need to add astructdefinition toModels/AccelByteStatisticModels.h - First let's add the model. Based on the endpoint information, it will return the following json
{
"data": [
{
"statCode": "string",
"statName": "string",
"namespace": "string",
"value": 0,
"tags": [
"string"
],
"createdAt": "2025-05-26T08:00:45.196Z",
"updatedAt": "2025-05-26T08:00:45.196Z",
"globalAggregationMethod": "TOTAL"
}
],
"paging": {
"previous": "string",
"next": "string"
}
}
- Add into
Models/AccelByteStatisticModels.ha corresponding struct to represent the json above
USTRUCT(BlueprintType)
struct ACCELBYTEUE4SDK_API FAccelByteModelsGlobalStatItemPagingSlicedResult
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AccelByte | Statistic | Models | StatItemPagingSlicedResult")
TArray<FAccelByteModelsGlobalStatItemValueResponse> Data{};
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AccelByte | Statistic | Models | StatItemPagingSlicedResult")
FAccelByteModelsPaging Paging{};
};
- Next, go to
Api/AccelByteStatisticApi.hand add the following function declaration, we make use ofFAccelByteModelsGlobalStatItemPagingSlicedResultstruct that we made earlier:
FAccelByteTaskWPtr ListGlobalStatItems(THandler<FAccelByteModelsGlobalStatItemPagingSlicedResult> const& OnSuccess
, FErrorHandler const& OnError
, TArray<FString> const& StatCodes = {}
, int32 Limit = 20
, int32 Offset = 0);
- Now, let's create the implementation in the .cpp file, go to
Source/AccelByteUe4Sdk/Private/Api/AccelByteStatisticApi.cppand add the following function definition:
FAccelByteTaskWPtr Statistic::ListGlobalStatItems(THandler<FAccelByteModelsGlobalStatItemPagingSlicedResult> const& OnSuccess
, FErrorHandler const& OnError
, TArray<FString> const& StatCodes
, int32 Limit
, int32 Offset)
{
FReport::Log(FString(__FUNCTION__));
const FString Url = FString::Printf(TEXT("%s/v1/public/namespaces/%s/globalstatitems")
, *SettingsRef.StatisticServerUrl
, *CredentialsRef->GetNamespace());
TMultiMap<FString, FString> QueryParams {
{ TEXT("limit"), FString::FromInt(Limit) },
{ TEXT("offset"), FString::FromInt(Offset) },
};
if(!StatCodes.IsEmpty())
{
QueryParams.Emplace(TEXT("statCodes"), FString::Join(StatCodes, TEXT(",")));
}
else
{
// Don't add statCodes into the QueryParams
}
return HttpClient.ApiRequest(TEXT("GET"), Url, QueryParams, FString(), OnSuccess, OnError);
}
- Done, you can do a test to make sure that it properly call the endpoint.
Make the functionality accessible from Blueprint
NOTE: The directories of interest of this section are:
Source/AccelByteUe4Sdk/Public/BlueprintsSource/AccelByteUe4Sdk/Private/Blueprints
After adding the functionality in the SDK, if we want to make it accessible via Blueprint we can follow the steps below:
- We need to add the Response Delegate. To do so, go to
Source/AccelByteUe4Sdk/Public/Blueprints/ABStatistic.hand add the following delegate declaration:
DECLARE_DYNAMIC_DELEGATE_OneParam(FDModelsGlobalStatItemPagingSlicedResultResponse, FAccelByteModelsGlobalStatItemPagingSlicedResult, Response);
- Add the function declaration, make use of the delegate we created above:
UFUNCTION(BlueprintCallable, Category = "AccelByte | Statistic | Api")
void ListGlobalStatItemsWithFilter(
FDModelsGlobalStatItemPagingSlicedResultResponse const& OnSuccess,
FDErrorHandler const& OnError,
TArray<FString> const& StatCodesFilter,
int32 Limit = 20,
int32 Offset = 0
);
UFUNCTION(BlueprintCallable, Category = "AccelByte | Statistic | Api")
void ListGlobalStatItems(
FDModelsGlobalStatItemPagingSlicedResultResponse const& OnSuccess,
FDErrorHandler const& OnError,
int32 Limit = 20,
int32 Offset = 0
);
- We created 2 functions because we need to support calling the endpoint without specifying the stat codes filter but UE Blueprint doesn't support function overloading.
- Implement the function definition for the declaration above:
void UABStatistic::ListGlobalStatItemsWithFilter(
FDModelsGlobalStatItemPagingSlicedResultResponse const& OnSuccess,
FDErrorHandler const& OnError,
TArray<FString> const& StatCodes,
int32 Limit,
int32 Offset)
{
const auto StatisticPtr = ApiClientPtr->GetStatisticApi().Pin();
if (StatisticPtr.IsValid())
{
StatisticPtr->ListGlobalStatItems(
THandler<FAccelByteModelsGlobalStatItemPagingSlicedResult>::CreateLambda(
[OnSuccess](FAccelByteModelsGlobalStatItemPagingSlicedResult const& Response)
{
OnSuccess.ExecuteIfBound(Response);
}
),
FErrorHandler::CreateLambda(
[OnError](int32 Code, FString const& Message)
{
OnError.ExecuteIfBound(Code, Message);
}
), StatCodes, Limit, Offset);
}
else
{
OnError.ExecuteIfBound(static_cast<int32>(AccelByte::ErrorCodes::InvalidRequest), TEXT("Api already destroyed!"));
}
}
void UABStatistic::ListGlobalStatItems(
FDModelsGlobalStatItemPagingSlicedResultResponse const& OnSuccess,
FDErrorHandler const& OnError,
int32 Limit,
int32 Offset)
{
// Call with empty array
ListGlobalStatItemsWithFilter(OnSuccess, OnError, TArray<FString>(), Limit, Offset);
}
- Done, you can do a test to make sure that the endpoint properly called from UE Blueprint.