{
  "openapi": "3.0.1",
  "info": {
    "title": "📈 Price History Builder - Volatility, Promo Cadence & Bands",
    "description": "📈 Accumulate per-product price history across scheduled runs into analytics nobody else offers. ✅ Volatility (stdev/CV), promo cadence (frequency, gap, discount depth), price bands with today's percentile, a next-drop estimate, and trend. Scrape URLs or feed a price list — testable offline.",
    "version": "1.0",
    "x-build-id": "jQapP7CTQ2PWkY7mh"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/that_red_bird~price-history-builder/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-that_red_bird-price-history-builder",
        "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/that_red_bird~price-history-builder/runs": {
      "post": {
        "operationId": "runs-sync-that_red_bird-price-history-builder",
        "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/that_red_bird~price-history-builder/run-sync": {
      "post": {
        "operationId": "run-sync-that_red_bird-price-history-builder",
        "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": {
          "products": {
            "title": "Product URLs (optional)",
            "type": "array",
            "description": "Product pages to scrape for today's price. Plain URLs, or objects like {\"url\":\"https://…\",\"label\":\"nike-air-42\",\"priceSelector\":\".price\"}. Price is auto-detected from JSON-LD, microdata or common price containers unless priceSelector is given. Leave empty if you only use \"prices\".",
            "default": [
              "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
            ]
          },
          "prices": {
            "title": "Supplied price list (optional)",
            "type": "array",
            "description": "Feed today's price directly instead of scraping — your own feed, spreadsheet export, or a previous scrape. Each item: {\"key\":\"sku-123\",\"price\":19.99,\"url\":\"https://…\",\"currency\":\"USD\",\"title\":\"…\",\"at\":\"2026-01-01T00:00:00Z\"}. Only \"key\" and \"price\" are required; \"at\" defaults to now. This is what makes the analytics testable fully offline and usable as a pure analytics step with no network access at all. Leave empty if you only use \"products\"."
          },
          "priceSelector": {
            "title": "Price CSS selector (optional)",
            "type": "string",
            "description": "Default selector applied to every URL in \"products\" that doesn't specify its own priceSelector. Leave empty to rely on automatic price detection."
          },
          "maxHistory": {
            "title": "Max history length per product",
            "minimum": 2,
            "maximum": 1000,
            "type": "integer",
            "description": "Cap on how many past price points are kept per product key in the state store. Oldest points are dropped once the cap is reached.",
            "default": 90
          },
          "promoDropThresholdPercent": {
            "title": "Promo detection threshold (%)",
            "minimum": 1,
            "maximum": 90,
            "type": "integer",
            "description": "A price point counts as a discount event when it sits at least this many percent below the rolling baseline (the median of the prior points). Lower catches smaller sales; higher only catches deep discounts.",
            "default": 8
          },
          "promoBaselineWindow": {
            "title": "Promo baseline window (points)",
            "minimum": 1,
            "maximum": 50,
            "type": "integer",
            "description": "How many of the immediately preceding price points are used to compute the rolling baseline that a new point is compared against for discount detection.",
            "default": 5
          },
          "minEventsForPrediction": {
            "title": "Minimum discount events before predicting",
            "minimum": 1,
            "maximum": 10,
            "type": "integer",
            "description": "The next-drop estimate is withheld until at least this many discount events have been observed for a product. More history in, more honest prediction out.",
            "default": 2
          },
          "alertPercentile": {
            "title": "Good-deal alert percentile",
            "minimum": 0,
            "maximum": 100,
            "type": "integer",
            "description": "Fire an alert when today's price is at or below this percentile of everything ever observed for that product (0 = the all-time low, 50 = the median price, 100 = never alerts).",
            "default": 25
          },
          "trendFlatBandPercent": {
            "title": "Trend flat band (%)",
            "minimum": 0,
            "maximum": 50,
            "type": "integer",
            "description": "Total change across the series smaller than this percent (either direction) is classified as STABLE rather than RISING/FALLING, so normal noise doesn't get reported as a trend.",
            "default": 2
          },
          "resetHistory": {
            "title": "Reset history",
            "type": "boolean",
            "description": "Forget stored price series and start fresh for every product in this run. Use after a bad scrape poisoned the history.",
            "default": false
          },
          "onlyAlerts": {
            "title": "Only output alerts",
            "type": "boolean",
            "description": "Push only rows where the good-deal alert fired. Recommended when tracking hundreds of products.",
            "default": false
          },
          "maxItems": {
            "title": "Max output rows",
            "minimum": 0,
            "type": "integer",
            "description": "Hard cap on dataset rows per run. 0 = no cap.",
            "default": 0
          },
          "renderJs": {
            "title": "Render JavaScript",
            "type": "boolean",
            "description": "Only needed for shops in \"products\" that build the price in the browser. Slower and more expensive. Has no effect on the supplied \"prices\" list.",
            "default": false
          },
          "customHeaders": {
            "title": "Custom headers",
            "type": "object",
            "description": "Extra request headers for scraping \"products\", e.g. a Cookie header for region-locked or logged-in pricing."
          },
          "concurrency": {
            "title": "Concurrency",
            "minimum": 1,
            "maximum": 20,
            "type": "integer",
            "description": "How many products (URL scrapes or supplied entries) to process in parallel.",
            "default": 5
          },
          "stateStoreName": {
            "title": "State store name",
            "type": "string",
            "description": "Named key-value store holding each product's accumulated price series. Use different names to keep separate history sets.",
            "default": "price-history-builder-state"
          },
          "proxyConfiguration": {
            "title": "Proxy",
            "type": "object",
            "description": "Optional Apify proxy configuration for shops in \"products\" that block datacenter traffic. Has no effect on the supplied \"prices\" list."
          }
        }
      },
      "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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}