{
  "openapi": "3.0.1",
  "info": {
    "title": "Taiwan Short Sale Eligibility & Borrow Fee API (TWSE + TPEx)",
    "description": "Can this Taiwan stock be shorted today? Below-close short list, shares available to borrow, stock borrow fees, margin haircuts and forced short-cover dates for every TWSE and TPEx stock, from ten official exchange reports, cross-checked against each other.",
    "version": "0.1",
    "x-build-id": "5xBkYHmZ1LkIhVeiJ"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/chamarix~taiwan-short-sale-eligibility/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-chamarix-taiwan-short-sale-eligibility",
        "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-short-sale-eligibility/runs": {
      "post": {
        "operationId": "runs-sync-chamarix-taiwan-short-sale-eligibility",
        "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-short-sale-eligibility/run-sync": {
      "post": {
        "operationId": "run-sync-chamarix-taiwan-short-sale-eligibility",
        "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": {
          "recordTypes": {
            "title": "What to fetch",
            "type": "array",
            "description": "Six record types in one dataset, told apart by record_type. collateral_balance is off by default because it is large (about 2,200 rows a session) and is about margin loans more than short selling.",
            "items": {
              "type": "string",
              "enum": [
                "eligibility",
                "borrow_fee",
                "margin_adjustment",
                "shortable_shares",
                "suspension_notice",
                "collateral_balance"
              ],
              "enumTitles": [
                "eligibility — may it be shorted below the last close? Suspension flags per stock (history from 2013)",
                "borrow_fee — the rate paid to borrow a stock, per stock per day (history from 2015)",
                "margin_adjustment — margin loan cuts and short margin raises, with reasons (TWSE history from 2014)",
                "shortable_shares — shares available to borrow and sell short today (today only)",
                "suspension_notice — upcoming short-sale suspensions and the forced cover date (today only)",
                "collateral_balance — shares pledged as collateral, five kinds of loan (history from 2006)"
              ]
            },
            "default": [
              "eligibility",
              "borrow_fee",
              "margin_adjustment",
              "shortable_shares",
              "suspension_notice"
            ]
          },
          "market": {
            "title": "Market",
            "enum": [
              "both",
              "twse",
              "tpex"
            ],
            "type": "string",
            "description": "TWSE listed, TPEx OTC, or both.",
            "default": "both"
          },
          "startDate": {
            "title": "Start date (YYYY-MM-DD)",
            "pattern": "^(|\\d{4}[-/]\\d{2}[-/]\\d{2})$",
            "type": "string",
            "description": "Leave both dates empty for the latest data: each report's most recent session, found by looking back over holidays. Fill them in for history. shortable_shares and suspension_notice have no history at the source and are only included when the range reaches today.",
            "default": ""
          },
          "endDate": {
            "title": "End date (YYYY-MM-DD)",
            "pattern": "^(|\\d{4}[-/]\\d{2}[-/]\\d{2})$",
            "type": "string",
            "description": "Last session to include, inclusive. Defaults to today in Taipei when a start date is given. Weekends are skipped; holidays answer empty and are not treated as errors.",
            "default": ""
          },
          "stockCodes": {
            "title": "Stock codes",
            "type": "array",
            "description": "Keep only these codes, e.g. 2330, 00400A. Leave empty for every stock. Codes are not always four digits: ETFs carry letters.",
            "default": [],
            "items": {
              "type": "string"
            }
          },
          "onlyRestricted": {
            "title": "Only restricted stocks",
            "type": "boolean",
            "description": "Keep only eligibility rows with at least one restriction, margin adjustments currently in effect, and collateral rows carrying a note. Cuts a daily run from about 2,000 eligibility rows to a few dozen.",
            "default": false
          },
          "maxRequests": {
            "title": "Maximum requests",
            "minimum": 0,
            "type": "integer",
            "description": "A safety cap for long backfills. When the plan exceeds it, the most recent sessions are kept. 0 lifts it.",
            "default": 300
          },
          "useApifyProxy": {
            "title": "Route TWSE requests through Apify Proxy",
            "type": "boolean",
            "description": "Turn this on for a multi-year backfill. TWSE's firewall refuses an address that asks too often; the proxy gives the run another exit. TPEx always goes direct, because it resets proxied connections.",
            "default": false
          }
        }
      },
      "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "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
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}