Skip to main content
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

  1. Source/AccelByteUe4Sdk/Public/Api
  2. Source/AccelByteUe4Sdk/Private/Api
  3. Source/AccelByteUe4Sdk/Public/Models

SDK Directories to modify to expose functionality to UE Blueprint

  1. Source/AccelByteUe4Sdk/Public/Blueprints
  2. Source/AccelByteUe4Sdk/Private/Blueprints

File name formats

  1. Inside Api directory: AccelByte<service name>Api.h
  2. Inside Blueprints directory: AB<service name>.h
  3. Inside Models directory AccelByte<service name>Models.h

General Steps

  1. Open the API Explorer and find which endpoint that you want to add
  2. 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/Api 4. Source/AccelByteUe4Sdk/Private/Api 5. Source/AccelByteUe4Sdk/Public/Models
  3. 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/Blueprints 8. 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/Api
  • Source/AccelByteUe4Sdk/Private/Api
  • Source/AccelByteUe4Sdk/Public/Models
  1. Open API Explorer, go to "Storage" in the left hand side drop down menu and search for "List Global"
  2. You'll find List Global Stat Items Endpoint, we'll use the information from this page to implement our API call in the SDK.
  3. In AccelByte Unreal SDK, go to Source/AccelByteUe4Sdk/Public directory. In it you'll find Api and Models directories, 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 to Api/AccelByteStatisticApi.h. Also, the model to receive data from service response is not present yet, so we need to add a struct definition to Models/AccelByteStatisticModels.h
  4. 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"
}
}
  1. Add into Models/AccelByteStatisticModels.h a 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{};
};
  1. Next, go to Api/AccelByteStatisticApi.h and add the following function declaration, we make use of FAccelByteModelsGlobalStatItemPagingSlicedResult struct that we made earlier:
FAccelByteTaskWPtr ListGlobalStatItems(THandler<FAccelByteModelsGlobalStatItemPagingSlicedResult> const& OnSuccess
, FErrorHandler const& OnError
, TArray<FString> const& StatCodes = {}
, int32 Limit = 20
, int32 Offset = 0);
  1. Now, let's create the implementation in the .cpp file, go to Source/AccelByteUe4Sdk/Private/Api/AccelByteStatisticApi.cpp and 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);
}

  1. 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/Blueprints
  • Source/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:

  1. We need to add the Response Delegate. To do so, go to Source/AccelByteUe4Sdk/Public/Blueprints/ABStatistic.h and add the following delegate declaration:
DECLARE_DYNAMIC_DELEGATE_OneParam(FDModelsGlobalStatItemPagingSlicedResultResponse, FAccelByteModelsGlobalStatItemPagingSlicedResult, Response);
  1. 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
);
  1. 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.
  2. 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);
}
  1. Done, you can do a test to make sure that the endpoint properly called from UE Blueprint.