{
  "openapi": "3.0.1",
  "info": {
    "title": "Malaysia Open Data Studio — Gov Data Joins",
    "description": "Value layer on Malaysia's official open data API (data.gov.my): cross-dataset joins (population x income x CPI by state), CSV/JSON/XLSX delivery, webhooks, AI-ready output with CC BY 4.0 attribution.",
    "version": "0.3",
    "x-build-id": "t1YiMrg2CAhbUHoxy"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/subimpact~my-open-data-studio/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-subimpact-my-open-data-studio",
        "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/subimpact~my-open-data-studio/runs": {
      "post": {
        "operationId": "runs-sync-subimpact-my-open-data-studio",
        "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/subimpact~my-open-data-studio/run-sync": {
      "post": {
        "operationId": "run-sync-subimpact-my-open-data-studio",
        "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": {
          "preset": {
            "title": "Preset bundle",
            "enum": [
              "B1",
              "B2",
              "B3",
              "B4",
              "B5",
              "B6",
              "B7",
              "B8",
              "B9",
              "B10",
              "B11",
              "custom"
            ],
            "type": "string",
            "description": "Join bundle. B1 = Economy by State. B2 = Demography by State. B3 = Labour Market & Mobility. B4 = Prices & Inflation. B5 = Health & Pandemic. B6 = Public Transport Ridership. B7 = Education by State. B8 = Tourism & Arrivals. B9 = Agriculture & Commodities. B10 = Public Safety. B11 = Healthcare Capacity. custom = bring your own dataset ids.",
            "default": "B1"
          },
          "customDatasets": {
            "title": "Custom join — dataset IDs",
            "type": "array",
            "description": "For preset=custom: list of data.gov.my catalogue ids to join (2-6). Leave empty to use a preset.",
            "items": {
              "type": "string"
            }
          },
          "customKey": {
            "title": "Custom join — key columns",
            "type": "array",
            "description": "For preset=custom: key parts to join on. Use 'year' (extracted from the date field) or raw field names like state, district. All datasets must share these keys.",
            "default": [
              "state",
              "year"
            ],
            "items": {
              "type": "string"
            }
          },
          "customJoinType": {
            "title": "Custom join — join type",
            "enum": [
              "inner",
              "left"
            ],
            "type": "string",
            "description": "inner keeps only keys present in every dataset; left keeps all keys from the first dataset.",
            "default": "inner"
          },
          "customParams": {
            "title": "Custom join — API filters (JSON)",
            "type": "string",
            "description": "For preset=custom: JSON object of extra API params applied to every dataset, e.g. {\"filter\": \"overall@division\"}."
          },
          "customAgg": {
            "title": "Custom join — aggregation",
            "enum": [
              "none",
              "sum",
              "mean"
            ],
            "type": "string",
            "description": "none = keep raw rows (last value per key). sum = aggregate numeric values per key. mean = average numeric values per key.",
            "default": "none"
          },
          "format": {
            "title": "Output format",
            "enum": [
              "json",
              "csv",
              "xlsx"
            ],
            "type": "string",
            "description": "File format delivered to the key-value store (dataset records are always JSON).",
            "default": "json"
          },
          "webhookUrl": {
            "title": "Webhook URL (optional)",
            "type": "string",
            "description": "POST the result file to this URL after the run (3 retries with backoff). Leave empty to skip."
          },
          "aiReady": {
            "title": "AI-ready package",
            "type": "boolean",
            "description": "Also emit JSON Schema + data dictionary + sample rows for LLM/RAG ingestion.",
            "default": true
          },
          "includeAttribution": {
            "title": "Include CC BY 4.0 attribution",
            "type": "boolean",
            "description": "Attach source/licence metadata sidecar to every output.",
            "default": true
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}