{
  "openapi": "3.0.1",
  "info": {
    "title": "Taiwan Index History — TAIEX & TPEx 指數歷史 API",
    "description": "Daily history for Taiwan's stock indices: the TAIEX back to 1990-01-04 with market turnover, its total-return twin, the TPEx OTC index back to 1999-09-01, and one row per session for every one of the ~273 indices TWSE publishes, each with its official English name.",
    "version": "0.1",
    "x-build-id": "kIq9LvH0WEBe6cuos"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/chamarix~taiwan-index-history/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-chamarix-taiwan-index-history",
        "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-index-history/runs": {
      "post": {
        "operationId": "runs-sync-chamarix-taiwan-index-history",
        "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-index-history/run-sync": {
      "post": {
        "operationId": "run-sync-chamarix-taiwan-index-history",
        "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": {
          "datasets": {
            "title": "Datasets",
            "type": "array",
            "description": "TAIEX_DAILY is one row per TWSE session — the weighted index open, high, low and close plus the market's turnover, share volume and trade count. TPEX_DAILY is the same shape for the OTC board's TPEx index. ALL_INDICES is one row per index per session, covering all ~273 indices the exchange publishes (sector, thematic, ESG, leveraged and inverse, and their total-return twins) and costs one request per session, or two with English names on. TPEX_SUB_INDICES adds the TPEx total-return, TPEx 50, corporate-governance and high-dividend series, which the OTC board serves only for a rolling window of recent sessions.",
            "items": {
              "type": "string",
              "enum": [
                "TAIEX_DAILY",
                "TPEX_DAILY",
                "ALL_INDICES",
                "TPEX_SUB_INDICES"
              ],
              "enumTitles": [
                "TAIEX_DAILY — TAIEX bar + market turnover (from 1990-01-04)",
                "TPEX_DAILY — TPEx index bar (from 1999-09-01)",
                "ALL_INDICES — every TWSE index, one row each (from 2009-01-05)",
                "TPEX_SUB_INDICES — TPEx 50 / governance / high dividend (rolling window)"
              ]
            },
            "default": [
              "TAIEX_DAILY",
              "TPEX_DAILY"
            ]
          },
          "startDate": {
            "title": "Start date (YYYY-MM-DD)",
            "pattern": "^(|\\d{4}[-/]?\\d{2}[-/]?\\d{2})$",
            "type": "string",
            "description": "First session to fetch. Leave both dates empty for the latest session. Each dataset has its own archive floor and a range that starts before it simply begins where the data does: turnover and the TAIEX close reach 1990-01-04, the intraday high and low 1999-01-05, the total-return index 2003-01-02, the TPEx index 1999-09-01 and the all-indices report 2009-01-05.",
            "default": ""
          },
          "endDate": {
            "title": "End date (YYYY-MM-DD)",
            "pattern": "^(|\\d{4}[-/]?\\d{2}[-/]?\\d{2})$",
            "type": "string",
            "description": "Last session to fetch, inclusive. Defaults to today. The daily series are served a month at a time, so a decade of TAIEX costs about 360 requests and a decade of the TPEx index about 120, no matter how many sessions they hold.",
            "default": ""
          },
          "includeEnglishNames": {
            "title": "Attach official English index names",
            "type": "boolean",
            "description": "Only affects ALL_INDICES. The exchange publishes the same report in English, so this fetches both editions and carries the official English name onto every row. It is not a row-for-row copy — some sessions carry an index in one language and not the other — so the two are matched on their numbers and an index that cannot be placed is left without an English name rather than given a wrong one. Doubles the request count for this dataset.",
            "default": true
          },
          "crossCheck": {
            "title": "Cross-check against the open-data hosts",
            "type": "boolean",
            "description": "Both exchanges publish their recent sessions a second time through open-data hosts built separately from the dated reports — different domains, different date formats, different column names. With this on, every overlap is compared value by value and the result written to the log. It is also the fallback the run uses if the exchange's firewall refuses a report mid-way. Costs up to four extra requests.",
            "default": true
          },
          "useApifyProxy": {
            "title": "Route TWSE requests through Apify Proxy",
            "type": "boolean",
            "description": "Turn this on for a backfill longer than about two years. TWSE's firewall refuses by address, so a long range gets cut off part-way and stays refused for minutes; with this on, TWSE requests go out through Apify Proxy and take a different exit address each time they are refused. It is off by default because a direct run is faster and cleaner for any ordinary range — through a datacentre proxy even TWSE drops a connection now and then. The OTC board always goes direct either way: it resets proxied connections outright, so proxying it would only break it.",
            "default": false
          },
          "maxSessions": {
            "title": "Maximum sessions for ALL_INDICES",
            "minimum": 0,
            "type": "integer",
            "description": "A safety cap on the per-session dataset, since a decade of it is about 2,400 sessions and twice that many requests. When a range exceeds the cap the most recent sessions are kept and the rest skipped, with a warning. Set to 0 to lift the cap. Does not affect the daily series, which are fetched a month at a time.",
            "default": 250
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}