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. HOW TO

Retrieve scores via API

PreviousIntegrate game via APINextAPIs

Last updated 1 year ago

Was this helpful?

To learn about how game objects are scored, learn about Classic Mode.

Getting game results

After a user plays a game, their scores are saved in your database. You can quickly retrieve the scored data using the API within your Console.

Here we're using the Games API to retrieve a player's scores for a specific game using /games/getPlayerScores

You can also retrieve all scored game objects for a particular user with the Game Objects resource. Get ranked Game Object results for a player using /game-objects/ranked

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 Ranked Results

get

Get ranked Game Object results for a player

Authorizations
Query parameters
playerIdstringRequired

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

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

Specify comma-separated input tags that will be used to score the game objects associated with the output tag.

If the output tag is included in the input tags, the player's score for those game object will be used as base scores

outputTagstringRequired

Specify the output tag of the game objects to get ranked results for

Responses
200
Successful response
application/json
default
Error response
application/json
get
GET /api/game-objects/ranked?playerId=text&inputTags=text&outputTag=text HTTP/1.1
Host: 
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
  "scores": [
    {
      "gameObject": {
        "id": "text",
        "name": "text"
      },
      "score": 1
    }
  ]
}
  • Getting game results
  • GETGet Player Scores
  • GETGet Ranked Results