openapi: 3.0.0
info:
  title: Shazam Search API
  description: |
    Search Shazam for songs and artists, as the search box on shazam.com does.

    Each song carries its title, credited artist name, Apple Music song id and links to shazam.com and Apple Music. Album name and id, ids of artists Apple Music links to the song, duration, genres, artwork, audio previews, ISRC, release date, track number and disc number are included when available. Each artist carries its Apple Music artist id and links, plus genres when available. `country` picks the catalog searched and `lang` the language of its labels.

    Shazam returns at most 100 songs and 100 artists per search, 25 of each per page.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Shazam Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Search engine. Must be set to: `shazam_search`'
          schema:
            type: string
            enum: ["shazam_search"]
        - name: q
          in: query
          required: true
          description: The song, artist or words to search for.
          schema:
            type: string
            maxLength: 500
        - name: type
          in: query
          required: false
          description: The kind of result to return. Leave it out to get both songs and artists, as shazam.com's search box shows.
          schema:
            type: string
            enum: ["songs", "artists"]
        - name: country
          in: query
          required: false
          description: Country whose catalog is searched (ISO 3166-1 alpha-2). Each country has its own catalog and ranking.
          schema:
            type: string
            enum: ["ae", "ag", "ai", "al", "am", "ao", "ar", "at", "au", "az", "ba", "bb", "be", "bf", "bg", "bh", "bj", "bm", "bn", "bo", "br", "bs", "bt", "bw", "by", "bz", "ca", "cd", "cg", "ch", "ci", "cl", "cm", "cn", "co", "cr", "cv", "cy", "cz", "de", "dk", "dm", "do", "dz", "ec", "ee", "eg", "es", "fi", "fj", "fm", "fr", "ga", "gb", "gd", "ge", "gh", "gm", "gr", "gt", "gw", "gy", "hk", "hn", "hr", "hu", "id", "ie", "il", "in", "iq", "is", "it", "jm", "jo", "jp", "ke", "kg", "kh", "kn", "kr", "kw", "ky", "kz", "la", "lb", "lc", "lk", "lr", "lt", "lu", "lv", "ly", "ma", "md", "me", "mg", "mk", "ml", "mm", "mn", "mo", "mr", "ms", "mt", "mu", "mv", "mw", "mx", "my", "mz", "na", "ne", "ng", "ni", "nl", "no", "np", "nz", "om", "pa", "pe", "pg", "ph", "pk", "pl", "pt", "py", "qa", "ro", "rs", "ru", "rw", "sa", "sb", "sc", "se", "sg", "si", "sk", "sl", "sn", "sr", "st", "sv", "sz", "tc", "td", "th", "tj", "tm", "tn", "to", "tr", "tt", "tw", "tz", "ua", "ug", "us", "uy", "uz", "vc", "ve", "vg", "vn", "vu", "xk", "ye", "za", "zm", "zw"]
            default: "us"
        - name: lang
          in: query
          required: false
          description: Language of genre names and other labels. Each country takes its own languages, listed on the country parameter page, and defaults to the first of them.
          schema:
            type: string
            enum: ["ar", "bn", "ca", "cs", "da", "de-ch", "de-de", "el", "en-au", "en-ca", "en-gb", "en-us", "es-es", "es-mx", "fi", "fr-ca", "fr-fr", "gu", "he", "hi", "hr", "hu", "id", "it", "ja", "kn", "ko", "ml", "mr", "ms", "nb", "nl", "or", "pa", "pl", "pt-br", "pt-pt", "ro", "ru", "sk", "sl", "sv", "ta", "te", "th", "tr", "uk", "ur", "vi", "zh-hans-cn", "zh-hant-hk", "zh-hant-tw"]
        - name: page
          in: query
          required: false
          description: Page of results, with up to 25 songs and 25 artists each. A later page can repeat a song from an earlier one.
          schema:
            type: integer
            minimum: 1
            maximum: 4
            default: 1
        - name: zero_retention
          in: query
          required: false
          description: Set to true to keep request parameters, HTML, and JSON responses out of storage and logs. Enterprise plans only.
          schema:
            type: boolean
            default: false
      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'
        '403':
          description: Forbidden. The account lacks access to zero data retention, or it requires `zero_retention=true`.
          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'
        search_information:
          $ref: '#/components/schemas/SearchInformation'
        songs:
          type: array
          description: Songs Shazam lists for the search, in Shazam's order.
          items:
            $ref: '#/components/schemas/Song'
        artists:
          type: array
          description: Artists Shazam lists for the search, in Shazam's order.
          items:
            $ref: '#/components/schemas/Artist'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Why the current page returned no results.
    SearchMetadata:
      type: object
      required: [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"
        json_url:
          type: string
          description: "URL to view JSON results"
    SearchParameters:
      type: object
      properties:
        engine:
          type: string
          description: Search engine used
        q:
          type: string
          description: The words searched for
        type:
          type: string
          description: The kind of result returned
        country:
          type: string
          description: Country whose catalog was searched
        lang:
          type: string
          description: Language of the labels
        page:
          type: integer
          description: Page of results
        zero_retention:
          type: boolean
          description: Present as true when zero data retention is enabled for the search.
    SearchInformation:
      type: object
      required: [top_result_type]
      properties:
        top_result_type:
          type: string
          enum: ["song", "artist"]
          description: The kind of result Shazam lists first for the search.
    Song:
      type: object
      required: [position, title, song_id, link, apple_music_link, artist_name]
      properties:
        position:
          type: integer
          description: Position of the song in the results, counting from the first page.
        title:
          type: string
          description: Title of the song.
        song_id:
          type: string
          description: Apple Music id of the song, which its shazam.com page uses too.
        link:
          type: string
          description: The song's page on shazam.com.
        apple_music_link:
          type: string
          description: The song on Apple Music.
        artist_name:
          type: string
          description: Artists credited on the song, as one line.
        artist_ids:
          type: array
          description: Apple Music ids for the artists linked to the song in the catalog.
          items:
            type: string
        album_name:
          type: string
          description: Album the song is on.
        album_id:
          type: string
          description: Apple Music id of the album when the Apple Music song link identifies it.
        duration_ms:
          type: integer
          description: Length of the song in milliseconds.
        release_date:
          type: string
          description: Release date of the song, as YYYY-MM-DD or YYYY when only the year is known.
        isrc:
          type: string
          description: International Standard Recording Code of the recording.
        genres:
          type: array
          description: Genres of the song, in the language of `lang`.
          items:
            type: string
        composer:
          type: string
          description: Composers credited on the song.
        track_number:
          type: integer
          description: Position of the song on its album disc.
        disc_number:
          type: integer
          description: Disc of the album the song is on.
        is_explicit:
          type: boolean
          description: Whether the song is marked explicit.
        has_lyrics:
          type: boolean
          description: Whether the song has lyrics on Apple Music.
        preview:
          type: string
          description: Audio preview of the song.
        thumbnail:
          type: string
          description: Cover art of the song, 400 by 400 pixels.
    Artist:
      type: object
      required: [position, name, artist_id, link, apple_music_link]
      properties:
        position:
          type: integer
          description: Position of the artist in the results, counting from the first page.
        name:
          type: string
          description: Name of the artist.
        artist_id:
          type: string
          description: Apple Music id of the artist, which its shazam.com page uses too.
        link:
          type: string
          description: The artist's page on shazam.com.
        apple_music_link:
          type: string
          description: The artist on Apple Music.
        genres:
          type: array
          description: Genres of the artist, in the language of `lang`.
          items:
            type: string
        thumbnail:
          type: string
          description: Picture of the artist, 400 by 400 pixels.
    Pagination:
      type: object
      required: [current]
      properties:
        current:
          type: integer
          description: Current page.
        next:
          type: integer
          description: Next page to pass as `page`, including when the current page is empty.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
