{
  "openapi": "3.1.0",
  "info": {
    "title": "DeckTuner API",
    "version": "1.0.0",
    "description": "Public, read-only API for extracted game settings, benchmark recommendations and workspace files. No authentication required. Honor response Cache-Control headers; see /developer/api/usage for terms and caching."
  },
  "servers": [
    {
      "url": "https://api.decktuner.app/v1",
      "description": "Production"
    }
  ],
  "paths": {
    "/games/{steam_id}/recommendations": {
      "get": {
        "operationId": "get-games-{steam_id}-recommendations",
        "summary": "Get benchmarked recommendations and settings snapshots",
        "description": "Returns canonical benchmark settings and measured performance per device and FPS target, including completed below-target results. Apply is offered for achieved targets with captured settings snapshots.",
        "tags": [
          "Benchmarks"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "device",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Filter to a device ID"
            },
            "description": "Filter to a device ID",
            "example": "steam-deck-oled"
          },
          {
            "in": "path",
            "name": "steam_id",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[1-9]\\d*$"
            },
            "example": "123"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecommendationsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/recordings/{id}/settings": {
      "get": {
        "operationId": "get-recordings-{id}-settings",
        "summary": "Download captured benchmark settings",
        "description": "Returns the stored unified patch unchanged. X-Steam-App-ID identifies the validated recording's game.",
        "tags": [
          "Benchmarks"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[1-9]\\d*$"
            },
            "example": "123"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "text/x-diff": {
                "schema": {
                  "$ref": "#/components/schemas/SettingsSnapshotResponse"
                }
              }
            }
          }
        }
      }
    },
    "/devices": {
      "get": {
        "operationId": "get-devices",
        "summary": "List devices",
        "description": "Public catalogue of devices that DeckTuner tests against.",
        "tags": [
          "Devices"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DevicesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/games/{steam_id}/files": {
      "get": {
        "operationId": "get-games-{steam_id}-files",
        "summary": "List workspace files for a game",
        "description": "Files from the latest successful non-fresh run with saved workspace files. Responses may be cached for 30 seconds.",
        "tags": [
          "Files"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "steam_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Steam app ID"
            },
            "description": "Steam app ID",
            "example": "123"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceFilesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/runs/{run_id}/files": {
      "get": {
        "operationId": "get-runs-{run_id}-files",
        "summary": "List workspace files for a run",
        "description": "Files currently saved for this run. Responses may be cached for 30 seconds.",
        "tags": [
          "Files"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "run_id",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Run ID"
            },
            "description": "Run ID",
            "example": "5e9dab67eb02"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceFilesResponse"
                }
              }
            }
          }
        }
      }
    },
    "/runs/{run_id}/files/{path}": {
      "get": {
        "operationId": "get-runs-{run_id}-files-{path}",
        "summary": "Download a workspace file",
        "description": "Complete file bytes, including binary files. Responses may be cached for 30 seconds.",
        "tags": [
          "Files"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "run_id",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "Run ID"
            },
            "description": "Run ID",
            "example": "5e9dab67eb02"
          },
          {
            "in": "path",
            "name": "path",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "description": "File path within the workspace, including nested directories"
            },
            "description": "File path within the workspace, including nested directories",
            "example": "scripts/autoplay.py"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "$ref": "#/components/schemas/WorkspaceFileResponse"
                }
              }
            }
          }
        }
      }
    },
    "/games": {
      "get": {
        "operationId": "get-games",
        "summary": "List games with extracted settings",
        "description": "Paginated list of all games whose settings have been extracted, newest first.",
        "tags": [
          "Games"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "description": "Max items to return (1-100)",
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "description": "Max items to return (1-100)",
            "example": 1
          },
          {
            "in": "query",
            "name": "cursor",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Opaque cursor from a previous response's `next_cursor`"
            },
            "description": "Opaque cursor from a previous response's `next_cursor`",
            "example": "214490"
          },
          {
            "in": "query",
            "name": "updated_since",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only return games whose settings were extracted at or after this ISO timestamp"
            },
            "description": "Only return games whose settings were extracted at or after this ISO timestamp",
            "example": "2020-01-01T00:00:00Z"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GamesListResponse"
                }
              }
            }
          }
        }
      }
    },
    "/games/{steam_id}": {
      "get": {
        "operationId": "get-games-{steam_id}",
        "summary": "Get game details",
        "description": "Metadata for a single game plus the canonical (latest successful) run per device.",
        "tags": [
          "Games"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "steam_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Steam app ID"
            },
            "description": "Steam app ID",
            "example": "214490"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GameDetailResponse"
                }
              }
            }
          }
        }
      }
    },
    "/games/{steam_id}/settings": {
      "get": {
        "operationId": "get-games-{steam_id}-settings",
        "summary": "Get extracted settings for a game",
        "description": "Returns extracted menu settings from the latest successful test per device. Use `?device=` to narrow.",
        "tags": [
          "Games"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "device",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Filter to a single device ID (e.g. \"amd-bc-250\")"
            },
            "description": "Filter to a single device ID (e.g. \"amd-bc-250\")",
            "example": "amd-bc-250"
          },
          {
            "in": "path",
            "name": "steam_id",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Steam app ID"
            },
            "description": "Steam app ID",
            "example": "214490"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SettingsResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Benchmarks"
    },
    {
      "name": "Devices"
    },
    {
      "name": "Files"
    },
    {
      "name": "Games"
    }
  ],
  "components": {
    "schemas": {
      "Device": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Device identifier used as `device` in other endpoints"
          },
          "name": {
            "type": "string"
          },
          "family": {
            "type": "string",
            "description": "Device family, e.g. \"steam-deck\""
          },
          "icon": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether this device is currently in rotation"
          },
          "status": {
            "type": "string"
          },
          "battery_capacity_wh": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "name",
          "family",
          "icon",
          "description",
          "enabled",
          "status",
          "battery_capacity_wh"
        ]
      },
      "DeviceRun": {
        "type": "object",
        "properties": {
          "device": {
            "type": "string"
          },
          "run_id": {
            "type": "string"
          },
          "tested_at": {
            "type": "string"
          },
          "game_build": {
            "type": "string"
          },
          "proton_version": {
            "type": "string"
          },
          "steamos_version": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "menu_item_count": {
            "type": "integer"
          },
          "feature_count": {
            "type": "integer"
          }
        },
        "required": [
          "device",
          "run_id",
          "tested_at",
          "game_build",
          "proton_version",
          "steamos_version",
          "type",
          "menu_item_count",
          "feature_count"
        ]
      },
      "DeviceSettings": {
        "type": "object",
        "properties": {
          "device": {
            "type": "string"
          },
          "run_id": {
            "type": "string"
          },
          "tested_at": {
            "type": "string"
          },
          "game_build": {
            "type": "string"
          },
          "proton_version": {
            "type": "string"
          },
          "steamos_version": {
            "type": "string"
          },
          "type": {
            "type": "string"
          },
          "menu_item_count": {
            "type": "integer"
          },
          "feature_count": {
            "type": "integer"
          },
          "settings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Setting"
            }
          }
        },
        "required": [
          "device",
          "run_id",
          "tested_at",
          "game_build",
          "proton_version",
          "steamos_version",
          "type",
          "menu_item_count",
          "feature_count",
          "settings"
        ]
      },
      "DevicesResponse": {
        "type": "object",
        "properties": {
          "devices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Device"
            }
          }
        },
        "required": [
          "devices"
        ]
      },
      "GameDetailResponse": {
        "type": "object",
        "properties": {
          "steam_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "release_date": {
            "type": [
              "string",
              "null"
            ]
          },
          "publishers": {
            "type": [
              "string",
              "null"
            ]
          },
          "developers": {
            "type": [
              "string",
              "null"
            ]
          },
          "genres": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "website": {
            "type": [
              "string",
              "null"
            ]
          },
          "vote_count": {
            "type": "integer"
          },
          "last_settings_extraction_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_settings_extraction_run_build": {
            "type": [
              "string",
              "null"
            ]
          },
          "asset_portrait": {
            "type": [
              "string",
              "null"
            ]
          },
          "asset_header": {
            "type": [
              "string",
              "null"
            ]
          },
          "asset_hero": {
            "type": [
              "string",
              "null"
            ]
          },
          "devices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DeviceRun"
            },
            "description": "One entry per device with a successful run"
          }
        },
        "required": [
          "steam_id",
          "name",
          "release_date",
          "publishers",
          "developers",
          "genres",
          "description",
          "website",
          "vote_count",
          "last_settings_extraction_at",
          "last_settings_extraction_run_build",
          "asset_portrait",
          "asset_header",
          "asset_hero",
          "devices"
        ]
      },
      "GameFilesParams": {
        "type": "object",
        "properties": {
          "steam_id": {
            "type": "string",
            "description": "Steam app ID"
          }
        },
        "required": [
          "steam_id"
        ]
      },
      "GameParams": {
        "type": "object",
        "properties": {
          "steam_id": {
            "type": "string",
            "description": "Steam app ID",
            "examples": [
              "214490"
            ]
          }
        },
        "required": [
          "steam_id"
        ]
      },
      "GamesListQuery": {
        "type": "object",
        "properties": {
          "limit": {
            "default": 50,
            "description": "Max items to return (1-100)",
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "cursor": {
            "type": "string",
            "description": "Opaque cursor from a previous response's `next_cursor`",
            "examples": [
              "214490"
            ]
          },
          "updated_since": {
            "type": "string",
            "format": "date-time",
            "description": "Only return games whose settings were extracted at or after this ISO timestamp",
            "examples": [
              "2020-01-01T00:00:00Z"
            ]
          }
        }
      },
      "GamesListResponse": {
        "type": "object",
        "properties": {
          "games": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GameSummary"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass to `cursor` on the next request; null when exhausted"
          }
        },
        "required": [
          "games",
          "next_cursor"
        ]
      },
      "GameSummary": {
        "type": "object",
        "properties": {
          "steam_id": {
            "type": "string",
            "description": "Steam app ID (numeric string for real games)"
          },
          "name": {
            "type": "string"
          },
          "last_settings_extraction_at": {
            "type": [
              "string",
              "null"
            ],
            "description": "ISO 8601 timestamp of the latest successful settings extraction"
          },
          "asset_portrait": {
            "type": [
              "string",
              "null"
            ],
            "description": "URL to portrait-aspect cover art"
          },
          "asset_header": {
            "type": [
              "string",
              "null"
            ],
            "description": "URL to header-aspect banner art"
          }
        },
        "required": [
          "steam_id",
          "name",
          "last_settings_extraction_at",
          "asset_portrait",
          "asset_header"
        ]
      },
      "RecommendationSchema": {
        "type": "object",
        "properties": {
          "recording_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "run_id": {
            "type": "string"
          },
          "device": {
            "type": "string"
          },
          "device_name": {
            "type": "string"
          },
          "official": {
            "type": "boolean"
          },
          "game_build": {
            "type": "string"
          },
          "proton_version": {
            "type": "string"
          },
          "target_fps": {
            "type": "integer"
          },
          "target_achieved": {
            "type": "boolean"
          },
          "preset": {
            "type": [
              "string",
              "null"
            ]
          },
          "avg_fps": {
            "type": [
              "number",
              "null"
            ]
          },
          "one_percent_low": {
            "type": [
              "number",
              "null"
            ]
          },
          "settings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TestedSettingSchema"
            }
          },
          "apply": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "url": {
                "type": "string"
              },
              "sha256": {
                "type": "string",
                "pattern": "^[a-f0-9]{64}$"
              }
            },
            "required": [
              "url",
              "sha256"
            ]
          }
        },
        "required": [
          "recording_id",
          "run_id",
          "device",
          "device_name",
          "official",
          "game_build",
          "proton_version",
          "target_fps",
          "target_achieved",
          "preset",
          "avg_fps",
          "one_percent_low",
          "settings",
          "apply"
        ]
      },
      "RecommendationsPath": {
        "type": "object",
        "properties": {
          "steam_id": {
            "type": "string",
            "pattern": "^[1-9]\\d*$"
          }
        },
        "required": [
          "steam_id"
        ]
      },
      "RecommendationsQuery": {
        "type": "object",
        "properties": {
          "device": {
            "type": "string",
            "description": "Filter to a device ID",
            "examples": [
              "steam-deck-oled"
            ]
          }
        }
      },
      "RecommendationsResponse": {
        "type": "object",
        "properties": {
          "steam_id": {
            "type": "string"
          },
          "recommendations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecommendationSchema"
            }
          }
        },
        "required": [
          "steam_id",
          "recommendations"
        ]
      },
      "RunFilesParams": {
        "type": "object",
        "properties": {
          "run_id": {
            "type": "string",
            "minLength": 1,
            "description": "Run ID",
            "examples": [
              "5e9dab67eb02"
            ]
          }
        },
        "required": [
          "run_id"
        ]
      },
      "Setting": {
        "type": "object",
        "properties": {
          "category": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "value": {
            "type": "string"
          },
          "raw_ocr": {
            "type": "string"
          },
          "display_order": {
            "type": "integer"
          },
          "feature_key": {
            "type": "string",
            "description": "Cross-game key of the tracked setting this maps to, or empty when untracked"
          },
          "feature_label": {
            "type": "string",
            "description": "Short human label for `feature_key`, or empty when untracked"
          },
          "screenshot_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "highlight": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "x": {
                "type": "integer"
              },
              "y": {
                "type": "integer"
              },
              "w": {
                "type": "integer"
              },
              "h": {
                "type": "integer"
              }
            },
            "required": [
              "x",
              "y",
              "w",
              "h"
            ],
            "description": "Bounding box within `screenshot_url` highlighting this setting"
          }
        },
        "required": [
          "category",
          "name",
          "value",
          "raw_ocr",
          "display_order",
          "feature_key",
          "feature_label",
          "screenshot_url",
          "highlight"
        ]
      },
      "SettingsPathParams": {
        "type": "object",
        "properties": {
          "steam_id": {
            "type": "string",
            "description": "Steam app ID",
            "examples": [
              "214490"
            ]
          }
        },
        "required": [
          "steam_id"
        ]
      },
      "SettingsQuery": {
        "type": "object",
        "properties": {
          "device": {
            "type": "string",
            "description": "Filter to a single device ID (e.g. \"amd-bc-250\")",
            "examples": [
              "amd-bc-250"
            ]
          }
        }
      },
      "SettingsResponse": {
        "type": "object",
        "properties": {
          "steam_id": {
            "type": "string"
          },
          "devices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DeviceSettings"
            }
          }
        },
        "required": [
          "steam_id",
          "devices"
        ]
      },
      "SettingsSnapshotPath": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[1-9]\\d*$"
          }
        },
        "required": [
          "id"
        ]
      },
      "SettingsSnapshotResponse": {
        "$ref": "#/components/schemas/SettingsSnapshotSchema"
      },
      "SettingsSnapshotSchema": {
        "type": "string",
        "minLength": 1
      },
      "TestedSettingSchema": {
        "type": "object",
        "properties": {
          "category": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "value": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "category",
          "name",
          "value"
        ],
        "additionalProperties": false
      },
      "WorkspaceFileParams": {
        "type": "object",
        "properties": {
          "run_id": {
            "type": "string",
            "minLength": 1,
            "description": "Run ID",
            "examples": [
              "5e9dab67eb02"
            ]
          },
          "path": {
            "type": "string",
            "minLength": 1,
            "description": "File path within the workspace, including nested directories",
            "examples": [
              "scripts/autoplay.py"
            ]
          }
        },
        "required": [
          "run_id",
          "path"
        ]
      },
      "WorkspaceFileResponse": {
        "type": "string",
        "contentMediaType": "application/octet-stream"
      },
      "WorkspaceFilesResponse": {
        "type": "object",
        "properties": {
          "run_id": {
            "type": "string"
          },
          "source_run_id": {
            "type": "string"
          },
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string"
                },
                "size": {
                  "type": "integer",
                  "minimum": 0,
                  "description": "Size in bytes"
                },
                "mode": {
                  "type": "integer"
                },
                "sha256": {
                  "type": "string"
                },
                "runtime": {
                  "type": "boolean"
                },
                "download_url": {
                  "type": "string",
                  "format": "uri",
                  "description": "Public API URL for the complete file bytes"
                }
              },
              "required": [
                "path",
                "size",
                "mode",
                "sha256",
                "runtime",
                "download_url"
              ]
            }
          }
        },
        "required": [
          "run_id",
          "source_run_id",
          "files"
        ]
      }
    },
    "responses": {}
  }
}
