{
  "openapi": "3.0.3",
  "info": {
    "title": "ShortDramaAPI Custom Catalog (draft)",
    "description": "Draft OpenAPI description of the /api/v1 gateway. Authenticate with header x-client-api-key. Confirm paths and response schemas with ShortDramaAPI before production use.",
    "version": "0.1.0"
  },
  "servers": [
    {
      "url": "https://api.shortdramaapi.com",
      "description": "API host"
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-client-api-key",
        "description": "Client API key (e.g. pk_live_…). Keep production keys server-side only."
      }
    },
    "schemas": {
      "Envelope": {
        "type": "object",
        "properties": {
          "status": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object"
          },
          "requestId": {
            "type": "string"
          }
        }
      }
    },
    "examples": {
      "catalogTrimmed": {
        "summary": "Real sample catalog item (trimmed)",
        "value": {
          "status": true,
          "message": "Custom API catalog fetched",
          "data": {
            "data": [
              {
                "id": "vcpAlwpqSM",
                "title": "Betray Me, Crave for Me",
                "cover": "/images/demo/posters/vcpAlwpqSM.webp",
                "episode_count": 52,
                "original_audio_languages": [
                  "en-US"
                ],
                "subtitle_languages": [
                  "en-US",
                  "hi-IN"
                ]
              }
            ],
            "meta": {
              "total": 2,
              "page": 1,
              "page_size": 20,
              "hasMore": false,
              "nextCursor": null
            }
          }
        }
      },
      "episodesTrimmed": {
        "summary": "Real sample episodes (trimmed)",
        "value": {
          "status": true,
          "message": "Custom API episodes fetched",
          "data": {
            "seriesId": "vcpAlwpqSM",
            "total": 52,
            "episodes": [
              {
                "id": "OuiA2iGBsY",
                "number": 1,
                "title": "Betray Me, Crave for Me",
                "isLocked": false,
                "cover": "https://codderlab.blr1.digitaloceanspaces.com/reelsnap-hi-en/series/vcpAlwpqSM/episodes/001-OuiA2iGBsY/cover.jpg",
                "subtitles": [
                  {
                    "language": "en-US",
                    "languageName": "English",
                    "url": "https://codderlab.blr1.digitaloceanspaces.com/reelsnap-hi-en/series/vcpAlwpqSM/episodes/001-OuiA2iGBsY/subtitles/en-US.vtt",
                    "format": "vtt"
                  },
                  {
                    "language": "hi-IN",
                    "languageName": "Hindi",
                    "url": "https://codderlab.blr1.digitaloceanspaces.com/reelsnap-hi-en/series/vcpAlwpqSM/episodes/001-OuiA2iGBsY/subtitles/hi-IN.vtt",
                    "format": "vtt"
                  }
                ]
              },
              {
                "id": "cJ7KQKARLM",
                "number": 2,
                "title": "Betray Me, Crave for Me",
                "isLocked": false,
                "cover": "https://codderlab.blr1.digitaloceanspaces.com/reelsnap-hi-en/series/vcpAlwpqSM/episodes/002-cJ7KQKARLM/cover.jpg",
                "subtitles": [
                  {
                    "language": "en-US",
                    "languageName": "English",
                    "url": "https://codderlab.blr1.digitaloceanspaces.com/reelsnap-hi-en/series/vcpAlwpqSM/episodes/002-cJ7KQKARLM/subtitles/en-US.vtt",
                    "format": "vtt"
                  },
                  {
                    "language": "hi-IN",
                    "languageName": "Hindi",
                    "url": "https://codderlab.blr1.digitaloceanspaces.com/reelsnap-hi-en/series/vcpAlwpqSM/episodes/002-cJ7KQKARLM/subtitles/hi-IN.vtt",
                    "format": "vtt"
                  }
                ]
              }
            ],
            "hasMore": true,
            "nextCursor": "page:2"
          }
        }
      },
      "playbackTrimmed": {
        "summary": "Real sample playback (trimmed)",
        "value": {
          "status": true,
          "message": "Custom API playback fetched",
          "data": {
            "episode_id": "OuiA2iGBsY",
            "series_id": "vcpAlwpqSM",
            "number": 1,
            "hls_url": "https://codderlab.blr1.digitaloceanspaces.com/reelsnap-hi-en/series/vcpAlwpqSM/episodes/001-OuiA2iGBsY/index.m3u8",
            "quality": {
              "width": 720,
              "height": 1280,
              "short_side": 720,
              "requested": 720
            },
            "audio_languages": [
              "en-US"
            ],
            "subtitles": [
              {
                "language": "en-US",
                "languageName": "English",
                "url": "https://codderlab.blr1.digitaloceanspaces.com/reelsnap-hi-en/series/vcpAlwpqSM/episodes/001-OuiA2iGBsY/subtitles/en-US.vtt",
                "format": "vtt"
              },
              {
                "language": "hi-IN",
                "languageName": "Hindi",
                "url": "https://codderlab.blr1.digitaloceanspaces.com/reelsnap-hi-en/series/vcpAlwpqSM/episodes/001-OuiA2iGBsY/subtitles/hi-IN.vtt",
                "format": "vtt"
              }
            ]
          }
        }
      }
    }
  },
  "security": [
    {
      "apiKey": []
    }
  ],
  "paths": {
    "/api/v1/languages": {
      "get": {
        "summary": "Languages",
        "description": "Languages for the Custom API catalog (optional ?platform=custom-api).",
        "parameters": [
          {
            "name": "platform",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Languages fetched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          }
        }
      }
    },
    "/api/v1/custom-api/catalog": {
      "get": {
        "summary": "Catalog",
        "description": "Series summary index with pagination.",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Catalog fetched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "examples": {
                  "trimmed": {
                    "$ref": "#/components/examples/catalogTrimmed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/api/v1/custom-api/categories": {
      "get": {
        "summary": "Categories",
        "description": "Category tabs from the frozen catalog.",
        "responses": {
          "200": {
            "description": "Categories fetched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          }
        }
      }
    },
    "/api/v1/custom-api/series": {
      "get": {
        "summary": "Series search",
        "description": "Filter series by q, language, category with pagination.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "language",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Series list fetched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key"
          }
        }
      }
    },
    "/api/v1/custom-api/series/{seriesId}": {
      "get": {
        "summary": "Series detail",
        "parameters": [
          {
            "name": "seriesId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Series detail fetched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "404": {
            "description": "Series not found"
          }
        }
      }
    },
    "/api/v1/custom-api/series/{seriesId}/episodes": {
      "get": {
        "summary": "Episode list",
        "parameters": [
          {
            "name": "seriesId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Episodes fetched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "examples": {
                  "trimmed": {
                    "$ref": "#/components/examples/episodesTrimmed"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Series not found"
          }
        }
      }
    },
    "/api/v1/custom-api/series/{seriesId}/episodes/{episodeId}/playback": {
      "get": {
        "summary": "Episode playback",
        "description": "HLS URL and media fields. Playback URLs may expire; request playback again when a URL stops working.",
        "parameters": [
          {
            "name": "seriesId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "episodeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Playback fetched",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "examples": {
                  "trimmed": {
                    "$ref": "#/components/examples/playbackTrimmed"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Plan, quota, or rights restriction"
          }
        }
      }
    }
  }
}
