{
  "openapi": "3.0.3",
  "info": {
    "title": "PricePulse API",
    "description": "Real-time price comparison API for Southeast Asian e-commerce platforms. Search products, get trending items, find arbitrage opportunities, and track price history across Carousell SG, Amazon SG, Lazada, and Vinted.",
    "version": "1.0.0",
    "contact": {
      "name": "PricePulse Team",
      "url": "https://incl-coupons-question-pair.trycloudflare.com"
    },
    "x-logo": {
      "url": "https://incl-coupons-question-pair.trycloudflare.com/favicon.ico"
    }
  },
  "servers": [
    {
      "url": "https://incl-coupons-question-pair.trycloudflare.com",
      "description": "Production server"
    },
    {
      "url": "http://localhost:8000",
      "description": "Local development"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Get your free API key at https://incl-coupons-question-pair.trycloudflare.com/pricing"
      }
    },
    "schemas": {
      "Product": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "price": {
            "type": "number"
          },
          "currency": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "carousell",
              "amazon",
              "lazada",
              "vinted"
            ]
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "image_url": {
            "type": "string",
            "format": "uri"
          },
          "views": {
            "type": "integer"
          }
        }
      }
    }
  },
  "paths": {
    "/search": {
      "get": {
        "summary": "Search products",
        "description": "Search for products across multiple e-commerce platforms",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Search query"
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "carousell",
                "amazon",
                "lazada",
                "vinted"
              ]
            },
            "description": "Limit to specific platform"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 20
            },
            "description": "Results per page"
          }
        ],
        "responses": {
          "200": {
            "description": "Search results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Product"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/trending": {
      "get": {
        "summary": "Get trending products",
        "description": "Returns the most popular/trending products across platforms",
        "parameters": [
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Trending products"
          }
        }
      }
    },
    "/arbitrage": {
      "get": {
        "summary": "Find arbitrage opportunities",
        "description": "Discover cross-platform price differences for profitable arbitrage",
        "parameters": [
          {
            "name": "min_profit",
            "in": "query",
            "schema": {
              "type": "number",
              "default": 10
            },
            "description": "Minimum profit margin %"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Arbitrage opportunities"
          }
        }
      }
    },
    "/categories": {
      "get": {
        "summary": "Browse categories",
        "parameters": [
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Category list"
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Health check",
        "responses": {
          "200": {
            "description": "API is healthy"
          }
        }
      }
    }
  }
}