{
  "openapi": "3.0.3",
  "info": {
    "title": "Speed API",
    "version": "1.0.0",
    "description": "Instant crypto swap API. All requests are signed: X-API-SIGN = hex(HMAC-SHA256(Secret, X-API-TIMESTAMP + METHOD + pathWithQuery + body)). Docs: https://speed.cc/docs",
    "contact": {
      "email": "serve@speed.cc",
      "url": "https://speed.cc/docs/support"
    }
  },
  "servers": [
    {
      "url": "https://speed.cc/api/open/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "ApiKey": [],
      "Timestamp": [],
      "Signature": []
    }
  ],
  "tags": [
    {
      "name": "Currencies",
      "description": "Supported currencies and networks"
    },
    {
      "name": "Quotes",
      "description": "Live quotes"
    },
    {
      "name": "Orders",
      "description": "Create, look up and handle orders"
    }
  ],
  "paths": {
    "/currencies": {
      "get": {
        "tags": [
          "Currencies"
        ],
        "operationId": "listCurrencies",
        "summary": "Supported currencies and networks",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "example": 0
                    },
                    "message": {
                      "type": "string",
                      "example": "ok"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Currency"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/rate": {
      "get": {
        "tags": [
          "Quotes"
        ],
        "operationId": "getRate",
        "summary": "Live quote",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Currency to pay"
          },
          {
            "name": "fromNetwork",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Network to pay on"
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Currency to receive"
          },
          {
            "name": "toNetwork",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Network to receive on"
          },
          {
            "name": "amount",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Amount to pay (decimal string)"
          },
          {
            "name": "rateType",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "FLOAT",
                "FIXED"
              ],
              "default": "FLOAT"
            },
            "description": "Rate type"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "example": 0
                    },
                    "message": {
                      "type": "string",
                      "example": "ok"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Rate"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/orders": {
      "post": {
        "tags": [
          "Orders"
        ],
        "operationId": "createOrder",
        "summary": "Create order",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOrderRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "example": 0
                    },
                    "message": {
                      "type": "string",
                      "example": "ok"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Orders"
        ],
        "operationId": "listOrders",
        "summary": "List orders, or get one by clientOrderId",
        "description": "Without clientOrderId: paginated list (newest first). With clientOrderId: returns that single Order.",
        "parameters": [
          {
            "name": "clientOrderId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "size",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "example": 0
                    },
                    "message": {
                      "type": "string",
                      "example": "ok"
                    },
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/OrderPage"
                        },
                        {
                          "$ref": "#/components/schemas/Order"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/orders/{orderNo}": {
      "get": {
        "tags": [
          "Orders"
        ],
        "operationId": "getOrder",
        "summary": "Get order",
        "parameters": [
          {
            "name": "orderNo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "example": 0
                    },
                    "message": {
                      "type": "string",
                      "example": "ok"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/orders/{orderNo}/action": {
      "post": {
        "tags": [
          "Orders"
        ],
        "operationId": "orderAction",
        "summary": "Continue or refund an ACTION_REQUIRED order",
        "parameters": [
          {
            "name": "orderNo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "code",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "code": {
                      "type": "integer",
                      "example": 0
                    },
                    "message": {
                      "type": "string",
                      "example": "ok"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error (code != 0)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-KEY"
      },
      "Timestamp": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-TIMESTAMP",
        "description": "Milliseconds since epoch; within 60s of server time"
      },
      "Signature": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-SIGN",
        "description": "hex(HMAC-SHA256(Secret, timestamp + METHOD + pathWithQuery + body)); single use"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "example": 40000
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "nullable": true
          }
        }
      },
      "OrderStatus": {
        "type": "string",
        "enum": [
          "WAITING_PAYMENT",
          "CONFIRMING",
          "EXCHANGING",
          "SENDING",
          "COMPLETED",
          "ACTION_REQUIRED",
          "REFUNDING",
          "REFUNDED",
          "ON_HOLD",
          "EXPIRED",
          "CLOSED"
        ]
      },
      "Currency": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "example": "USDT"
          },
          "network": {
            "type": "string",
            "example": "TRC20"
          },
          "name": {
            "type": "string",
            "example": "Tether"
          },
          "decimals": {
            "type": "integer",
            "example": 6
          },
          "minAmount": {
            "type": "string",
            "example": "10"
          },
          "maxAmount": {
            "type": "string",
            "example": "500000"
          },
          "needMemo": {
            "type": "boolean"
          },
          "payIn": {
            "type": "boolean"
          },
          "payOut": {
            "type": "boolean"
          }
        }
      },
      "Rate": {
        "type": "object",
        "properties": {
          "rate": {
            "type": "string",
            "description": "Approximate amount received per 1 unit paid"
          },
          "receiveAmount": {
            "type": "string",
            "description": "Estimated amount received, after all fees"
          },
          "minAmount": {
            "type": "string"
          },
          "maxAmount": {
            "type": "string"
          }
        }
      },
      "CreateOrderRequest": {
        "type": "object",
        "required": [
          "fromCurrency",
          "fromNetwork",
          "toCurrency",
          "toNetwork",
          "amount",
          "recipientAddress"
        ],
        "properties": {
          "fromCurrency": {
            "type": "string",
            "maxLength": 16,
            "example": "USDT"
          },
          "fromNetwork": {
            "type": "string",
            "maxLength": 32,
            "example": "TRC20"
          },
          "toCurrency": {
            "type": "string",
            "maxLength": 16,
            "example": "BTC"
          },
          "toNetwork": {
            "type": "string",
            "maxLength": 32,
            "example": "Bitcoin"
          },
          "amount": {
            "type": "string",
            "description": "Amount to pay (decimal string)",
            "example": "1000"
          },
          "recipientAddress": {
            "type": "string",
            "maxLength": 128
          },
          "recipientMemo": {
            "type": "string",
            "maxLength": 128
          },
          "refundAddress": {
            "type": "string",
            "description": "Required for FIXED orders",
            "maxLength": 128
          },
          "refundMemo": {
            "type": "string",
            "maxLength": 128
          },
          "rateType": {
            "type": "string",
            "enum": [
              "FLOAT",
              "FIXED"
            ],
            "default": "FLOAT"
          },
          "clientOrderId": {
            "type": "string",
            "description": "Your order ID; idempotency key per account",
            "pattern": "^[A-Za-z0-9_.:-]{1,64}$"
          }
        }
      },
      "ActionRequest": {
        "type": "object",
        "required": [
          "action"
        ],
        "properties": {
          "action": {
            "type": "string",
            "enum": [
              "CONTINUE",
              "REFUND"
            ]
          },
          "refundAddress": {
            "type": "string"
          },
          "refundMemo": {
            "type": "string"
          }
        }
      },
      "Order": {
        "type": "object",
        "properties": {
          "orderNo": {
            "type": "string",
            "description": "Speed order number",
            "example": "PX261115F9QFHKEU"
          },
          "clientOrderId": {
            "type": "string",
            "description": "Your order ID",
            "nullable": true,
            "example": "shop-1001"
          },
          "status": {
            "$ref": "#/components/schemas/OrderStatus"
          },
          "rateType": {
            "type": "string",
            "enum": [
              "FLOAT",
              "FIXED"
            ]
          },
          "fromCurrency": {
            "type": "string",
            "example": "USDT"
          },
          "fromNetwork": {
            "type": "string",
            "example": "TRC20"
          },
          "toCurrency": {
            "type": "string",
            "example": "BTC"
          },
          "toNetwork": {
            "type": "string",
            "example": "Bitcoin"
          },
          "sendAmount": {
            "type": "string",
            "description": "Amount the user must pay",
            "example": "1000"
          },
          "depositAddress": {
            "type": "string",
            "description": "Payment address"
          },
          "depositMemo": {
            "type": "string",
            "description": "Payment memo / tag; required when not empty",
            "nullable": true
          },
          "paidAmount": {
            "type": "string",
            "description": "Amount actually received from the user",
            "nullable": true
          },
          "receiveAmount": {
            "type": "string",
            "description": "Amount the user receives; estimate while receiveFinal is false",
            "nullable": true
          },
          "receiveFinal": {
            "type": "boolean"
          },
          "recipientAddress": {
            "type": "string"
          },
          "recipientMemo": {
            "type": "string",
            "nullable": true
          },
          "refundAddress": {
            "type": "string",
            "nullable": true
          },
          "refundMemo": {
            "type": "string",
            "nullable": true
          },
          "depositTx": {
            "type": "string",
            "nullable": true
          },
          "payoutTx": {
            "type": "string",
            "nullable": true
          },
          "action": {
            "type": "object",
            "nullable": true,
            "properties": {
              "reason": {
                "type": "string",
                "enum": [
                  "RATE_MOVED",
                  "AMOUNT_MISMATCH",
                  "BELOW_MIN",
                  "ABOVE_MAX"
                ]
              },
              "canContinue": {
                "type": "boolean"
              }
            }
          },
          "expireAt": {
            "type": "string",
            "description": "UTC, e.g. 2026-11-15T17:31:24"
          },
          "createdAt": {
            "type": "string",
            "description": "UTC"
          },
          "completedAt": {
            "type": "string",
            "description": "UTC",
            "nullable": true
          }
        }
      },
      "OrderPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Order"
            }
          },
          "total": {
            "type": "integer"
          },
          "page": {
            "type": "integer"
          },
          "size": {
            "type": "integer"
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "description": "POSTed to your callback URL. Headers: X-SPEED-TIMESTAMP, X-SPEED-SIGN = hex(HMAC-SHA256(Secret, timestamp + raw body))",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "order.status",
              "ping"
            ]
          },
          "status": {
            "$ref": "#/components/schemas/OrderStatus"
          },
          "order": {
            "$ref": "#/components/schemas/Order"
          },
          "timestamp": {
            "type": "integer"
          }
        }
      }
    }
  }
}