openapi: 3.0.0
info:
  title: YouTube Channel Shorts API
  description: |
    Retrieve the shorts feed of a YouTube channel, sorted by latest, popular, or oldest, with pagination support.

    **Cross-linking**: The channel ID returned by this API can be used with the YouTube Channel API to fetch detailed channel information. Short IDs are YouTube video IDs and can be used with the YouTube Video Details API to get comprehensive video information.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: YouTube Channel Shorts Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: Search engine to use
          schema:
            type: string
            enum: ["youtube_channel_shorts"]
        - name: channel_id
          in: query
          required: true
          description: The YouTube channel ID or handle (e.g., "@MrBeast" or "UCX6OQ3DkcsbYNE6H8uQQuVA")
          schema:
            type: string
        - name: gl
          in: query
          required: false
          description: Country code for localized results (ISO 3166-1 alpha-2)
          schema:
            type: string
            enum: ["DZ", "AR", "AU", "AT", "AZ", "BH", "BD", "BY", "BE", "BO", "BA", "BR", "BG", "KH", "CA", "CL", "CO", "CR", "HR", "CY", "CZ", "DK", "DO", "EC", "EG", "SV", "EE", "FI", "FR", "GE", "DE", "GH", "GR", "GT", "HN", "HK", "HU", "IS", "IN", "ID", "IQ", "IE", "IL", "IT", "JM", "JP", "JO", "KZ", "KE", "KW", "LA", "LV", "LB", "LY", "LI", "LT", "LU", "MY", "MT", "MX", "ME", "MA", "NP", "NL", "NZ", "NI", "NG", "MK", "NO", "OM", "PK", "PA", "PG", "PY", "PE", "PH", "PL", "PT", "PR", "QA", "RO", "RU", "SA", "SN", "RS", "SG", "SK", "SI", "ZA", "KR", "ES", "LK", "SE", "CH", "TW", "TZ", "TH", "TN", "TR", "UG", "UA", "AE", "GB", "US", "UY", "VE", "VN", "YE", "ZW"]
            default: "US"
        - name: hl
          in: query
          required: false
          description: Language code for the interface language
          schema:
            type: string
            enum: ["af", "az", "id", "ms", "bs", "ca", "cs", "da", "de", "et", "en-in", "en-gb", "en", "es", "es-419", "es-us", "eu", "fil", "fr", "fr-ca", "gl", "hr", "zu", "is", "it", "sw", "lv", "lt", "hu", "nl", "no", "uz", "pl", "pt-pt", "pt", "ro", "sq", "sk", "sl", "sr-latn", "fi", "sv", "vi", "tr", "be", "bg", "ky", "kk", "mk", "mn", "ru", "sr", "uk", "el", "hy", "iw", "ur", "ar", "fa", "ne", "mr", "hi", "as", "bn", "pa", "gu", "or", "ta", "te", "kn", "ml", "si", "th", "lo", "my", "ka", "am", "km", "zh-cn", "zh-tw", "zh-hk", "ja", "ko"]
            default: "en"
        - name: sort_by
          in: query
          required: false
          description: Sort order for the shorts
          schema:
            type: string
            enum: ["latest", "popular", "oldest"]
            default: "latest"
        - name: next_page_token
          in: query
          required: false
          description: Token for pagination to retrieve the next page of results
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SearchResponse'
        '400':
          description: Validation Error. There is an issue with query parameters, such as missing required parameters or invalid values.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Authentication Error. The API key is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate Limit Exceeded. The number of allowed requests has been exceeded. Consider upgrading your plan or waiting for the limit to reset.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server Error. Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Timeout. We could not retrieve results in 90 seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Use Bearer authentication. Format: "Bearer YOUR_API_KEY"'
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api_key
      description: Pass API key as query parameter
  schemas:
    SearchResponse:
      type: object
      properties:
        search_metadata:
          $ref: '#/components/schemas/SearchMetadata'
        search_parameters:
          $ref: '#/components/schemas/SearchParameters'
        channel:
          allOf:
            - $ref: '#/components/schemas/Channel'
          description: Channel information. Present on first-page requests without a sort or with sort_by=latest; omitted on sort_by=popular, sort_by=oldest, and paginated requests.
        shorts:
          type: array
          items:
            $ref: '#/components/schemas/Short'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Error message if the search failed
    SearchMetadata:
      type: object
      required: [id, status, created_at]
      properties:
        id:
          type: string
          description: Unique identifier for the search request
        status:
          type: string
          description: Status of the search request
        created_at:
          type: string
          format: date-time
          description: Timestamp when the search was created
        request_time_taken:
          type: number
          description: Time taken to make the request in seconds
        parsing_time_taken:
          type: number
          description: Time taken to parse the results in seconds
        total_time_taken:
          type: number
          description: Total time taken for the search in seconds
        request_url:
          type: string
          description: YouTube URL for this search
        html_url:
          type: string
          description: URL to view HTML results
        json_url:
          type: string
          description: URL to view JSON results
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: The search engine used
        channel_id:
          type: string
          description: The YouTube channel ID or handle
        gl:
          type: string
          description: Country code used for the search
        hl:
          type: string
          description: Language code used for the search
        sort_by:
          type: string
          description: Sort order used for the search
        next_page_token:
          type: string
          description: Pagination token used for this request
    Channel:
      type: object
      properties:
        handle:
          type: string
          description: Channel handle (e.g., "@MrBeast")
        id:
          type: string
          description: Unique channel identifier
        title:
          type: string
          description: Channel name
        subscribers:
          type: integer
          description: Number of channel subscribers
        videos:
          type: integer
          description: Total number of videos on the channel
        description:
          type: string
          description: Channel description
        keywords:
          type: string
          description: Channel keywords
        tags:
          type: array
          items:
            type: string
          description: Channel tags
        available_countries:
          type: array
          items:
            type: string
          description: Countries where the channel is available
        badges:
          type: array
          items:
            type: string
          description: Channel badges and certifications
        first_link:
          type: string
          description: Primary external link for the channel
        is_verified:
          type: boolean
          description: Whether the channel is verified
        is_family_safe:
          type: boolean
          description: Whether the channel is family-safe
        banner:
          type: string
          description: URL to channel banner image
        avatar:
          type: string
          description: URL to channel avatar image
    Short:
      type: object
      properties:
        position:
          type: integer
          description: Position in the results
        id:
          type: string
          description: YouTube video ID of the short
        title:
          type: string
          description: Short title
        link:
          type: string
          description: Direct link to the short
        views:
          type: integer
          description: Approximate number of views
        thumbnail:
          type: string
          description: URL to the short thumbnail image
    Pagination:
      type: object
      properties:
        next_page_token:
          type: string
          description: Token to retrieve the next page of results in the current sort order
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
