# Manage game data

## Create new Game Objects

<figure><img src="/files/8B4ogBhbiXaz26KCw6RT" alt="" width="563"><figcaption><p>Game Objects page</p></figcaption></figure>

You can quickly create Game Objects through the Console. Simply navigate to Game Objects, enter the name of your Game Object using `shift`+`enter`.

## Group objects into Tags

Next, you'll need to organize our Game Objects into Tags, which are collections of Game Objects. Group objects into Tags to input them into Games later on.

You can then load your Tags as inputs into games. Let's create a Tag under Tags page&#x20;

<figure><img src="/files/FfsnW6UG6rHQn1MIRi47" alt=""><figcaption><p>Create a Tag under the Tags page by clicking <code>shift</code> + <code>enter</code></p></figcaption></figure>

#### Input tagged objects into game

After creating our Tag, tag them by returning to the Game Objects page, bulk selecting, selecting the `Hobbies` tag, and then load them as inputs into our `hobbies-ranker` game. &#x20;

## Importing data

### Prepare your records

Your data must be in a format the 2bttns platform can understand. Once you've decided on your game objects, we'll need to prepare your records for import.&#x20;

### Format your JSON

Already have data you'd like to input into 2bttns? Let's walk through how to format your data to import through API or the Console interface.

{% hint style="danger" %}
Your JSON must contain a `name` equivalent field. These values are loaded as choices within your Game buttons. Fields not represented in the Game Objects model are ignored. See [Example](https://www.npmjs.com/package/@2bttns/objects#example) for more information.
{% endhint %}

{% code title="Import JSON Structure " %}

```typescript
 const outputShape: OutputShape = { gameObjects: [
    {
      id: '',
      name: '', // REQUIRED
      description: '',
      tagIds: []
    }
  ],
  tags: [
    {
      id: '',
      name: '',
      description: ''
    }
  ]
};
```

{% endcode %}

{% code title="Game Object Type" %}

```typescript
interface GameObject {
  id: string;
  name: string;
  description: string;
  tagIds: string[];
  [key: string]: any;
}
```

{% endcode %}

### How 2bttns Helps

We've got you covered. 2bttns comes with a Formatter to effortlessly transform any JSON into the specified data model.

#### Using the formatter

**Example: Personalize Coffee Shop Drinks to Moods ☕️ 😁**

You're building a creative coffee shop experience where the menu dynamically adapts to how customers are feeling. Using 2bttns, we can categorize menu items by mood, ensuring each customer finds the perfect drink to match their current state of mind.&#x20;

{% code title="drinks-moods.json" %}

```json
{
    "coffee_shop_drinks": [
        {
            "mood": "Energetic",
            "drinks": [
                "Espresso",
                "Iced Coffee",
                "Cold Brew"
            ]
        },
        {
            "mood": "Focused",
            "drinks": [
                "Espresso",
                "Latte",
                "Iced Coffee"
            ]
        },
        {
            "mood": "Relaxed",
            "drinks": [
                "Cappuccino",
                "Latte"
            ]
        },
        {
            "mood": "Content",
            "drinks": [
                "Cappuccino",
                "Iced Latte"
            ]
        },
        ...
    ]
}
```

{% endcode %}

Run the following script anywhere to use the Formatter

```bash
npx @2bttns/objects
```

<figure><img src="/files/gJqkoWJeZ5lyBRGVLguU" alt="" width="563"><figcaption><p>Running the @2bttns/objects formatter script</p></figcaption></figure>

After selecting <mark style="color:blue;">Format Data</mark>, pass in your JSON&#x20;

{% code title="Formatter prompt" overflow="wrap" %}

```bash
? 📁 Enter the path of the input JSON file:
› /Users/you/Downloads/drinks-mood.json
```

{% endcode %}

Input the path to the list object in your JSON containing your Game Objects. In this case, `coffee_shop_drinks` is the object containing our list of Moods objects:

{% code title="Formatter prompt" overflow="wrap" %}

```
✔ 🔍 Select the path in JSON where the data to be converted is located:
· coffee_shop_drinks
```

{% endcode %}

The Formatter will ask you questions to create a ready-to-upload JSON. Here's how it works:

{% code title="Formatter prompts" overflow="wrap" %}

```
✔ ⭐️ Which key in your JSON corresponds to "id" with value type "string"?
 👉 Enter "none" if none exists. 
 · none
 
✔ ⭐️ Which key in your JSON corresponds to "name" with value type "string"?
 👉 Enter "none" if none exists.
 · mood

✔ ⭐️ Which key in your JSON corresponds to "description" with value type "string"?
 👉 Enter "none" if none exists.
 · none

✔ ⭐️ Which key in your JSON corresponds to "tagIds" with value type "object"?
 👉 Enter "none" if none exists.
 · none

✔ 📁 Enter the path where you want to save the output JSON file (e.g., /your/path/name/): 
 press ENTER for current directory
 · /Users/you/Downloads

✔ 📁 Enter the output file name (e.g., my-output.json):
· output.json

✅ Output JSON file saved successfully! ✅

```

{% endcode %}

Here's an outline of each field and its corresponding data mapping:

<table><thead><tr><th width="178">Key</th><th width="128">Value</th><th>Definition</th></tr></thead><tbody><tr><td><code>id</code></td><td>string</td><td>A unique uuid representing a game object. Formatter will generate one if none.</td></tr><tr><td><code>name</code></td><td>string<mark style="color:red;">*</mark></td><td>The name of game object. This is what users see and score when playing a round of 2bttns.</td></tr><tr><td><code>description</code></td><td>string</td><td>A description of the game object </td></tr><tr><td><code>tagIds</code></td><td>object</td><td>Each ID corresponds to the parent collection that a game object is part of. You can group Game Objects into Tags using the Console.</td></tr></tbody></table>

*<mark style="color:red;">\*Required</mark>*

Viola! 🪄 And here's the resulting output JSON:

{% code title="ready-to-upload.json" %}

```json
{
  "gameObjects": [
    {
      "id": "clso4o94h0001xk9sfsjwdf0q",
      "name": "Focused",
      "description": "",
      "tagIds": []
    },
    {
      "id": "clso4o94h0004xk9sgbw84w0i",
      "name": "Comforted",
      "description": "",
      "tagIds": []
    },
    {
      "id": "clso4o94h0007xk9shfrm4izk",
      "name": "Reflective",
      "description": "",
      "tagIds": []
    },
    ...
  ],
  "tags": [
    {
      "id": "",
      "name": "",
      "description": ""
    }
  ]
}

```

{% endcode %}

### How to import

You can import your data either through API/SDK or the Console interface.&#x20;

#### Import with Console

You can drag and drop your JSON of Game Objects in. Navigate to your Console and click on the Actions button.

<figure><img src="/files/Z6XhzfOaIVb7vQaWSpIu" alt="" width="563"><figcaption><p>Console > Game Objects > Actions > Import from JSON</p></figcaption></figure>

#### Import with API

You can also import your JSON through the API using the following endpoint:

{% openapi src="/files/kCwNyeiyMRxJvhZ934kk" path="/import-data" method="post" %}
[openapi.json](https://content.gitbook.com/content/n2L7ltGlCAKlpbJZ3edj/blobs/489xqKU5WXWpX6Dz2H47/openapi.json)
{% endopenapi %}


---

# 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.2bttns.com/how-to/manage-game-data.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.
