{
  "openapi": "3.0.1",
  "info": {
    "title": "dScribe AI",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.scribesocial.ai/v1"
    }
  ],
  "paths": {
    "/transcribe": {
      "post": {
        "tags": [
          "SocialMediaTranscription"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "includeMetadata",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SocialMediaTranscriptionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SocialMediaTranscriptionResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - The request was invalid or the social media post is unsupported for some known reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TranscribeErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found - The requested post could not be found. This may occur if the video has been removed, is private, or never existed."
          }
        }
      }
    },
    "/transcribe-batch": {
      "post": {
        "tags": [
          "SocialMediaTranscription"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchSocialMediaTranscriptionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchSocialMediaTranscriptionResponse"
                }
              }
            }
          }
        }
      }
    },
    "/durations": {
      "post": {
        "tags": [
          "SocialMediaTranscription"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "includeMetadata",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BatchSocialMediaVideoDurationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchSocialMediaVideoDurationResponse"
                }
              }
            }
          }
        }
      }
    },
    "/transcribe-result/{operationId}": {
      "get": {
        "tags": [
          "SocialMediaTranscription"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "operationId": "/v1/transcribe-result/{operationId}",
        "parameters": [
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchSocialMediaTranscriptionResponse"
                }
              }
            }
          }
        }
      }
    },
    "/scrape": {
      "post": {
        "tags": [
          "WebScrape"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebScrapeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebScrapeResponse"
                }
              }
            }
          }
        }
      }
    },
    "/analyze": {
      "post": {
        "tags": [
          "SocialMediaTranscription"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "includeMetadata",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SocialMediaAnalyzeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SocialMediaAnalyzeResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - The request was invalid or the social media post is unsupported for some known reason.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TranscribeErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found - The requested post could not be found. This may occur if the video has been removed, is private, or never existed."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "A URI reference that identifies the problem type",
            "default": "https://tools.ietf.org/html/rfc9110#section-15.5.5"
          },
          "title": {
            "type": "string",
            "description": "A short, human-readable summary of the problem type",
            "default": "Not Found"
          },
          "status": {
            "type": "integer",
            "description": "The HTTP status code",
            "default": 404
          },
          "traceId": {
            "type": "string",
            "description": "A unique identifier for this specific occurrence of the problem"
          }
        },
        "required": [
          "type",
          "title",
          "status",
          "traceId"
        ],
        "additionalProperties": false
      },
      "BatchSocialMediaTranscriptionRequest": {
        "type": "object",
        "properties": {
          "post_urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": false
          },
          "callback_url": {
            "type": "string",
            "nullable": true
          },
          "proxy_url": {
            "type": "string",
            "nullable": true
          },
          "max_mb_download_on_proxy": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "BatchSocialMediaTranscriptionResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BatchTranscriptionData"
            },
            "nullable": false
          },
          "status": {
            "$ref": "#/components/schemas/TranscriptionJobStatus"
          },
          "operation_id": {
            "type": "string",
            "nullable": false
          },
          "markdown": {
            "type": "string",
            "nullable": false
          }
        },
        "additionalProperties": false
      },
      "BatchSocialMediaVideoDurationRequest": {
        "type": "object",
        "properties": {
          "post_urls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": false
          }
        },
        "additionalProperties": false
      },
      "BatchSocialMediaVideoDurationResponse": {
        "type": "object",
        "properties": {
          "durations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VideoMetadata"
            },
            "nullable": false
          }
        },
        "additionalProperties": false
      },
      "TranscribeErrorResponse": {
        "type": "object",
        "properties": {
          "error_code": {
            "type": "string",
            "description": "A short code that quickly describes the error.",
            "enum": [
              "UnsupportedUrl",
              "NSFWUnsupported",
              "PostContainsNoVideo",
              "DownloadSizeExceeded",
              "ProxyConnectionFailure",
              "ProxyDownloadFailed",
              "Unknown"
            ]
          },
          "error_message": {
            "description": "A short description of the error that occurred.",
            "type": "string"
          }
        },
        "required": [
          "error_code",
          "error_message"
        ],
        "additionalProperties": false
      },
      "Paragraph": {
        "type": "object",
        "properties": {
          "sentences": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Sentence"
            },
            "nullable": false
          },
          "num_words": {
            "type": "integer",
            "format": "int32",
            "nullable": false
          },
          "start": {
            "type": "number",
            "format": "double",
            "nullable": false
          },
          "end": {
            "type": "number",
            "format": "double",
            "nullable": false
          }
        },
        "additionalProperties": false
      },
      "Sentence": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "nullable": false
          },
          "start": {
            "type": "number",
            "format": "double",
            "nullable": false
          },
          "end": {
            "type": "number",
            "format": "double",
            "nullable": false
          }
        },
        "additionalProperties": false
      },
      "SocialMediaTranscriptionRequest": {
        "type": "object",
        "properties": {
          "post_url": {
            "type": "string",
            "nullable": false
          },
          "callback_url": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SocialMediaAnalyzeRequest": {
        "type": "object",
        "properties": {
          "post_url": {
            "type": "string",
            "nullable": false
          },
          "callback_url": {
            "type": "string",
            "nullable": true
          },
          "query": {
            "type": "string",
            "default": null,
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SocialMediaAnalyzeResponse": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/TranscriptionJobStatus",
            "default": "completed"
          },
          "operation_id": {
            "type": "string",
            "nullable": false
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnalyzeData"
            },
            "nullable": false
          }
        },
        "additionalProperties": false
      },
      "SocialMediaTranscriptionResponse": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/TranscriptionJobStatus",
            "default": "completed"
          },
          "operation_id": {
            "type": "string",
            "nullable": false
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TranscriptionData"
            },
            "nullable": false
          },
          "markdown": {
            "type": "string",
            "nullable": false
          }
        },
        "additionalProperties": false
      },
      "BatchTranscriptionData": {
        "type": "object",
        "properties": {
          "video_url": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "transcription": {
            "type": "string",
            "nullable": true
          },
          "paragraphs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Paragraph"
            },
            "nullable": true
          },
          "video_id": {
            "type": "string",
            "nullable": true
          },
          "transcribed_duration": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "total_duration": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/TranscriptionStatus"
          },
          "error": {
            "type": "string",
            "nullable": true,
            "default": null,
            "enum": [
              "NSFWUnsupported",
              "InvalidRequestBody",
              "UnsupportedUrl",
              "NoVideoDetected",
              "TooManyVideos",
              "DownloadSizeExceeded",
              "ProxyConnectionFailure",
              "ProxyDownloadFailed"
            ]
          },
          "platform": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "AnalyzeData": {
        "allOf": [
          {
            "type": "object",
            "properties": {
              "video_summary": {
                "type": "string",
                "nullable": false
              },
              "query_result": {
                "type": "object",
                "nullable": true,
                "properties": {
                  "answer": {
                    "type": "string"
                  }
                }
              },
              "detected_brands": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/DetectedBrand"
                }
              }
            }
          },
          {
            "$ref": "#/components/schemas/TranscriptionData"
          }
        ]
      },
      "DetectedBrand": {
        "type": "object",
        "nullable": false,
        "properties": {
          "name": {
            "type": "string",
            "nullable": false
          },
          "description": {
            "type": "string",
            "nullable": false
          }
        }
      },
      "TranscriptionData": {
        "type": "object",
        "properties": {
          "video_url": {
            "type": "string",
            "nullable": false
          },
          "post_url": {
            "type": "string",
            "nullable": false
          },
          "description": {
            "type": "string",
            "nullable": false
          },
          "transcription": {
            "type": "string",
            "nullable": false
          },
          "paragraphs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Paragraph"
            },
            "nullable": false
          },
          "video_id": {
            "type": "string",
            "nullable": false
          },
          "transcribed_duration": {
            "type": "number",
            "format": "double",
            "nullable": false
          },
          "total_duration": {
            "type": "number",
            "format": "double",
            "nullable": false
          },
          "status": {
            "$ref": "#/components/schemas/TranscriptionStatus",
            "default": "completed"
          },
          "platform": {
            "type": "string",
            "nullable": false
          },
          "title": {
            "type": "string",
            "nullable": false
          },
          "metadata": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TwitterMetadata",
                "title": "Twitter"
              },
              {
                "$ref": "#/components/schemas/YouTubeMetadata",
                "title": "YouTube"
              },
              {
                "$ref": "#/components/schemas/TikTokMetadata",
                "title": "TikTok"
              },
              {
                "$ref": "#/components/schemas/InstagramMetadata",
                "title": "Instagram"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "TranscriptionJobStatus": {
        "enum": [
          "queued",
          "in_progress",
          "failed",
          "completed",
          "completed_with_failures"
        ],
        "type": "string"
      },
      "TranscriptionStatus": {
        "enum": [
          "in_progress",
          "failed",
          "completed"
        ],
        "type": "string"
      },
      "VideoMetadata": {
        "type": "object",
        "properties": {
          "video_url": {
            "type": "string",
            "nullable": true
          },
          "video_id": {
            "type": "string",
            "nullable": true
          },
          "duration": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "metadata": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/TwitterMetadata",
                "title": "Twitter"
              },
              {
                "$ref": "#/components/schemas/YouTubeMetadata",
                "title": "YouTube"
              },
              {
                "$ref": "#/components/schemas/TikTokMetadata",
                "title": "TikTok"
              },
              {
                "$ref": "#/components/schemas/InstagramMetadata",
                "title": "Instagram"
              }
            ]
          },
          "error": {
            "type": "string",
            "nullable": true,
            "enum": [
              "UnsupportedUrl",
              "InvalidUrl",
              "TooManyBatchUrls",
              "NoBatchUrls",
              "TooManyDurationsUrls",
              "NSFWUnsupported",
              "PostNotFoundOrUnavailable",
              "PostContainsNoVideo",
              "Unknown"
            ],
            "default": null
          }
        },
        "additionalProperties": false
      },
      "TwitterMetadata": {
        "type": "object",
        "properties": {
          "upload_time": {
            "type": "string",
            "format": "date-time",
            "nullable": false
          },
          "comment_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          },
          "like_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          },
          "thumbnail": {
            "type": "string",
            "nullable": false
          },
          "retweet_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          },
          "quote_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          }
        },
        "nullable": true,
        "additionalProperties": false
      },
      "YouTubeMetadata": {
        "type": "object",
        "properties": {
          "upload_time": {
            "type": "string",
            "format": "date-time",
            "nullable": false
          },
          "comment_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          },
          "like_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          },
          "thumbnail": {
            "type": "string",
            "nullable": false
          }
        },
        "nullable": true,
        "additionalProperties": false
      },
      "TikTokMetadata": {
        "type": "object",
        "properties": {
          "upload_time": {
            "type": "string",
            "format": "date-time",
            "nullable": false
          },
          "comment_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          },
          "like_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          },
          "thumbnail": {
            "type": "string",
            "nullable": false
          },
          "share_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          },
          "play_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          }
        },
        "nullable": true,
        "additionalProperties": false
      },
      "InstagramMetadata": {
        "type": "object",
        "properties": {
          "upload_time": {
            "type": "string",
            "format": "date-time",
            "nullable": false
          },
          "comment_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          },
          "like_count": {
            "type": "integer",
            "format": "int64",
            "nullable": false
          },
          "thumbnail": {
            "type": "string",
            "nullable": false
          }
        },
        "nullable": true,
        "additionalProperties": false
      },
      "WebScrapeRequest": {
        "type": "object",
        "properties": {
          "post_url": {
            "type": "string",
            "nullable": false
          }
        },
        "additionalProperties": false
      },
      "WebScrapeResponse": {
        "type": "object",
        "properties": {
          "markdown": {
            "type": "string",
            "nullable": false
          },
          "videos": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TranscriptionData"
            },
            "nullable": false
          }
        },
        "additionalProperties": false
      },
      "PostTranscribedEvent": {
        "type": "object",
        "required": [
          "event_type",
          "operation_id",
          "data"
        ],
        "properties": {
          "event_type": {
            "type": "string",
            "enum": [
              "post_transcribed_event"
            ],
            "description": "Type of the event"
          },
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the batch operation"
          },
          "data": {
            "type": "array",
            "description": "Array containing a single post's transcription result",
            "items": {
              "$ref": "#/components/schemas/BatchTranscriptionData"
            }
          }
        }
      },
      "BatchTranscribeCompletedEvent": {
        "type": "object",
        "required": [
          "event_type",
          "operation_id",
          "status",
          "data"
        ],
        "properties": {
          "event_type": {
            "type": "string",
            "enum": [
              "batch_transcribe_completed_event"
            ],
            "description": "Type of the event"
          },
          "operation_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the batch operation"
          },
          "status": {
            "type": "string",
            "enum": [
              "completed",
              "completed_with_failures",
              "failed"
            ],
            "description": "The final status of the batch operation"
          },
          "data": {
            "type": "array",
            "description": "Array containing all transcription results",
            "items": {
              "$ref": "#/components/schemas/BatchTranscriptionData"
            }
          },
          "markdown": {
            "type": "string",
            "nullable": false
          }
        }
      }
    }
  }
}