{
  "openapi": "3.0.1",
  "info": {
    "title": "Taiwan Block Trades API — 鉅額交易 (TWSE + TPEx)",
    "description": "Every block trade printed on the Taiwan Stock Exchange and TPEx: price, share count, consideration, paired vs continuous, and the full constituent list behind each basket trade. TWSE history back to 2005, TPEx for the current year, cross-validated against each exchange's own statistics.",
    "version": "0.1",
    "x-build-id": "7ABBfghYo77gd4W0N"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/chamarix~taiwan-block-trades/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-chamarix-taiwan-block-trades",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/chamarix~taiwan-block-trades/runs": {
      "post": {
        "operationId": "runs-sync-chamarix-taiwan-block-trades",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/chamarix~taiwan-block-trades/run-sync": {
      "post": {
        "operationId": "run-sync-chamarix-taiwan-block-trades",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "startDate": {
            "title": "Start date (資料日期)",
            "pattern": "^(|\\d{4}-\\d{2}-\\d{2})$",
            "type": "string",
            "description": "First trading day to cover, YYYY-MM-DD. Leave empty for the latest published trading day. TWSE has published block trades since 2005-04-04; TPEx's feed only carries the current year.",
            "default": ""
          },
          "endDate": {
            "title": "End date",
            "pattern": "^(|\\d{4}-\\d{2}-\\d{2})$",
            "type": "string",
            "description": "Last trading day to cover, inclusive. Leave empty to fetch only the start date. TWSE serves one request per day, so a long range is a long run — TPEx is fetched whole regardless of the range.",
            "default": ""
          },
          "markets": {
            "title": "Markets",
            "type": "array",
            "description": "Which exchange to cover. Leave empty for both.",
            "items": {
              "type": "string",
              "enum": [
                "TWSE",
                "TPEX"
              ],
              "enumTitles": [
                "TWSE — listed (上市)",
                "TPEx — OTC (上櫃)"
              ]
            },
            "default": []
          },
          "stockCodes": {
            "title": "Security codes filter",
            "type": "array",
            "description": "Optional list of security codes (e.g., ['2330', '2317']). A basket trade is kept when any security inside it matches. This filters what is emitted, not what is fetched — the range still costs the same.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "tradeTypes": {
            "title": "Trade type filter",
            "type": "array",
            "description": "PAIRED (配對交易) is a pre-negotiated cross between two counterparties. CONTINUOUS (逐筆交易) is matched against the block-trade order book. Leave empty for both.",
            "items": {
              "type": "string",
              "enum": [
                "PAIRED",
                "CONTINUOUS"
              ],
              "enumTitles": [
                "Paired (配對交易)",
                "Continuous (逐筆交易)"
              ]
            },
            "default": []
          },
          "recordTypes": {
            "title": "Record type filter",
            "type": "array",
            "description": "SINGLE_TRADE is one executed trade. BASKET_TRADE is one TWSE 股票組合 trade with its constituents nested. DAILY_AGGREGATE is TPEx's per-security daily line, which is all TPEx publishes for days other than today. Leave empty for all.",
            "items": {
              "type": "string",
              "enum": [
                "SINGLE_TRADE",
                "BASKET_TRADE",
                "DAILY_AGGREGATE"
              ],
              "enumTitles": [
                "Single trade (單一證券)",
                "Basket trade (股票組合)",
                "TPEx daily aggregate"
              ]
            },
            "default": []
          },
          "minTradeValue": {
            "title": "Minimum consideration (NTD)",
            "minimum": 0,
            "type": "integer",
            "description": "Drop records worth less than this in New Taiwan dollars. Useful for isolating the handful of trades that actually move a stake, e.g. 1000000000 for a billion-dollar block.",
            "default": 0
          },
          "minShares": {
            "title": "Minimum share count",
            "minimum": 0,
            "type": "integer",
            "description": "Drop records below this many shares. Note the unit is shares, not the 1,000-share 張 that Taiwanese brokers quote.",
            "default": 0
          },
          "includeBasketTrades": {
            "title": "Include TWSE basket trades",
            "type": "boolean",
            "description": "Fetch the 股票組合 report as well, and follow each basket's drill-down for its constituents. Costs one extra request per day plus one per basket; baskets are rare, so most days this is a single extra request.",
            "default": true
          },
          "crossCheck": {
            "title": "Cross-check against the exchanges' statistics",
            "type": "boolean",
            "description": "Compare the parsed rows with each exchange's separately published block-trade statistics and log any disagreement. Two extra requests per run. Leave on unless you are optimising a very short run.",
            "default": true
          },
          "maxDays": {
            "title": "Maximum weekdays per run",
            "minimum": 0,
            "type": "integer",
            "description": "Safety stop on how many weekdays a single run will walk. Set 0 to lift it.",
            "default": 400
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}