LootLocker
The BasicsGame SystemsContent ManagementPlayer Management
LootLocker
  • πŸ“ŒThe Basics
    • Getting Started
    • What is LootLocker?
    • Core Concepts
      • Players
      • Assets
      • Character Classes
      • API Types
      • Web Console
      • Stage & Live Environments
      • Glossary
    • Unity Quick Start
      • Install the SDK
      • Configure the SDK
      • Authenticate Your First Player
      • Update the SDK
    • Unreal Quick Start
      • Install & Configure the SDK
        • Older versions
      • Authenticate Your First Player
    • Godot Quick Start
      • Install the SDK
      • Configure the SDK
      • Authenticate Your First Player
      • Update the SDK
    • SDKs
    • Samples
      • Authentication Samples
      • Leaderboard Samples
      • Progression Samples
      • Player Samples
    • Launching Your Game
    • Support
      • Error Codes
      • Unreal Marketplace Plugin Support
  • 🎭Players
    • Overview
    • Authentication
      • How To
        • Guest Login
        • Steam
        • Apple
        • Apple Game Center
        • Google
        • Epic Games
        • PlayStation
        • Meta / Oculus
        • Xbox
        • Nintendo Switch
    • Files
      • How To
        • Manage Files in Web Console
        • Work with Files In-Game
    • Inventory
      • How To
        • Work with Player Inventory
    • Messages
      • How To
        • Configure Messages in Web Console
    • Names
      • How To
        • Work with Player Names
    • Player Manager
      • How To
        • Manage Players through Web Console
        • Manage Players In-Game
        • Use Player Operations
    • Unified Player Accounts
      • How To
        • Configure UPA in Web Console
        • Use Remote Login In-Game
        • Connect Identiy Provider to Player
        • External Provider Linking
        • Transition from Guest Login to Other Provider
        • Disconnect Identity Provider from Player
    • White Label Login
      • How To
        • Configure White Label Login
        • Create a New White Label User
        • Request User Verification
        • Handle Returning Users
        • Start a White Label Session
  • πŸͺ™Commerce
    • Overview
    • Catalogs
      • How To
        • Configure Catalogs in LootLocker Console
        • List all Catalogs
        • Use Catalogs In-Game
        • Setup In-Game Store
    • Currencies
      • How To
        • Configure a Currency in Web Console
        • Use Currencies In-Game
    • DLC Management
      • How To
        • Configure DLC in Web Console
        • Use DLC In-Game
    • Entitlements
      • How To
        • Work with Entitlements In-Game
    • Real Money Purchases
      • How To
        • Configure In-App Purchase in Web Console
        • Make Purchases through Google Play Store
        • Make Purchases through Apple Store
        • Make Purchases through Steam Store
    • Virtual Purchases
    • Wallets
      • How To
        • Manage a Wallet in Web Console
        • Use Wallets In-Game
  • βš”οΈContent
    • Overview
    • Assets
      • How To
        • Create & Configure an Asset
        • Organize & Search for Assets
        • Retrieve Assets In-Game
        • Set up Asset Storage Template
        • Check Grant Notifications
        • Set up a Game Config Asset
        • Create a Loot Box
        • Work with Loot Boxes In-Game
        • Create a Drop Table
        • Work with Drop Tables In-Game
        • Create a Rental Asset
        • Work with Rental Assets In-Game
    • User Generated Content (UGC)
      • How To
        • Create UGC In-Game
    • Twitch Drops
  • πŸ•ΉοΈGame Systems
    • Overview
    • Classes & Heroes
      • How To
        • Base Classes
        • Hero Classes
        • Implement Classes In-Game
        • Implement Heroes In-Game
    • Leaderboards
      • How To
        • Configure Leaderboard in Web Console
        • Use Player Leaderboards
        • Use Generic Leaderboards
        • Use Metadata to Store Additional Information
        • Use Scheduled Reset with Rewards
        • Use Leaderboards for Time Based Rankings
      • Leaderboard FAQ
      • GameMaker References
    • Feedback
      • How To
        • Manage Feedback Categories
        • Create Player Feedback
        • Create UGC Feedback
        • Create Game Feedback
        • View and Manage Feedback
    • Progressions
      • How To
        • Create a Progression
        • Game Progressions
        • Player Progressions
        • Class Progressions
        • Asset Instance Progressions
    • Triggers
      • How To
        • Setup a trigger in the Web Console
        • Invoke trigger from game
  • ⛓️Shared Systems
    • Overview
    • Metadata
      • How To
        • Add Metadata in Console
        • Fetch a Single Metadata In-Game
        • Fetch Metadata In-Game by Tags
        • Fetch Metadata In-Game from Multiple Sources
    • Notifications
      • How To
        • List Notifications and Mark as Read In-Game
  • πŸ—οΈAdmin
    • Settings
    • User Settings
    • Organization Settings
    • CORS Allowlist
  • ⭕️ Legacy
    • Deprecations
      • Unity SDK Deprecation Log
        • Version 2.1.5 - Migration to Open UPM
        • Version 2.0.0
      • Unreal SDK Deprecation Log
        • Version 4.0.0
        • Version 3.0.0
    • Legacy Storage
    • Legacy Triggers
      • Activate a trigger
      • Create a trigger
    • Legacy Progressions
      • Create a Progression System
      • Use a Progression System In-Game
Powered by GitBook
On this page
  • Prerequisites
  • Fetching Metadata from multiple sources
  • Conclusion
  1. Shared Systems
  2. Metadata
  3. How To

Fetch Metadata In-Game from Multiple Sources

PreviousFetch Metadata In-Game by TagsNextNotifications

Last updated 7 months ago

In this How-to, we will fetch all metadata matching a specific key on multiple items.

Prerequisites

  • A LootLocker account and a created game

Fetching Metadata from multiple sources

When fetching a several metadata, you need to provide 3 things:

  • A ulid: (can be retrieved through the or in the depending on the feature) of the item to fetch metadata for

    • For example: 01J96M0BX1GGTPP2QDRCBV3FW2

  • A key: of the desired metadata

    • For example: icon

  • A source type

    • One of the following: , , ,

When fetching metadata by tags, a key will supersede the tag, so if you want to search by tags it’s best to avoid using keys and vice versa. When fetching metadata by tags you will get all metadata on that object with the same corresponding tag.

// Create an array of sources and keys that we want to fetch
LootLockerMetadataSourceAndKeys[] sourcesAndKeys = new LootLockerMetadataSourceAndKeys[]{
    new LootLockerMetadataSourceAndKeys
    {
        source = LootLockerMetadataSources.currency,
        id = "01J7S0CED5K0THCB1ENN9XKQWZ",
        keys = new string[] { "icon" }
    },
    new LootLockerMetadataSourceAndKeys
    {
        source = LootLockerMetadataSources.catalog_item,
        id = "01J9RE51T32WNXSQADNJ5RGQCX",
        keys = new string[] { "icon", "featured" }
    }
};

// Base64 can be set to content_type "application/x-redacted", use this to avoid accidentally fetching large data files
bool ignoreFiles = true;

LootLockerSDKManager.GetMultisourceMetadata(sourcesAndKeys, (response) =>
{

    if (response.success)
    {
        // Handle the received metadata differently depending on the use cases
        foreach (var entry in response.Metadata)
        {
            // Currency
            if (entry.source == LootLockerMetadataSources.currency)
            {
                // Get the first entry as a base64 (file), this is an image so we convert it to a sprite to be displayed
                LootLockerMetadataBase64Value base64String = null;
                entry.entries[0].TryGetValueAsBase64(out base64String);
                byte[] imageBytes = Convert.FromBase64String(base64String.content);
                Texture2D tex = new Texture2D(291, 302);
                tex.LoadImage(imageBytes);
                tex.filterMode = FilterMode.Point;
                Sprite sprite = Sprite.Create(tex, new Rect(0.0f, 0.0f, tex.width, tex.height), new Vector2(0.5f, 0.5f), 100.0f);
                // Add your own code here to display the sprite
            }

            // Catalog Item
            if (entry.source == LootLockerMetadataSources.catalog_item)
            {
                // Multiple keys requested: loop through to find the correct one
                foreach (var catalogItemMetadata in entry.entries)
                {
                    // Handle the image
                    if (catalogItemMetadata.type == LootLockerMetadataTypes.Base64)
                    {
                        // Look above in how LootLockerMetadataSources.currency is handled to see how to handle an image
                    }

                    // Handle a bool
                    if (catalogItemMetadata.type == LootLockerMetadataTypes.Bool)
                    {
                        bool featured = catalogItemMetadata.TryGetValueAsBool(out featured);
                        // Add your own code here to make us of the returned bool value
                    }
                }
            }
        }
    }
    else
    {
        // If it failed, output the error to the console
        Debug.Log(response.errorData.message);
    }
}, ignoreFiles);

Coming soon

curl --location --request POST 'https://api.lootlocker.io/game/metadata/multisource?ignore_files=true' \
--header 'x-session-token: your_token_here' \
--header 'Content-Type: application/json' \
--data-raw '{
    "sources": [
        {
            "source": "leaderboard",
            "id": "01J8030AMYTZN4ZQ4WBT3V8XGP",
            "keys": [
                "has_beta_access",
                "preferred_nickname"
            ]
        },
        {
            "source": "catalog_item",
            "id": "01J7S0CED5K0THCB1ENN9XKQWZ",
            "keys": [
                "has_beta_access"
            ]
        }
    ]
}'

Conclusion

Check out our for more ways of handling the received metadata entries.

In this How-to we’ve fetched multiple metadata entries that were created in the by using tags. Metadata also provides the possibility to in game or .

⛓️
A feature with at least one type of metadata
An active Game Session
web console
SDK's
Progression
leaderboard
catalog_item
currency
SDK
web console
fetch a single metadata
fetch metadata in game with tags