{
  "openapi": "3.1.0",
  "info": {
    "title": "UGCdrop public catalog API",
    "version": "1.0.0",
    "description": "Free, keyless search over UGCdrop's library of real UGC video clips (reactions, hooks, b-roll) for ads, plus keyless buying at $2 a clip ($3 for premium clips): /buy returns a Stripe checkout link and an order id; /order/{id} returns the download links once paid. Add format=md to any endpoint for markdown with inline thumbnails.",
    "contact": {
      "url": "https://ugcdrop.com/api"
    }
  },
  "servers": [
    {
      "url": "https://api.ugcdrop.com"
    }
  ],
  "paths": {
    "/search": {
      "get": {
        "operationId": "searchClips",
        "summary": "Search UGC clips by words and tags",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Free text. Words that match tag names (e.g. female, surprised, skincare) are applied as tag filters.",
            "example": "surprised woman skincare"
          },
          {
            "name": "tags",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated tag names; a clip must match all of them. See /tags.",
            "example": "female,calm"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 24,
              "default": 12
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 20,
              "default": 1
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "downloads",
                "recent"
              ],
              "default": "downloads"
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "md"
              ],
              "default": "json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching clips",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SearchResult"
                }
              },
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited (60 requests/minute per IP)"
          }
        }
      }
    },
    "/tags": {
      "get": {
        "operationId": "listTags",
        "summary": "All clip tags, grouped by category",
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "md"
              ],
              "default": "json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Tags by category",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "categories": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/clip/{id}": {
      "get": {
        "operationId": "getClip",
        "summary": "One clip",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "md"
              ],
              "default": "json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The clip",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "clip": {
                      "$ref": "#/components/schemas/Clip"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/buy": {
      "get": {
        "operationId": "buyClips",
        "summary": "Start a purchase ($2 per clip, $3 premium, no account)",
        "parameters": [
          {
            "name": "clips",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Comma-separated clip ids from /search, up to 20"
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "md"
              ],
              "default": "json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Checkout started",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "order_id": {
                      "type": "string",
                      "description": "Secret receipt; keep private"
                    },
                    "amount_usd": {
                      "type": "number"
                    },
                    "checkout_url": {
                      "type": "string",
                      "format": "uri",
                      "description": "Stripe payment page for the user"
                    },
                    "status_url": {
                      "type": "string",
                      "format": "uri"
                    },
                    "clips": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/order/{order_id}": {
      "get": {
        "operationId": "getOrder",
        "summary": "Order status; once paid, download links",
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "md"
              ],
              "default": "json"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "pending (with checkout_url), expired, or paid with downloads[] (each link valid 1 hour; call again for fresh links for 7 days)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "pending",
                        "paid",
                        "expired"
                      ]
                    },
                    "checkout_url": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "downloads": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "download_url": {
                            "type": "string",
                            "format": "uri"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Clip": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "creator": {
            "type": [
              "string",
              "null"
            ]
          },
          "kind": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "real",
              "ai",
              null
            ]
          },
          "premium": {
            "type": "boolean"
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "category": {
                  "type": "string"
                }
              }
            }
          },
          "thumbnail_url": {
            "type": "string",
            "format": "uri"
          },
          "page_url": {
            "type": "string",
            "format": "uri",
            "description": "Where the user watches and downloads the clip"
          },
          "downloads": {
            "type": "integer"
          },
          "views": {
            "type": "integer"
          },
          "buy_url": {
            "type": "string",
            "format": "uri"
          },
          "price_usd": {
            "type": "number"
          }
        }
      },
      "SearchResult": {
        "type": "object",
        "properties": {
          "matched": {
            "type": "object",
            "properties": {
              "tags": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "text": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          },
          "clips": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Clip"
            }
          },
          "next": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "how_to_buy": {
            "type": "string"
          }
        }
      }
    }
  }
}