{
    "openapi": "3.1.2",
    "info": {
        "title": "BalkTalk",
        "version": "1",
        "description": "BalkTalk public API for third-party apps. Documentation: https://www.balktalk.net/developeri"
    },
    "servers": [
        {
            "url": "https://www.balktalk.net/api/dev/v1"
        }
    ],
    "security": [
        {
            "http": []
        },
        {
            "http": []
        }
    ],
    "paths": {
        "/activity": {
            "post": {
                "operationId": "dev.activity.store",
                "description": "Lasts about two minutes - while the member plays, call it once a minute. Scope: `activity`.",
                "summary": "Member is using the app",
                "tags": [
                    "Activity"
                ],
                "responses": {
                    "204": {
                        "description": "No content"
                    }
                }
            },
            "delete": {
                "operationId": "dev.activity.destroy",
                "description": "Removes the \"is playing\" indicator right away. Scope: `activity`.",
                "summary": "Member stopped using the app",
                "tags": [
                    "Activity"
                ],
                "responses": {
                    "204": {
                        "description": "No content"
                    }
                }
            }
        },
        "/me": {
            "get": {
                "operationId": "dev.me",
                "description": "The member who granted access to the app. With the `profile` scope the response also carries their\npublic profile. Scope: `identity`.",
                "summary": "Signed-in member",
                "tags": [
                    "Identity"
                ],
                "responses": {
                    "200": {
                        "description": "`MemberResource`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/MemberResource"
                                        }
                                    },
                                    "required": [
                                        "data"
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
        "/users/{username}": {
            "get": {
                "operationId": "dev.users.show",
                "description": "By username. Returns 404 when the member does not exist or there is a block between them and the\nsigned-in member. Scope: `profile`.",
                "summary": "Public profile of a member",
                "tags": [
                    "Identity"
                ],
                "parameters": [
                    {
                        "name": "username",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "`MemberResource`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/MemberResource"
                                        }
                                    },
                                    "required": [
                                        "data"
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
        "/boards": {
            "get": {
                "operationId": "dev.boards.index",
                "description": "The boards created in the developer portal. An app only sees its own. Scope: `identity`.",
                "summary": "App leaderboards",
                "tags": [
                    "Score"
                ],
                "responses": {
                    "200": {
                        "description": "Array of `BoardResource`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/BoardResource"
                                            }
                                        }
                                    },
                                    "required": [
                                        "data"
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
        "/boards/{key}/scores": {
            "get": {
                "operationId": "dev.boards.scores.index",
                "description": "The best `limit` scores (default 20, at most 50) as the signed-in member sees them, and their own score\nwith its rank (`me` is null until they have a score). Scope: `identity`.",
                "summary": "Top of a leaderboard",
                "tags": [
                    "Score"
                ],
                "parameters": [
                    {
                        "name": "key",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": [
                                "integer",
                                "null"
                            ],
                            "minimum": 1,
                            "maximum": 50
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/ScoreResource"
                                            }
                                        },
                                        "me": {
                                            "anyOf": [
                                                {
                                                    "$ref": "#/components/schemas/ScoreResource"
                                                },
                                                {
                                                    "type": "null"
                                                }
                                            ]
                                        },
                                        "board": {
                                            "$ref": "#/components/schemas/BoardResource"
                                        }
                                    },
                                    "required": [
                                        "data",
                                        "me",
                                        "board"
                                    ]
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                }
            }
        },
        "/boards/{key}/scores/me": {
            "put": {
                "operationId": "dev.boards.scores.store",
                "description": "It is kept only if it beats their best (by the order of the board). `improved` tells whether this call\nset a new best. Scope: `scores`.",
                "summary": "Save a score for the signed-in member",
                "tags": [
                    "Score"
                ],
                "parameters": [
                    {
                        "name": "key",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "score": {
                                        "type": "integer",
                                        "description": "An integer; for a board with the `time` format, milliseconds",
                                        "minimum": -9007199254740991,
                                        "maximum": 9007199254740991
                                    }
                                },
                                "required": [
                                    "score"
                                ]
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/ScoreResource"
                                        },
                                        "improved": {
                                            "type": "boolean"
                                        }
                                    },
                                    "required": [
                                        "data",
                                        "improved"
                                    ]
                                }
                            }
                        }
                    },
                    "422": {
                        "$ref": "#/components/responses/ValidationException"
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "http": {
                "type": "http",
                "scheme": "bearer"
            }
        },
        "schemas": {
            "BoardFormat": {
                "type": "string",
                "description": "Prikaz rezultata: broj ili vrijeme (rezultat je u milisekundama)\n",
                "enum": [
                    "number",
                    "time"
                ],
                "title": "BoardFormat"
            },
            "BoardOrder": {
                "type": "string",
                "description": "Rang lista: veci rezultat je bolji (bodovi) ili manji (vrijeme)\n",
                "enum": [
                    "desc",
                    "asc"
                ],
                "title": "BoardOrder"
            },
            "BoardResource": {
                "type": "object",
                "properties": {
                    "key": {
                        "type": "string",
                        "description": "Board key in the address: /boards/{key}/scores"
                    },
                    "name": {
                        "type": "string"
                    },
                    "order": {
                        "description": "desc = a higher score is better, asc = a lower score is better",
                        "$ref": "#/components/schemas/BoardOrder"
                    },
                    "format": {
                        "description": "number = a number, time = milliseconds",
                        "$ref": "#/components/schemas/BoardFormat"
                    }
                },
                "required": [
                    "key",
                    "name",
                    "order",
                    "format"
                ],
                "title": "BoardResource"
            },
            "MemberResource": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer",
                        "description": "Permanent member number on BalkTalk"
                    },
                    "username": {
                        "type": "string"
                    },
                    "display_name": {
                        "type": "string"
                    },
                    "avatar_url": {
                        "type": "string",
                        "description": "Full address of the picture (a member without one has a default picture)"
                    },
                    "verified": {
                        "type": "boolean",
                        "description": "Verification badge: BalkTalk checked that the profile is a real person"
                    },
                    "profile_url": {
                        "type": "string"
                    },
                    "profile": {
                        "type": "object",
                        "description": "Public profile - only with the `profile` scope; a field the member does not show is null",
                        "properties": {
                            "about": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "age": {
                                "type": [
                                    "integer",
                                    "null"
                                ]
                            },
                            "gender": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "country_code": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "country_name": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "location": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "website": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            },
                            "joined_at": {
                                "type": [
                                    "string",
                                    "null"
                                ]
                            }
                        },
                        "required": [
                            "about",
                            "age",
                            "gender",
                            "country_code",
                            "country_name",
                            "location",
                            "website",
                            "joined_at"
                        ]
                    }
                },
                "required": [
                    "id",
                    "username",
                    "display_name",
                    "avatar_url",
                    "verified",
                    "profile_url"
                ],
                "title": "MemberResource"
            },
            "ScoreResource": {
                "type": "object",
                "properties": {
                    "rank": {
                        "type": "string",
                        "description": "Rank on the board (1 = first)"
                    },
                    "score": {
                        "type": "integer"
                    },
                    "achieved_at": {
                        "type": "string"
                    },
                    "user": {
                        "$ref": "#/components/schemas/MemberResource"
                    }
                },
                "required": [
                    "rank",
                    "score",
                    "achieved_at",
                    "user"
                ],
                "title": "ScoreResource"
            }
        },
        "responses": {
            "ValidationException": {
                "description": "Validation error",
                "content": {
                    "application/json": {
                        "schema": {
                            "type": "object",
                            "properties": {
                                "message": {
                                    "type": "string",
                                    "description": "Errors overview."
                                },
                                "errors": {
                                    "type": "object",
                                    "description": "A detailed description of each field that failed validation.",
                                    "additionalProperties": {
                                        "type": "array",
                                        "items": {
                                            "type": "string"
                                        }
                                    }
                                }
                            },
                            "required": [
                                "message",
                                "errors"
                            ]
                        }
                    }
                }
            }
        }
    }
}