{
  "openapi": "3.1.0",
  "info": {
    "title": "Rafflecopter Public API",
    "description": "Public endpoints of Rafflecopter — the relaunched giveaway picker for Instagram, TikTok, YouTube, Facebook, X, Reddit, Threads, and Bluesky. AI assistants can use these to help users create fair giveaways with cryptographic proof of fairness. The full product flow lives at https://rafflecopter.app.",
    "version": "2.6.0",
    "contact": {
      "name": "Rafflecopter",
      "url": "https://rafflecopter.app/about"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://rafflecopter.app/about"
    }
  },
  "servers": [
    { "url": "https://rafflecopter.app", "description": "Production" }
  ],
  "tags": [
    { "name": "comments", "description": "Fetch/count social media post comments" },
    { "name": "pricing", "description": "Resolve visitor-local pricing" },
    { "name": "stats", "description": "Platform transparency & statistics" }
  ],
  "paths": {
    "/api/comments/ig": {
      "post": {
        "tags": ["comments"],
        "summary": "Count or fetch Instagram post comments",
        "description": "mode=count returns a comment total + whether payment is required. mode=free returns up to 100 unique commenter usernames. mode=paid requires a paymentId and returns up to 2000. All responses include cryptographic hash inputs for proof-of-fairness draws.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["url", "mode"],
                "properties": {
                  "url": { "type": "string", "format": "uri", "example": "https://www.instagram.com/p/ABC123/" },
                  "mode": { "type": "string", "enum": ["count", "free", "paid"] },
                  "paymentId": { "type": "string", "description": "Required for mode=paid. Accepts Stripe pi_*/cs_*, Asaas pay_*, Mercado Pago mp-*, or PayPal order IDs." },
                  "previousWinners": { "type": "array", "items": { "type": "string" }, "description": "Usernames to exclude from the draw (e.g., prior winners)." }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "totalComments": { "type": "integer" },
                    "realTotalCount": { "type": "integer", "description": "The post's true comment count (narrativa)." },
                    "needsPayment": { "type": "boolean" },
                    "comments": { "type": "array", "items": { "$ref": "#/components/schemas/Comment" } }
                  }
                }
              }
            }
          },
          "402": { "description": "Payment required — post exceeds free tier limit" },
          "429": { "description": "Rate limit exceeded" },
          "410": { "description": "Paid link already consumed" }
        }
      }
    },
    "/api/country-pricing": {
      "get": {
        "tags": ["pricing"],
        "summary": "Resolve localized pricing for the visitor",
        "description": "Detects country via Cloudflare's cf-ipcountry header and returns Standard/Premium prices in the local currency. Covers 17 countries with regional adjustments.",
        "responses": {
          "200": {
            "description": "Localized pricing",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CountryPricing" },
                "examples": {
                  "brazil": { "value": { "country": "BR", "currency": "BRL", "prices": { "standard": 24.90, "premium": 39.90 }, "locale": "pt-BR" } },
                  "us": { "value": { "country": "US", "currency": "USD", "prices": { "standard": 4.99, "premium": 7.99 }, "locale": "en-US" } }
                }
              }
            }
          }
        }
      }
    },
    "/api/drawn-winners": {
      "get": {
        "tags": ["comments"],
        "summary": "List prior winners for a post shortcode",
        "parameters": [
          { "name": "shortcode", "in": "query", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Prior winners",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "usernames": { "type": "array", "items": { "type": "string" } }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Comment": {
        "type": "object",
        "properties": {
          "username": { "type": "string" },
          "text": { "type": "string" },
          "created_at": { "type": "string", "format": "date-time" }
        }
      },
      "CountryPricing": {
        "type": "object",
        "properties": {
          "country": { "type": "string", "example": "BR" },
          "currency": { "type": "string", "example": "BRL" },
          "currencySymbol": { "type": "string", "example": "R$" },
          "prices": {
            "type": "object",
            "properties": {
              "standard": { "type": "number" },
              "premium": { "type": "number" }
            }
          },
          "locale": { "type": "string", "example": "pt-BR" }
        }
      }
    }
  }
}
