openapi: 3.1.0
info:
  title: Uncensorify API
  version: 1.1.0
  description: Music delivery platform API
servers:
  - url: https://api.uncensorify.com/v1
  - url: http://localhost:8080/v1

paths:
  /health:
    get:
      summary: Health check
      responses:
        '200':
          description: OK

  /status:
    get:
      summary: Platform status (public)
      responses:
        '200':
          description: Aggregated service health

  /auth/telegram:
    post:
      summary: Telegram Login Widget auth
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id: { type: integer }
                first_name: { type: string }
                username: { type: string }
                auth_date: { type: integer }
                hash: { type: string }
      responses:
        '200':
          description: Token pair

  /auth/refresh:
    post:
      summary: Refresh JWT tokens (rotation)
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                refresh_token: { type: string }
      responses:
        '200':
          description: New token pair

  /search:
    get:
      summary: Search tracks
      security: [{ bearerAuth: [] }]
      parameters:
        - name: q
          in: query
          required: true
          schema: { type: string }
        - name: limit
          in: query
          schema: { type: integer, default: 20 }
      responses:
        '200':
          description: Search results

  /downloads:
    post:
      summary: Request download
      security: [{ bearerAuth: [] }]
      responses:
        '200':
          description: Instant delivery
        '202':
          description: Job enqueued

  /downloads/batch:
    post:
      summary: Batch download (Premium)
      security: [{ bearerAuth: [] }]
      responses:
        '202':
          description: Batch accepted

  /playlists:
    get:
      summary: List playlists
      security: [{ bearerAuth: [] }]
      responses:
        '200':
          description: Playlists
    post:
      summary: Create playlist
      security: [{ bearerAuth: [] }]
      responses:
        '201':
          description: Created

  /playlists/{playlistID}/tracks:
    get:
      summary: List playlist tracks
      security: [{ bearerAuth: [] }]
      parameters:
        - name: playlistID
          in: path
          required: true
          schema: { type: string, format: uuid }
      responses:
        '200':
          description: Tracks
    post:
      summary: Add track to playlist
      security: [{ bearerAuth: [] }]
      responses:
        '201':
          description: Added

  /subscription/checkout:
    post:
      summary: Create payment checkout
      security: [{ bearerAuth: [] }]
      responses:
        '200':
          description: Invoice details

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
