Skip to content

Fetch a Single Metadata In-Game

This how-to fetches a single Metadata entry by key from your game and outputs it to the console.

Prerequisites

Fetch Metadata by Key

When fetching a single Metadata entry, provide three things:

  • A ulid: the ID of the item to fetch Metadata for. This can be retrieved through the Web Console or in the SDKs, depending on the feature.
    • For example: 01J96M0BX1GGTPP2QDRCBV3FW2
  • A key: the key of the desired Metadata entry.
    • For example: icon
  • A source type: one of the following: Progression, Leaderboard, Catalog Item, or Currency.

Call the function with these values to fetch and display the Metadata entry.

// Available sources are: reward, leaderboard, catalog_item, progression, currency,
LootLockerMetadataSources sourceType = LootLockerMetadataSources.leaderboard;
// The ulid of the source you are trying to fetch metadata for
string sourceID = "01J96M0BX1GGTPP2QDRCBV3FW2";
// The key of the source that you want to fetch
string key = "info";
// Base64 can be set to content_type "application/x-redacted", use this to avoid accidentally fetching large data files
bool ignoreFiles = true;
LootLockerSDKManager.GetMetadata(sourceType, sourceID, key, (response) =>
{
if(response.success)
{
// If it succeeded, dispaly the fetched metadata in the console
string value = "";
response.entry.TryGetValueAsString(out value);
Debug.Log("Metadata result:"+ value);
}
else
{
// If it failed, output the error to the console
Debug.Log(response.errorData.message);
}
}, ignoreFiles);

Conclusion

You've fetched a single Metadata entry created in the Web Console. You can also fetch Metadata by tags or from multiple sources at once.