{
  "openapi": "3.1.0",
  "info": {
    "title": "Bitcofy T-MARKET REST API",
    "description": "Spot trading API. All financial values use decimal strings. No withdrawals or account transfers.",
    "version": "1.0.0"
  },
  "paths": {
    "/api/t-market/v1/time": {
      "get": {
        "summary": "Server Time",
        "operationId": "server_time_api_t_market_v1_time_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Invalid parameters, increments or operation ID"
          },
          "401": {
            "description": "Missing, expired, revoked or invalid key"
          },
          "403": {
            "description": "Read-only key or restricted account"
          },
          "404": {
            "description": "Unknown or unowned order/command"
          },
          "409": {
            "description": "Idempotency conflict or engine rejection"
          },
          "413": {
            "description": "Request body exceeds 16 KiB"
          },
          "429": {
            "description": "Rate/concurrency limit. Observe Retry-After."
          },
          "503": {
            "description": "Temporarily unavailable or confirmation unknown. Retry the identical command ID."
          }
        },
        "parameters": []
      }
    },
    "/api/t-market/v1/markets": {
      "get": {
        "summary": "Markets",
        "operationId": "markets_api_t_market_v1_markets_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Invalid parameters, increments or operation ID"
          },
          "401": {
            "description": "Missing, expired, revoked or invalid key"
          },
          "403": {
            "description": "Read-only key or restricted account"
          },
          "404": {
            "description": "Unknown or unowned order/command"
          },
          "409": {
            "description": "Idempotency conflict or engine rejection"
          },
          "413": {
            "description": "Request body exceeds 16 KiB"
          },
          "429": {
            "description": "Rate/concurrency limit. Observe Retry-After."
          },
          "503": {
            "description": "Temporarily unavailable or confirmation unknown. Retry the identical command ID."
          }
        },
        "parameters": []
      }
    },
    "/api/t-market/v1/book": {
      "get": {
        "summary": "Book",
        "operationId": "book_api_t_market_v1_book_get",
        "parameters": [
          {
            "name": "market",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Market"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 200,
              "minimum": 1,
              "default": 100,
              "title": "Limit"
            }
          },
          {
            "name": "after_bid_price_ticks",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "maximum": 9223372036854775807,
                  "exclusiveMinimum": 0
                },
                {
                  "type": "null"
                }
              ],
              "title": "After Bid Price Ticks"
            }
          },
          {
            "name": "after_ask_price_ticks",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "maximum": 9223372036854775807,
                  "exclusiveMinimum": 0
                },
                {
                  "type": "null"
                }
              ],
              "title": "After Ask Price Ticks"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters, increments or operation ID"
          },
          "401": {
            "description": "Missing, expired, revoked or invalid key"
          },
          "403": {
            "description": "Read-only key or restricted account"
          },
          "404": {
            "description": "Unknown or unowned order/command"
          },
          "409": {
            "description": "Idempotency conflict or engine rejection"
          },
          "413": {
            "description": "Request body exceeds 16 KiB"
          },
          "429": {
            "description": "Rate/concurrency limit. Observe Retry-After."
          },
          "503": {
            "description": "Temporarily unavailable or confirmation unknown. Retry the identical command ID."
          }
        }
      }
    },
    "/api/t-market/v1/trades": {
      "get": {
        "summary": "Trades",
        "operationId": "trades_api_t_market_v1_trades_get",
        "parameters": [
          {
            "name": "market",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Market"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 500,
              "minimum": 1,
              "default": 100,
              "title": "Limit"
            }
          },
          {
            "name": "before_sequence",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "maximum": 9223372036854775807,
                  "minimum": 1
                },
                {
                  "type": "null"
                }
              ],
              "title": "Before Sequence"
            }
          },
          {
            "name": "before_fill_index",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "maximum": 2147483647,
                  "minimum": 0
                },
                {
                  "type": "null"
                }
              ],
              "title": "Before Fill Index"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters, increments or operation ID"
          },
          "401": {
            "description": "Missing, expired, revoked or invalid key"
          },
          "403": {
            "description": "Read-only key or restricted account"
          },
          "404": {
            "description": "Unknown or unowned order/command"
          },
          "409": {
            "description": "Idempotency conflict or engine rejection"
          },
          "413": {
            "description": "Request body exceeds 16 KiB"
          },
          "429": {
            "description": "Rate/concurrency limit. Observe Retry-After."
          },
          "503": {
            "description": "Temporarily unavailable or confirmation unknown. Retry the identical command ID."
          }
        }
      }
    },
    "/api/t-market/v1/candles": {
      "get": {
        "summary": "Candles",
        "operationId": "candles_api_t_market_v1_candles_get",
        "parameters": [
          {
            "name": "market",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Market"
            }
          },
          {
            "name": "seconds",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "default": 60,
              "title": "Seconds"
            }
          },
          {
            "name": "before_ms",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "maximum": 9223372036854775807,
                  "minimum": 1
                },
                {
                  "type": "null"
                }
              ],
              "title": "Before Ms"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 1000,
              "minimum": 1,
              "default": 500,
              "title": "Limit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters, increments or operation ID"
          },
          "401": {
            "description": "Missing, expired, revoked or invalid key"
          },
          "403": {
            "description": "Read-only key or restricted account"
          },
          "404": {
            "description": "Unknown or unowned order/command"
          },
          "409": {
            "description": "Idempotency conflict or engine rejection"
          },
          "413": {
            "description": "Request body exceeds 16 KiB"
          },
          "429": {
            "description": "Rate/concurrency limit. Observe Retry-After."
          },
          "503": {
            "description": "Temporarily unavailable or confirmation unknown. Retry the identical command ID."
          }
        }
      }
    },
    "/api/t-market/v1/account": {
      "get": {
        "summary": "Account",
        "operationId": "account_api_t_market_v1_account_get",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters, increments or operation ID"
          },
          "401": {
            "description": "Missing, expired, revoked or invalid key"
          },
          "403": {
            "description": "Read-only key or restricted account"
          },
          "404": {
            "description": "Unknown or unowned order/command"
          },
          "409": {
            "description": "Idempotency conflict or engine rejection"
          },
          "413": {
            "description": "Request body exceeds 16 KiB"
          },
          "429": {
            "description": "Rate/concurrency limit. Observe Retry-After."
          },
          "503": {
            "description": "Temporarily unavailable or confirmation unknown. Retry the identical command ID."
          }
        },
        "security": [
          {
            "ApiKeyBearer": []
          }
        ]
      }
    },
    "/api/t-market/v1/orders": {
      "get": {
        "summary": "Orders",
        "operationId": "orders_api_t_market_v1_orders_get",
        "parameters": [
          {
            "name": "market",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Market"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "default": "open",
              "title": "Status"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 50,
              "title": "Limit"
            }
          },
          {
            "name": "before_sequence",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "maximum": 9223372036854775807,
                  "minimum": 1
                },
                {
                  "type": "null"
                }
              ],
              "title": "Before Sequence"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters, increments or operation ID"
          },
          "401": {
            "description": "Missing, expired, revoked or invalid key"
          },
          "403": {
            "description": "Read-only key or restricted account"
          },
          "404": {
            "description": "Unknown or unowned order/command"
          },
          "409": {
            "description": "Idempotency conflict or engine rejection"
          },
          "413": {
            "description": "Request body exceeds 16 KiB"
          },
          "429": {
            "description": "Rate/concurrency limit. Observe Retry-After."
          },
          "503": {
            "description": "Temporarily unavailable or confirmation unknown. Retry the identical command ID."
          }
        },
        "security": [
          {
            "ApiKeyBearer": []
          }
        ]
      },
      "post": {
        "summary": "Place",
        "operationId": "place_api_t_market_v1_orders_post",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Idempotency-Key"
            },
            "description": "A new UUIDv4 for a new command; preserve the ID and identical payload for retries."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicOrder"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters, increments or operation ID"
          },
          "401": {
            "description": "Missing, expired, revoked or invalid key"
          },
          "403": {
            "description": "Read-only key or restricted account"
          },
          "404": {
            "description": "Unknown or unowned order/command"
          },
          "409": {
            "description": "Idempotency conflict or engine rejection"
          },
          "413": {
            "description": "Request body exceeds 16 KiB"
          },
          "429": {
            "description": "Rate/concurrency limit. Observe Retry-After."
          },
          "503": {
            "description": "Temporarily unavailable or confirmation unknown. Retry the identical command ID."
          }
        },
        "security": [
          {
            "ApiKeyBearer": []
          }
        ]
      }
    },
    "/api/t-market/v1/orders/{order_id}": {
      "get": {
        "summary": "Order",
        "operationId": "order_api_t_market_v1_orders__order_id__get",
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Order Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters, increments or operation ID"
          },
          "401": {
            "description": "Missing, expired, revoked or invalid key"
          },
          "403": {
            "description": "Read-only key or restricted account"
          },
          "404": {
            "description": "Unknown or unowned order/command"
          },
          "409": {
            "description": "Idempotency conflict or engine rejection"
          },
          "413": {
            "description": "Request body exceeds 16 KiB"
          },
          "429": {
            "description": "Rate/concurrency limit. Observe Retry-After."
          },
          "503": {
            "description": "Temporarily unavailable or confirmation unknown. Retry the identical command ID."
          }
        },
        "security": [
          {
            "ApiKeyBearer": []
          }
        ]
      }
    },
    "/api/t-market/v1/commands/{operation_id}": {
      "get": {
        "summary": "Command",
        "operationId": "command_api_t_market_v1_commands__operation_id__get",
        "parameters": [
          {
            "name": "operation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Operation Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters, increments or operation ID"
          },
          "401": {
            "description": "Missing, expired, revoked or invalid key"
          },
          "403": {
            "description": "Read-only key or restricted account"
          },
          "404": {
            "description": "Unknown or unowned order/command"
          },
          "409": {
            "description": "Idempotency conflict or engine rejection"
          },
          "413": {
            "description": "Request body exceeds 16 KiB"
          },
          "429": {
            "description": "Rate/concurrency limit. Observe Retry-After."
          },
          "503": {
            "description": "Temporarily unavailable or confirmation unknown. Retry the identical command ID."
          }
        },
        "security": [
          {
            "ApiKeyBearer": []
          }
        ]
      }
    },
    "/api/t-market/v1/orders/{order_id}/cancel": {
      "post": {
        "summary": "Cancel",
        "operationId": "cancel_api_t_market_v1_orders__order_id__cancel_post",
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Order Id"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Idempotency-Key"
            },
            "description": "A new UUIDv4 for a new command; preserve the ID and identical payload for retries."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Empty"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters, increments or operation ID"
          },
          "401": {
            "description": "Missing, expired, revoked or invalid key"
          },
          "403": {
            "description": "Read-only key or restricted account"
          },
          "404": {
            "description": "Unknown or unowned order/command"
          },
          "409": {
            "description": "Idempotency conflict or engine rejection"
          },
          "413": {
            "description": "Request body exceeds 16 KiB"
          },
          "429": {
            "description": "Rate/concurrency limit. Observe Retry-After."
          },
          "503": {
            "description": "Temporarily unavailable or confirmation unknown. Retry the identical command ID."
          }
        },
        "security": [
          {
            "ApiKeyBearer": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "Empty": {
        "properties": {},
        "additionalProperties": false,
        "type": "object",
        "title": "Empty"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "KeyPermissions": {
        "properties": {
          "can_trade": {
            "type": "boolean",
            "title": "Can Trade"
          },
          "version": {
            "type": "integer",
            "title": "Version"
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "can_trade",
          "version"
        ],
        "title": "KeyPermissions"
      },
      "NewKey": {
        "properties": {
          "key_id": {
            "type": "string",
            "title": "Key Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "token_hash": {
            "type": "string",
            "title": "Token Hash"
          },
          "can_trade": {
            "type": "boolean",
            "title": "Can Trade",
            "default": false
          },
          "expiry_days": {
            "type": "integer",
            "title": "Expiry Days",
            "default": 90
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "key_id",
          "name",
          "token_hash"
        ],
        "title": "NewKey"
      },
      "PublicOrder": {
        "properties": {
          "market": {
            "type": "string",
            "title": "Market"
          },
          "side": {
            "type": "string",
            "title": "Side"
          },
          "type": {
            "type": "string",
            "title": "Type",
            "default": "limit"
          },
          "price": {
            "type": "string",
            "title": "Price"
          },
          "quantity": {
            "type": "string",
            "title": "Quantity"
          },
          "max_spend": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Spend"
          },
          "tif": {
            "type": "string",
            "title": "Tif",
            "default": "GTC"
          },
          "post_only": {
            "type": "boolean",
            "title": "Post Only",
            "default": false
          }
        },
        "additionalProperties": false,
        "type": "object",
        "required": [
          "market",
          "side",
          "price",
          "quantity"
        ],
        "title": "PublicOrder"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "ApiKeyBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "bctm_UUIDv4.secret",
        "description": "Create keys in T-MARKET → API. Read access is enabled by default; trading permission is separate."
      }
    }
  },
  "servers": [
    {
      "url": "https://bitcofy.pro"
    }
  ]
}