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

Players

PreviousTagsNextAdmin

Was this helpful?

Get Player Count

get

Get player count

Authorizations
Responses
200
Successful response
application/json
default
Error response
application/json
get
GET /api/players/count HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "count": 1
}

Get Player by ID

get

Get player by ID

Authorizations
Path parameters
idstringRequired

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

Pattern: ^[a-zA-Z0-9_-]+$
Responses
200
Successful response
application/json
default
Error response
application/json
get
GET /api/players/{id} HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "player": {
    "id": "text",
    "name": "text",
    "createdAt": "text",
    "updatedAt": "text"
  }
}

Delete Player by ID

delete

Delete player by ID

Authorizations
Path parameters
idstringRequired

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

Pattern: ^[a-zA-Z0-9_-]+$
Responses
200
Successful response
application/json
default
Error response
application/json
delete
DELETE /api/players/{id} HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "deletedPlayer": {
    "id": "text",
    "name": "text",
    "createdAt": "text",
    "updatedAt": "text"
  }
}
  • POSTCreate Player
  • GETGet All Players
  • GETGet Player Count
  • GETGet Player by ID
  • PUTUpdate Player by ID
  • DELETEDelete Player by ID

Get All Players

get

Get all players

Authorizations
Responses
200
Successful response
application/json
default
Error response
application/json
get
GET /api/players HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "players": [
    {
      "id": "text",
      "name": "text",
      "createdAt": "text",
      "updatedAt": "text"
    }
  ]
}

Create Player

post

Creates a player with the given ID and an optional name. The ID must be unique, and ideally corresponds with a user ID used by the app integrating with 2bttns.

Authorizations
Body
idstringRequired

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

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

{
  "id": "text",
  "name": "text"
}
{
  "createdPlayer": {
    "id": "text",
    "name": "text",
    "createdAt": "text",
    "updatedAt": "text"
  }
}

Update Player by ID

put

Update player by 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/players/{id} HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 36

{
  "data": {
    "id": "text",
    "name": "text"
  }
}
{
  "updatedPlayer": {
    "id": "text",
    "name": "text",
    "createdAt": "text",
    "updatedAt": "text"
  }
}