openapi: 3.0.3
info:
  title: core-images API
  description: SME/Atlas core service for image resources
  termsOfService: https://www.sonymusic.com/terms-and-conditions/
  license:
    name: Proprietary
  version: 1.1.0
paths:
  "/v2/albums/by_gras_product_id/{gras_product_id}":
    summary: Album cover by GRAS product ID
    parameters:
      - name: gras_product_id
        in: path
        description: GRAS product ID of album
        required: true
        schema:
          type: string
      - name: fallback_spotify_id
        in: query
        description: Fallback Spotify album ID if there is no GRAS image.
        required: false
        schema:
          type: string
      - name: with_placeholders
        in: query
        description: Flag param to include placeholders images
        required: false
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [ small, medium, large ]
    get:
      operationId: album_by_gras_product_id
      summary: Fetch album cover by GRAS product ID
      description:
        If the fallback ID is provided, then the fallback image would
        be requested and provided if exists.
      responses:
        "307":
          description: Redirect to image on Sony Music’s CDN
          headers:
            X-Image-Type:
              description: Whether the image is original or a placeholder
              schema:
                type: string
                pattern: "^(original|placeholder)$"
        "404":
          description: Either that GRAS ID is not a valid product, or
            that product does not have an image associated with it.
        "503":
          description: The underlying service was not available at
            this time.
      tags:
        - album
        - SCUBA
  "/v2/albums/by_gras_product_ids/{gras_product_ids}":
    summary: Album covers by GRAS product IDs
    parameters:
      - name: gras_product_ids
        in: path
        description: Coma separated list of GRAS product IDs of albums
        required: true
        schema:
          type: string
      - name: with_placeholders
        in: query
        description: Flag param to include placeholders images
        required: false
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [ small, medium, large ]
    get:
      operationId: album_by_gras_product_ids
      summary: Fetch albums covers by GRAS product IDs
      description: Batch endpoint to fetch multiple urls
      responses:
        "200":
          description: Mapping of ids and urls
        "404":
          description: Either that GRAS ID is not a valid product, or
            that product does not have an image associated with it.
      tags:
        - album
        - SCUBA
  "/v2/albums/by_spotify_id/{spotify_album_id}":
    summary: Album cover by Spotify album ID
    parameters:
      - name: spotify_album_id
        in: path
        description: Spotify ID of album (not URN)
        required: true
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [ small, medium, large ]
    get:
      operationId: album_by_spotify_id
      summary: Fetch album cover by Spotify album ID
      responses:
        "307":
          description: Redirect to image on Spotify’s CDN
        "404":
          description: That ID is not a recognized album.
        "503":
          description: The Spotify API was not available at this time.
      tags:
        - album
        - Spotify
  "/v2/albums/by_spotify_track_id/{spotify_track_id}":
    summary: Album cover by Spotify track ID
    parameters:
      - name: spotify_track_id
        in: path
        description: Spotify ID of track (not URN)
        required: true
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [ small, medium, large ]
    get:
      operationId: album_by_spotify_track_id
      summary: Fetch album cover by Spotify track ID
      description: >
        Spotify doesn’t give tracks their own artwork, so
        the images returned are associated with the album for a
        track. This necessarily means that this endpoint has an
        additional point of failure: if the track isn’t associated
        with an album it won’t have any artwork of its own to return
        and the service will send back a 404 Not Found.
      responses:
        "307":
          description: Redirect to image on Spotify’s CDN
        "404":
          description: Either the ID is not a recognized track or
            there is no artwork available for that track.
        "503":
          description: The Spotify API was not available at this time.
      tags:
        - album
        - Spotify
  "/v2/artists/by_gras_participant_id/{gras_participant_id}":
    summary: Artist photo by GRAS participant ID
    parameters:
      - name: gras_participant_id
        in: path
        description: GRAS participant ID of artist
        required: true
        schema:
          type: string
      - name: fallback_spotify_id
        in: query
        description: Fallback Spotify artist ID if there is no GRAS image
        required: false
        schema:
          type: string
      - name: with_placeholders
        in: query
        description: Flag param to include placeholders images
        required: false
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [small, medium, large]
    get:
      operationId: artist_by_gras_participant_id
      summary: Fetch artist photo by GRAS participant ID
      responses:
        "302":
          description: Redirect to image on Sony Music’s domain
          headers:
            X-Image-Type:
              description: Whether the image is original or a placeholder
              schema:
                type: string
                pattern: "^(original|placeholder)$"
        "404":
          description: Unable to find participant
        "503":
          description: The underlying service was not available at
            this time.
      tags:
        - artist
        - SCUBA
  "/v2/artists/by_gras_participant_ids/{gras_participant_ids}":
    summary: Artist photos by GRAS participant IDs
    parameters:
      - name: gras_participant_ids
        in: path
        description: Coma separated list of GRAS participant IDs of artists
        required: true
        schema:
          type: string
      - name: with_placeholders
        in: query
        description: Flag param to include placeholders images
        required: false
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [ small, medium, large ]
    get:
      operationId: artist_by_gras_participant_ids
      summary: Fetch artist photos by GRAS participant IDs
      description: Batch endpoint to fetch multiple urls
      responses:
        "200":
          description: Mapping of ids and urls
        "404":
          description: Either that GRAS ID is not a valid album, or
            that album does not have an image associated with it.
      tags:
        - artist
        - SCUBA
  "/v2/artists/by_spotify_id/{spotify_artist_id}":
    summary: Artist photo by Spotify artist ID
    parameters:
      - name: spotify_artist_id
        in: path
        description: Spotify ID of artist (not URN)
        required: true
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [ small, medium, large ]
    get:
      operationId: artist_by_spotify_id
      summary: Fetch artist photo by Spotify artist ID
      responses:
        "307":
          description: Redirect to image on Spotify’s CDN
        "404":
          description: Either the artist ID was not recognized by
            Spotify, or no image is associated with that artist in
            Spotify.
        "503":
          description: The Spotify API was not available at this time.
      tags:
        - artist
        - Spotify
  "/v2/albums/by_apple_music_id/{apple_album_id}":
    summary: Album image by Apple Music album ID
    parameters:
      - name: apple_album_id
        in: path
        description: Apple Music album ID
        required: true
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [ small, medium, large ]
      - name: storefront
        in: query
        description: Apple storefront of the images.
          ID from available storefronts
          by https://api.music.apple.com/v1/storefronts
        required: false
        schema:
          type: string
          example: us
    get:
      operationId: album_by_apple_music_id
      summary: Fetch album image by Apple Music album ID
      description: >-
        By default, this image is requested from the Apple Music API as a 160
        pixel square.
      responses:
        "302":
          description: Redirect to image on Apple’s CDN
        "404":
          description: Unable to find album in Apple Music
        "503":
          description: The Apple Music API was not available at this
            time.
      tags:
        - album
        - Apple Music
  "/v2/albums/by_apple_track_id/{apple_track_id}":
    summary: Album image by Apple Music track ID
    parameters:
      - name: apple_track_id
        in: path
        description: Apple Music track ID
        required: true
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [ small, medium, large ]
      - name: storefront
        in: query
        description: Apple storefront of the images.
          ID from available storefronts
          by https://api.music.apple.com/v1/storefronts
        required: false
        schema:
          type: string
          example: us
    get:
      operationId: album_by_apple_track_id
      summary: Fetch album image by Apple Music track ID
      description: >-
        By default, this image is requested from the Apple Music API as a 160
        pixel square.
      responses:
        "302":
          description: Redirect to image on Apple’s CDN
        "404":
          description: Unable to find album in Apple Music
        "503":
          description: The Apple Music API was not available at this
            time.
      tags:
        - album
        - Apple Music
  "/v2/playlists/by_apple_music_id/{playlist_id}":
    summary: Playlist image by Apple Music playlist ID
    parameters:
      - name: playlist_id
        in: path
        description: Apple Music playlist ID, including "pl." prefix
        required: true
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [ small, medium, large ]
      - name: storefront
        in: query
        description: Apple storefront of the images.
          ID from available storefronts
          by https://api.music.apple.com/v1/storefronts
        required: false
        schema:
          type: string
          example: us
    get:
      operationId: playlist_by_apple_music_id
      summary: Fetch playlist image by Apple Music playlist ID
      description: >-
        By default, this image is requested from the Apple Music API as a 256
        pixel square, but no guarantee is made that the result will match those
        dimensions.

        Testing has not revealed a way to create a public Apple Music playlist without a cover image, so if that situation is detected this endpoint is expected to return a 404 rather than a default image location.
      responses:
        "302":
          description: Redirect to image on Apple’s CDN
        "404":
          description: Unable to find playlist in Apple Music
        "503":
          description: The Apple Music API was not available at this
            time.
      tags:
        - playlist
        - Apple Music
      externalDocs:
        description: Sequence diagram for playlist_by_apple_music_id
        url: /core-images/sequence/playlist_by_apple_music_id.svg
  "/v2/playlists/by_spotify_id/{playlist_id}":
    summary: Playlist image by Spotify playlist ID
    parameters:
      - name: playlist_id
        in: path
        description: Spotify playlist ID
        required: true
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [ small, medium, large ]
    get:
      operationId: playlist_by_spotify_id
      summary: Fetch playlist image by Spotify playlist ID
      description: Spotify’s API allows for the possibility of multiple images representing
        a playlist. If this is the case, this endpoint arbitrarily chooses the
        first image returned.
      responses:
        "302":
          description: Redirect to image on Spotify’s CDN
        "404":
          description: Unable to find playlist in Spotify
        "503":
          description: The Spotify API was not available at this time.
      tags:
        - playlist
        - Spotify
  "/v2/labels/by_label_id/{label_id}":
    summary: Label image label ID
    parameters:
      - name: label_id
        in: path
        description: Label ID
        required: true
        schema:
          type: string
      - name: resolution
        in: query
        description: "Resolution of the images (default: small)"
        required: false
        schema:
          type: string
          enum: [ small, medium, large ]
    get:
      operationId: label_by_label_id
      summary: Fetch label image by label ID
      description: Label images from internal storage
      responses:
        "302":
          description: Redirect to image on internal CDN
        "404":
          description: Unable to label
      tags:
        - label
