Chess Challenger 2

Chess Challenger 2 · Ações GPT

Chess API

This API provides services to validate chess moves, initialize the board, and update the board state.

  • POST /initialize_fenInitializes the board in FEN format
  • PUT /validate_move_and_update_fenUpdates the current FEN based on a move in SAN format
  • POST /get_fen_for_gameComputes the FEN notation for a game given a sequence of moves
  • GET /draw_chessboardGenerates an image of the chessboard and returns a URL to the image along with the game state.
Esquema API original
{
  "openapi": "3.1.0",
  "info": {
    "title": "Chess API",
    "description": "This API provides services to validate chess moves, initialize the board, and update the board state.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://chessmovemanagement.ranbysoftware.com",
      "description": "Production server"
    }
  ],
  "paths": {
    "/initialize_fen": {
      "post": {
        "operationId": "initializeFen",
        "summary": "Initializes the board in FEN format",
        "x-openai-isConsequential": false,
        "responses": {
          "200": {
            "description": "Returns initial FEN notation of the chess board",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fen": {
                      "type": "string",
                      "description": "Standard FEN notation of the chess board's initial state"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/validate_move_and_update_fen": {
      "put": {
        "operationId": "updateFen",
        "summary": "Updates the current FEN based on a move in SAN format",
        "x-openai-isConsequential": false,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FenUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validates the move and, if valid, returns the updated FEN after applying the move",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "valid": {
                      "type": "boolean",
                      "description": "True if the move is valid, False otherwise"
                    },
                    "updated": {
                      "type": "boolean",
                      "description": "True if the FEN is updated"
                    },
                    "fen": {
                      "type": "string",
                      "description": "Updated FEN of the chess board after the move"
                    },
                    "message": {
                      "type": "string",
                      "description": "Message highlighting any problems with the update"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/get_fen_for_game": {
      "post": {
        "operationId": "getFenForGame",
        "summary": "Computes the FEN notation for a game given a sequence of moves",
        "x-openai-isConsequential": false,
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChessGame"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns the FEN notation after applying all provided moves",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "fen": {
                      "type": "string",
                      "description": "FEN notation of the chess board after applying the moves"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    },
    "/draw_chessboard": {
      "get": {
        "operationId": "drawChessBoard",
        "summary": "Generates an image of the chessboard and returns a URL to the image along with the game state.",
        "x-openai-isConsequential": false,
        "parameters": [
          {
            "name": "fen",
            "in": "query",
            "description": "FEN string representing the current state of the chess board.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "player_is_playing_white",
            "in": "query",
            "description": "Boolean flag indicating if the player is playing as white.",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully returned a URL to the chessboard image and additional game state information.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "chess_board_image_url": {
                      "type": "string",
                      "format": "uri",
                      "description": "URL to the PNG image of the chess board. This URL is a presigned URL allowing temporary access."
                    },
                    "chess_board_ascii": {
                      "type": "string",
                      "description": "ASCII representation of the chess board."
                    },
                    "chess_board_state": {
                      "type": "string",
                      "description": "The current FEN notation of the chess board."
                    },
                    "is_check": {
                      "type": "boolean",
                      "description": "Indicates if the current board position is a check."
                    },
                    "is_checkmate": {
                      "type": "boolean",
                      "description": "Indicates if the current board position is a checkmate."
                    },
                    "legal_moves": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "List of legal moves from the current position in UCI format."
                    },
                    "player_to_move": {
                      "type": "string",
                      "description": "Indicates which player's turn it is to move ('white' or 'black')."
                    },
                    "player_is_playing": {
                      "type": "string",
                      "description": "Indicates if the player is playing as 'white' or 'black'."
                    },
                    "chess_challenger_is_playing": {
                      "type": "string",
                      "description": "Indicates if the Chess Challenger AI is playing as 'white' or 'black'."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error when generating the chessboard image or processing the game data.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string",
                      "description": "Error message detailing the cause of the failure."
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "ChessGame": {
        "type": "object",
        "required": [
          "moves"
        ],
        "properties": {
          "moves": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "A series of chess moves in standard notation (e.g., ['e2e4', 'e7e5'])"
          }
        }
      },
      "ChessMove": {
        "type": "object",
        "properties": {
          "fen": {
            "type": "string",
            "description": "Current board state in FEN notation"
          },
          "move": {
            "type": "string",
            "description": "Chess move in standard notation (e.g., 'e2e4')"
          }
        }
      },
      "FenUpdate": {
        "type": "object",
        "required": [
          "fen",
          "move"
        ],
        "properties": {
          "fen": {
            "type": "string",
            "description": "FEN notation of the current board state before the move."
          },
          "move": {
            "type": "string",
            "description": "Chess move in SAN format to be applied to the FEN."
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    }
  }
}