{
  "openapi": "3.1.0",
  "info": {
    "title": "Blocksize Market Data API OpenAPI",
    "version": "1.0.0",
    "description": "Generated from the Blocksize machine-readable API documentation. The API uses JSON-RPC 2.0 over WebSocket and selected HTTP POST methods."
  },
  "externalDocs": {
    "description": "Human-readable Blocksize API documentation",
    "url": "https://matrix.blocksize.capital/api-docs"
  },
  "servers": [
    {
      "url": "https://data.blocksize.capital"
    }
  ],
  "tags": [
    {
      "name": "Real-Time VWAP"
    },
    {
      "name": "30-Minute VWAP"
    },
    {
      "name": "Real-Time Bid/Ask"
    },
    {
      "name": "AMM State Price"
    },
    {
      "name": "Time"
    }
  ],
  "paths": {
    "/marketdata/v1/api": {
      "post": {
        "operationId": "callJsonRpc",
        "summary": "Call an HTTP-available Blocksize JSON-RPC method",
        "description": "Send one of the documented HTTP-available JSON-RPC request envelopes. The response body is a JSON-RPC success or error envelope; API-level errors can be returned with HTTP status 200.",
        "tags": [
          "JSON-RPC"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          },
          {
            "BearerAuth": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/VwapInstrumentsRequest"
                  },
                  {
                    "$ref": "#/components/schemas/VwapLatestRequest"
                  },
                  {
                    "$ref": "#/components/schemas/ClosingpriceListRequest"
                  },
                  {
                    "$ref": "#/components/schemas/ClosingpriceTradesRequest"
                  },
                  {
                    "$ref": "#/components/schemas/BidaskInstrumentsRequest"
                  },
                  {
                    "$ref": "#/components/schemas/BidaskGetSnapshotRequest"
                  },
                  {
                    "$ref": "#/components/schemas/StatePoolRequest"
                  },
                  {
                    "$ref": "#/components/schemas/StateInstrumentsRequest"
                  },
                  {
                    "$ref": "#/components/schemas/TimeNowRequest"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC success or error response",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/VwapInstrumentsResponse"
                    },
                    {
                      "$ref": "#/components/schemas/VwapLatestResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ClosingpriceListResponse"
                    },
                    {
                      "$ref": "#/components/schemas/ClosingpriceTradesResponse"
                    },
                    {
                      "$ref": "#/components/schemas/BidaskInstrumentsResponse"
                    },
                    {
                      "$ref": "#/components/schemas/BidaskGetSnapshotResponse"
                    },
                    {
                      "$ref": "#/components/schemas/StatePoolResponse"
                    },
                    {
                      "$ref": "#/components/schemas/StateInstrumentsResponse"
                    },
                    {
                      "$ref": "#/components/schemas/TimeNowResponse"
                    },
                    {
                      "$ref": "#/components/schemas/JsonRpcErrorResponse"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Api-Key"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "JsonRpcId": {
        "oneOf": [
          {
            "type": "string"
          },
          {
            "type": "integer"
          }
        ]
      },
      "JsonRpcError": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "enum": [
              -32600,
              -32601,
              -32602,
              -32603,
              -32700,
              4000,
              4001,
              4002,
              4003
            ]
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "JsonRpcErrorResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "error"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/JsonRpcId"
              },
              {
                "type": "null"
              }
            ]
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer",
                "enum": [
                  -32600,
                  -32601,
                  -32602,
                  -32603,
                  -32700,
                  4000,
                  4001,
                  4002,
                  4003
                ]
              },
              "message": {
                "type": "string"
              },
              "data": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "VwapInstrumentsParams": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "VwapInstrumentsResult": {
        "type": "object",
        "properties": {
          "instruments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "ticker": {
                  "type": "string",
                  "description": "The instrument's ticker"
                },
                "base_currency": {
                  "type": "string",
                  "description": "The instrument's base currency"
                },
                "quote_currency": {
                  "type": "string",
                  "description": "The instrument's quote currency"
                },
                "exchanges": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "A list of exchanges which are currently used to calculate the price"
                }
              },
              "required": [
                "ticker",
                "base_currency",
                "quote_currency",
                "exchanges"
              ],
              "additionalProperties": false
            },
            "description": "A list of all pairs that can be subscribed to"
          }
        },
        "required": [
          "instruments"
        ],
        "additionalProperties": false
      },
      "VwapInstrumentsRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "method"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "method": {
            "type": "string",
            "const": "vwap_instruments"
          },
          "params": {
            "$ref": "#/components/schemas/VwapInstrumentsParams"
          }
        },
        "additionalProperties": false
      },
      "VwapInstrumentsResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "result"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "result": {
            "$ref": "#/components/schemas/VwapInstrumentsResult"
          }
        },
        "additionalProperties": false
      },
      "VwapLatestParams": {
        "type": "object",
        "properties": {
          "ticker": {
            "type": "string",
            "description": "The ticker of the instrument"
          }
        },
        "required": [
          "ticker"
        ],
        "additionalProperties": false
      },
      "VwapLatestResult": {
        "type": "object",
        "properties": {
          "vwap": {
            "type": "object",
            "properties": {
              "ticker": {
                "type": "string",
                "description": "The ticker of the instrument"
              },
              "price": {
                "type": "number",
                "format": "double",
                "description": "The VWAP of the instrument"
              },
              "size": {
                "type": "number",
                "format": "double",
                "description": "Total size"
              },
              "volume": {
                "type": "number",
                "format": "double",
                "description": "Total volume"
              },
              "market_cap": {
                "type": "number",
                "format": "double",
                "description": "Circulating supply of the base token times the price"
              },
              "ts": {
                "type": "integer",
                "format": "int64",
                "description": "Timestamp of VWAP in milliseconds. Indicates last timestamp (exchange provided) of the last trade used for calculation"
              }
            },
            "required": [
              "ticker",
              "price",
              "size",
              "volume",
              "ts"
            ],
            "additionalProperties": false,
            "description": "The latest known VWAP for the given ticker"
          }
        },
        "required": [
          "vwap"
        ],
        "additionalProperties": false
      },
      "VwapLatestRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "method",
          "params"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "method": {
            "type": "string",
            "const": "vwap_latest"
          },
          "params": {
            "$ref": "#/components/schemas/VwapLatestParams"
          }
        },
        "additionalProperties": false
      },
      "VwapLatestResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "result"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "result": {
            "$ref": "#/components/schemas/VwapLatestResult"
          }
        },
        "additionalProperties": false
      },
      "ClosingpriceListParams": {
        "type": "object",
        "properties": {
          "ts": {
            "type": "integer",
            "format": "int64",
            "description": "The Unix timestamp in milliseconds."
          },
          "quote": {
            "type": "string",
            "description": "An optional quote currency to report prices in. If EUR or USD are specified, synthetic prices will be calculated."
          }
        },
        "required": [
          "ts",
          "quote"
        ],
        "additionalProperties": false
      },
      "ClosingpriceListResult": {
        "type": "object",
        "properties": {
          "conversion_rates": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "from": {
                  "type": "string",
                  "description": "The currency this conversion rate is being applied to"
                },
                "to": {
                  "type": "string",
                  "description": "The currency this conversion rate will result in"
                },
                "rate": {
                  "type": "string",
                  "description": "The conversion rate"
                },
                "ts": {
                  "type": "integer",
                  "format": "int64",
                  "description": "The Unix timestamp in milliseconds."
                },
                "datetime": {
                  "type": "string",
                  "description": "The timestamp in RFC3339 format."
                }
              },
              "required": [
                "from",
                "to",
                "rate",
                "ts",
                "datetime"
              ],
              "additionalProperties": false
            },
            "description": "The conversion rates applied to calculate synthetic prices."
          },
          "prices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "base": {
                  "type": "string",
                  "description": "The base currency"
                },
                "quote": {
                  "type": "string",
                  "description": "The quote currency"
                },
                "price": {
                  "type": "string",
                  "description": "The closing price"
                },
                "ts": {
                  "type": "integer",
                  "format": "int64",
                  "description": "The Unix timestamp in milliseconds."
                },
                "datetime": {
                  "type": "string",
                  "description": "The timestamp in RFC3339 format."
                },
                "original_quote": {
                  "type": "string",
                  "description": "For those pairs that were calculated using conversion"
                }
              },
              "required": [
                "base",
                "quote",
                "price",
                "ts",
                "datetime"
              ],
              "additionalProperties": false
            },
            "description": "A list of closing prices"
          }
        },
        "required": [
          "prices"
        ],
        "additionalProperties": false
      },
      "ClosingpriceListRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "method",
          "params"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "method": {
            "type": "string",
            "const": "closingprice_list"
          },
          "params": {
            "$ref": "#/components/schemas/ClosingpriceListParams"
          }
        },
        "additionalProperties": false
      },
      "ClosingpriceListResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "result"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "result": {
            "$ref": "#/components/schemas/ClosingpriceListResult"
          }
        },
        "additionalProperties": false
      },
      "ClosingpriceTradesParams": {
        "type": "object",
        "properties": {
          "base": {
            "type": "string",
            "description": "The base currency"
          },
          "quote": {
            "type": "string",
            "description": "The quote currency"
          },
          "ts": {
            "type": "integer",
            "format": "int64",
            "description": "The UTC timestamp in milliseconds."
          }
        },
        "required": [
          "base",
          "quote",
          "ts"
        ],
        "additionalProperties": false
      },
      "ClosingpriceTradesResult": {
        "type": "object",
        "properties": {
          "prices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "base": {
                  "type": "string",
                  "description": "The base currency"
                },
                "quote": {
                  "type": "string",
                  "description": "The quote currency"
                },
                "exchange": {
                  "type": "string",
                  "description": "The trade exchange"
                },
                "price": {
                  "type": "string",
                  "description": "The trade price"
                },
                "size": {
                  "type": "string",
                  "description": "Size of the trade in base currency"
                },
                "ts": {
                  "type": "integer",
                  "format": "int64",
                  "description": "The UTC timestamp in milliseconds."
                }
              },
              "required": [
                "base",
                "quote",
                "exchange",
                "price",
                "size",
                "ts"
              ],
              "additionalProperties": false
            },
            "description": "A list of trades"
          }
        },
        "required": [
          "prices"
        ],
        "additionalProperties": false
      },
      "ClosingpriceTradesRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "method",
          "params"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "method": {
            "type": "string",
            "const": "closingprice_trades"
          },
          "params": {
            "$ref": "#/components/schemas/ClosingpriceTradesParams"
          }
        },
        "additionalProperties": false
      },
      "ClosingpriceTradesResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "result"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "result": {
            "$ref": "#/components/schemas/ClosingpriceTradesResult"
          }
        },
        "additionalProperties": false
      },
      "BidaskInstrumentsParams": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "BidaskInstrumentsResult": {
        "type": "object",
        "properties": {
          "instruments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "ticker": {
                  "type": "string",
                  "description": "The instrument's ticker"
                },
                "base_currency": {
                  "type": "string",
                  "description": "The instrument's base currency"
                },
                "quote_currency": {
                  "type": "string",
                  "description": "The instrument's quote currency"
                },
                "exchanges": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "A list of exchanges which are currently used to calculate the price"
                }
              },
              "required": [
                "ticker",
                "base_currency",
                "quote_currency",
                "exchanges"
              ],
              "additionalProperties": false
            },
            "description": "A list of all pairs that can be subscribed to"
          }
        },
        "required": [
          "instruments"
        ],
        "additionalProperties": false
      },
      "BidaskInstrumentsRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "method"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "method": {
            "type": "string",
            "const": "bidask_instruments"
          },
          "params": {
            "$ref": "#/components/schemas/BidaskInstrumentsParams"
          }
        },
        "additionalProperties": false
      },
      "BidaskInstrumentsResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "result"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "result": {
            "$ref": "#/components/schemas/BidaskInstrumentsResult"
          }
        },
        "additionalProperties": false
      },
      "BidaskGetSnapshotParams": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "BidaskGetSnapshotResult": {
        "type": "object",
        "properties": {
          "snapshot": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "ticker": {
                  "type": "string",
                  "description": "The ticker of the instrument"
                },
                "agg_bid_price": {
                  "type": "string",
                  "description": "The aggregated bid price of the instrument"
                },
                "agg_bid_size": {
                  "type": "string",
                  "description": "The aggregated bid size of the instrument"
                },
                "agg_ask_price": {
                  "type": "string",
                  "description": "The aggregated ask price of the instrument"
                },
                "agg_ask_size": {
                  "type": "string",
                  "description": "The aggregated ask size of the instrument"
                },
                "agg_mid_price": {
                  "type": "string",
                  "description": "The aggregated mid price of the instrument"
                },
                "ts": {
                  "type": "integer",
                  "format": "int64",
                  "description": "The UTC timestamp in microseconds."
                },
                "market_cap": {
                  "type": "number",
                  "format": "double",
                  "description": "Circulating supply of the base token times mid price"
                }
              },
              "required": [
                "ticker",
                "agg_bid_price",
                "agg_bid_size",
                "agg_ask_price",
                "agg_ask_size",
                "agg_mid_price",
                "ts"
              ],
              "additionalProperties": false
            },
            "description": "This will contain price updates for all the requested tickers"
          }
        },
        "required": [
          "snapshot"
        ],
        "additionalProperties": false
      },
      "BidaskGetSnapshotRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "method"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "method": {
            "type": "string",
            "const": "bidask_getSnapshot"
          },
          "params": {
            "$ref": "#/components/schemas/BidaskGetSnapshotParams"
          }
        },
        "additionalProperties": false
      },
      "BidaskGetSnapshotResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "result"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "result": {
            "$ref": "#/components/schemas/BidaskGetSnapshotResult"
          }
        },
        "additionalProperties": false
      },
      "StatePoolParams": {
        "type": "object",
        "properties": {
          "symbol": {
            "type": "string"
          },
          "block": {
            "type": "integer",
            "format": "int64"
          },
          "block_time": {
            "type": "integer",
            "format": "int64"
          },
          "network": {
            "type": "string"
          },
          "pool": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "StatePoolResult": {
        "type": "object",
        "properties": {
          "state": {}
        },
        "additionalProperties": false
      },
      "StatePoolRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "method",
          "params"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "method": {
            "type": "string",
            "const": "state_pool"
          },
          "params": {
            "$ref": "#/components/schemas/StatePoolParams"
          }
        },
        "additionalProperties": false
      },
      "StatePoolResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "result"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "result": {
            "$ref": "#/components/schemas/StatePoolResult"
          }
        },
        "additionalProperties": false
      },
      "StateInstrumentsParams": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "StateInstrumentsResult": {
        "type": "object",
        "properties": {
          "instruments": {
            "type": "array",
            "items": {}
          }
        },
        "additionalProperties": false
      },
      "StateInstrumentsRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "method"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "method": {
            "type": "string",
            "const": "state_instruments"
          },
          "params": {
            "$ref": "#/components/schemas/StateInstrumentsParams"
          }
        },
        "additionalProperties": false
      },
      "StateInstrumentsResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "result"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "result": {
            "$ref": "#/components/schemas/StateInstrumentsResult"
          }
        },
        "additionalProperties": false
      },
      "TimeNowParams": {
        "type": "object",
        "properties": {},
        "additionalProperties": false
      },
      "TimeNowResult": {
        "type": "object",
        "properties": {
          "timestamp": {
            "type": "integer",
            "format": "int64",
            "description": "The server time in seconds (Unix)."
          }
        },
        "additionalProperties": false
      },
      "TimeNowRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "method"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "method": {
            "type": "string",
            "const": "time_now"
          },
          "params": {
            "$ref": "#/components/schemas/TimeNowParams"
          }
        },
        "additionalProperties": false
      },
      "TimeNowResponse": {
        "type": "object",
        "required": [
          "jsonrpc",
          "id",
          "result"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "$ref": "#/components/schemas/JsonRpcId"
          },
          "result": {
            "$ref": "#/components/schemas/TimeNowResult"
          }
        },
        "additionalProperties": false
      }
    }
  }
}
