# Fetch Metadata In-Game by Tags

In this How-to, we will fetch all metadata on a specific leaderboard by using tags.

## Prerequisites

* [A LootLocker account and a created game](https://lootlocker.com/sign-up)
* [A feature with at least one type of metadata](/shared-systems/metadata/how-to/add-metadata-in-console.md)
* [An active Game Session](/players/authentication.md)

## Fetching by tags

When fetching metadata by tags, you need to provide 3 things:

* **A `ulid`**: (can be retrieved through the [web console](https://console.lootlocker.com) or in the [SDK's](/the-basics/sdks.md) depending on the feature) of the item to fetch metadata for
  * For example: `01J96M0BX1GGTPP2QDRCBV3FW2`
* **The tags**: of the desired metadata
  * For example: `warrior, global`
* **A source type**
  * One of the following: [Progression](/game-systems/progressions.md), [leaderboard](/game-systems/leaderboards.md), [catalog\_item](/commerce/catalogs.md), [currency](https://github.com/lootlocker/gitbook-sync/blob/main/commerce/currencies.md)

## Calling the function

When fetching metadata by tags, a key **can be added**, but 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(s).

{% tabs %}
{% tab title="Unity" %}

```csharp
// Available sources are: reward, leaderboard, catalog_item, progression, currency,
LootLockerMetadataSources sourceType = LootLockerMetadataSources.progression;

// The ulid of the source you are trying to fetch metadata for
string sourceID = "01J96M0BX1GGTPP2QDRCBV3FW2";

// The tags of the metadata that you want to fetch
string[] tags = {"warrior", "global" };

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

LootLockerSDKManager.ListMetadataWithTags(sourceType, sourceID, tags, (response) =>
{
    if (response.success)
    {
        // If it succeeded, display all fetched metadata in the console
        Debug.Log("Metadata result:");
        foreach (var entry in response.entries)
        {
            string value = "";
            Debug.Log(entry.key+": "+entry.TryGetValueAsString(out value));
        }
    }
    else
    {
        // If it failed, output the error to the console
        Debug.Log(response.errorData.message);
    }
}, ignoreFiles);
```

{% hint style="info" %}
Check out our [SDK](/the-basics/unity-quick-start.md) for more ways of handling the received metadata entries.
{% endhint %}
{% endtab %}

{% tab title="Unreal" %}

### Coming soon

{% endtab %}

{% tab title="REST" %}

```bash
curl -X GET 'https://api.lootlocker.io/game/metadata/source/catalog_item/id/{ulid}?tags={tags}&ignore_files={bool}' \
    -H 'x-session-token: your_token_here' \
```

{% endtab %}
{% endtabs %}

## Conclusion

In this How-to we’ve fetched multiple metadata entries that were created in the [web console](https://console.lootlocker.com) by using tags. Metadata also provides the possibility to fetch a [single metadata](/shared-systems/metadata/how-to/fetch-a-single-metadata-in-game.md) in game or Fetch metadata in game from [multiple sources](/shared-systems/metadata/how-to/fetch-metadata-in-game-from-multiple-sources.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lootlocker.com/shared-systems/metadata/how-to/fetch-metadata-in-game-by-tags.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
