2bttns
  • Getting Started
    • What is 2bttns?
    • Quick Start
    • 🆕You Asked We Listened
  • HOW TO
    • Set up your Console
    • Use the API
    • Build a game
    • Manage game data
    • Integrate game via API
    • Retrieve scores via API
  • References
    • APIs
      • Authentication
      • Generate Game URL
      • Games
      • Game Objects
      • Tags
      • Players
      • Admin
      • Export/Import
    • Command Line Interface (CLI)
      • Install
      • Usage
      • Configuration
  • TUTORIALS
    • ✨Personalize profiles with 2bttns and Next.js
Powered by GitBook
On this page

Was this helpful?

  1. References
  2. APIs

Games

PreviousGenerate Game URLNextGame Objects

Was this helpful?

Get Player Scores

get

Get a Player's score data for a specific Game.

Authorizations
Query parameters
game_idstringRequired

The game id to get scores for

Pattern: ^[a-zA-Z0-9_-]+$
player_idstringRequired

The player id to get scores for

Pattern: ^[a-zA-Z0-9_-]+$
include_game_objectsbooleanOptional

Whether to include game objects in the response

Default: false
Responses
200
Successful response
application/json
default
Error response
application/json
get
GET /api/games/getPlayerScores?game_id=text&player_id=text HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "playerScores": [
    {
      "createdAt": "text",
      "updatedAt": "text",
      "score": 1,
      "playerId": "text",
      "gameObjectId": "text",
      "gameObject": {
        "id": "text",
        "createdAt": "text",
        "updatedAt": "text",
        "name": "text",
        "description": "text"
      }
    }
  ]
}

Get All Games

get

Get all Games. Paginated by default. Supports filtering and sorting.

Authorizations
Query parameters
takeany ofOptionalDefault: 10
notOptional
or
numberOptional
skipany ofOptionalDefault: 0
notOptional
or
numberOptional
idFilterany ofOptional

Comma-separated Game IDs to filter by

notOptional
or
string[]Optional
allowFuzzyIdFilterbooleanOptional

Set to true to enable fuzzy ID filtering. If false, only returns exact matches.

Default: false
nameFilterany ofOptional

Comma-separated Game names to filter by

notOptional
or
string[]Optional
allowFuzzyNameFilterbooleanOptional

Set to true to enable fuzzy name filtering. If false, only returns exact matches.

Default: false
tagFilterany ofOptional

Comma-separated list of input tag IDs the resulting game must have

notOptional
or
string[]Optional
tagExcludeFilterany ofOptional

Comma-separated list of input tag IDs to exclude from the response. Use this to exclude games that have a specific input tag, even if they match the requiredTags filter.

notOptional
or
string[]Optional
untaggedFilterstring · enumOptional

include: Include all games, regardless of whether they have input tags or not.

exclude: Exclude games that have no input tags.

untagged-only: Only return games that have no input tags. Setting this option will ignore requiredTags and excludeTags, since tagged items shouldn't appear in the results.

Default: includePossible values:
sortFieldstring · enumOptional

Field to sort by

Possible values:
sortOrderstring · enumOptional

Sort order for the selected field

Possible values:
includeTagDatabooleanOptional

Set to true to include additional tags info in the response

Default: false
excludeGamesany ofOptional

Comma-separated list of Game IDs to exclude from the response

notOptional
or
string[]Optional
Responses
200
Successful response
application/json
default
Error response
application/json
get
GET /api/games HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "games": [
    {
      "id": "text",
      "name": "text",
      "description": "text",
      "createdAt": "text",
      "updatedAt": "text",
      "inputTags": [
        "text"
      ],
      "mode": "text",
      "customCss": "text"
    }
  ],
  "tags": [
    {
      "id": "text",
      "name": "text",
      "description": "text",
      "createdAt": "text",
      "updatedAt": "text"
    }
  ]
}

Delete Games

delete

Delete one or more Games by their IDs

Authorizations
Query parameters
idstring[]Optional
Responses
200
Successful response
application/json
default
Error response
application/json
delete
DELETE /api/games HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "deletedCount": 1
}

Get Game Count

get

Get Game Count

Authorizations
Query parameters
idFilterany ofOptional

Comma-separated Game IDs to filter by

notOptional
or
string[]Optional
allowFuzzyIdFilterbooleanOptional

Set to true to enable fuzzy ID filtering. If false, only returns exact matches.

Default: false
nameFilterany ofOptional

Comma-separated Game names to filter by

notOptional
or
string[]Optional
allowFuzzyNameFilterbooleanOptional

Set to true to enable fuzzy name filtering. If false, only returns exact matches.

Default: false
tagFilterany ofOptional

Comma-separated list of input tag IDs the resulting game must have

notOptional
or
string[]Optional
tagExcludeFilterany ofOptional

Comma-separated list of input tag IDs to exclude from the response. Use this to exclude games that have a specific input tag, even if they match the requiredTags filter.

notOptional
or
string[]Optional
untaggedFilterstring · enumOptional

include: Include all games, regardless of whether they have input tags or not.

exclude: Exclude games that have no input tags.

untagged-only: Only return games that have no input tags. Setting this option will ignore requiredTags and excludeTags, since tagged items shouldn't appear in the results.

Default: includePossible values:
excludeGamesany ofOptional

Comma-separated list of Game IDs to exclude from the response

notOptional
or
string[]Optional
Responses
200
Successful response
application/json
default
Error response
application/json
get
GET /api/games/count HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "count": 1
}

Get Game by ID

get

Get a game by its ID.

Authorizations
Path parameters
idstringRequired

ID value. Only alphanumeric, underscore, and hyphen are allowed.

Pattern: ^[a-zA-Z0-9_-]+$
Query parameters
includeGameObjectsany ofOptionalDefault: false
notOptional
or
booleanOptionalDefault: false
Responses
200
Successful response
application/json
default
Error response
application/json
get
GET /api/games/{id} HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "game": {
    "id": "text",
    "name": "text",
    "description": "text",
    "createdAt": "text",
    "updatedAt": "text",
    "inputTags": [
      {
        "id": "text",
        "createdAt": "text",
        "updatedAt": "text",
        "name": "text",
        "description": "text"
      }
    ],
    "defaultNumItemsPerRound": 1,
    "mode": "text",
    "modeConfigJson": "text",
    "customCss": "text",
    "gameObjects": [
      {
        "id": "text",
        "name": "text",
        "description": "text",
        "createdAt": "text",
        "updatedAt": "text"
      }
    ]
  }
}
  • GETGet Player Scores
  • GETGet All Games
  • POSTCreate Game
  • DELETEDelete Games
  • GETGet Game Count
  • GETGet Game by ID
  • PUTUpdate Game by ID

Create Game

post

Create a new Game

Authorizations
Body
idstringOptional

ID value. Only alphanumeric, underscore, and hyphen are allowed.

Pattern: ^[a-zA-Z0-9_-]+$
namestringRequired
descriptionstringOptional
Responses
200
Successful response
application/json
default
Error response
application/json
post
POST /api/games HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 48

{
  "id": "text",
  "name": "text",
  "description": "text"
}
{
  "createdGame": {
    "id": "text",
    "name": "text",
    "description": "text",
    "createdAt": "text",
    "updatedAt": "text",
    "mode": "text"
  }
}

Update Game by ID

put

Update a Game by its ID

Authorizations
Path parameters
idstringRequired

ID value. Only alphanumeric, underscore, and hyphen are allowed.

Pattern: ^[a-zA-Z0-9_-]+$
Body
Responses
200
Successful response
application/json
default
Error response
application/json
put
PUT /api/games/{id} HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 163

{
  "data": {
    "id": "text",
    "name": "text",
    "description": "text",
    "inputTags": [
      "text"
    ],
    "defaultNumItemsPerRound": 1,
    "mode": "text",
    "modeConfigJson": "text",
    "customCss": "text"
  }
}
{
  "updatedGameObject": {
    "id": "text",
    "createdAt": "text",
    "updatedAt": "text",
    "name": "text",
    "description": "text",
    "defaultNumItemsPerRound": 1,
    "mode": "text",
    "modeConfigJson": "text",
    "customCss": "text"
  }
}