{
  "openapi": "3.1.0",
  "info": {
    "title": "TrueFPS API",
    "version": "1.0.0",
    "description": "JSON API used by the TrueFPS game FPS calculator and B2B ecommerce widget."
  },
  "servers": [
    {
      "url": "https://truefps.com",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/hardware": {
      "get": {
        "summary": "List hardware",
        "description": "Returns available CPUs, GPUs and valid CPU/GPU pairs.",
        "operationId": "listHardware",
        "responses": {
          "200": {
            "description": "Hardware lists and valid pairs.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HardwareResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/games": {
      "get": {
        "summary": "List games",
        "description": "Returns games and known minimum/recommended requirements.",
        "operationId": "listGames",
        "responses": {
          "200": {
            "description": "List of games.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Game"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/fps": {
      "get": {
        "summary": "Get FPS estimates",
        "description": "Returns FPS estimates grouped by game, resolution and graphics preset for a selected CPU/GPU pair.",
        "operationId": "getFps",
        "parameters": [
          {
            "name": "cpu_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "gpu_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "FPS estimates. Response shape may include per-game maps used by the web app.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid cpu_id/gpu_id."
          }
        }
      }
    },
    "/api/benchmarks": {
      "get": {
        "summary": "Search benchmark rows",
        "description": "Searches and filters benchmark rows with pagination.",
        "operationId": "searchBenchmarks",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cpu_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "gpu_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "game_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "resolution",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["720p", "1080p", "1440p", "2160p"]
            }
          },
          {
            "name": "preset",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": ["low", "medium", "high", "ultra"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Benchmark search result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/api/recommend": {
      "get": {
        "summary": "Get upgrade recommendations",
        "description": "Returns component upgrade recommendations for the selected hardware and game context.",
        "operationId": "getRecommendations",
        "parameters": [
          {
            "name": "cpu_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "gpu_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "component",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["cpu", "gpu"]
            }
          },
          {
            "name": "game_id",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "available_ids",
            "in": "query",
            "description": "Comma-separated merchant inventory component ids.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "available_names",
            "in": "query",
            "description": "Comma-separated merchant inventory component names for fuzzy matching.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Upgrade recommendation result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Missing or invalid required parameter."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "HardwareItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          }
        },
        "required": ["id", "name"]
      },
      "HardwarePair": {
        "type": "object",
        "properties": {
          "cpu_id": {
            "type": "integer"
          },
          "gpu_id": {
            "type": "integer"
          }
        },
        "required": ["cpu_id", "gpu_id"]
      },
      "HardwareResponse": {
        "type": "object",
        "properties": {
          "cpus": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HardwareItem"
            }
          },
          "gpus": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HardwareItem"
            }
          },
          "pairs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HardwarePair"
            }
          }
        },
        "required": ["cpus", "gpus", "pairs"]
      },
      "Game": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "min_cpu": {
            "type": "string"
          },
          "min_gpu": {
            "type": "string"
          },
          "rec_cpu": {
            "type": "string"
          },
          "rec_gpu": {
            "type": "string"
          }
        },
        "required": ["id", "name"]
      }
    }
  }
}
