openapi: 3.0.0
info:
  title: Deezer Search API
  description: |
    Search the Deezer catalog for tracks, albums, artists, playlists, podcasts or user profiles.

    Each result carries its Deezer id and link. Tracks carry their ISRC, duration, popularity rank, explicit flag and a preview link, with the artist and album. Deezer shows each country its own catalog, so `country` picks the catalog searched.

    Deezer returns at most 300 results per search.
  version: 1.0.0
servers:
  - url: https://www.searchapi.io/api/v1
paths:
  /search:
    get:
      summary: Deezer Search
      security:
        - ApiKeyAuth: []
        - ApiKeyQuery: []
      parameters:
        - name: engine
          in: query
          required: true
          description: 'Search engine. Must be set to: `deezer_search`'
          schema:
            type: string
            enum: ["deezer_search"]
        - name: q
          in: query
          required: true
          description: The terms to search for. Deezer refuses some text, such as script tags or SQL, and the search then returns an error.
          schema:
            type: string
            maxLength: 500
        - name: type
          in: query
          required: false
          description: 'The kind of result to return. Deezer has podcast search in these countries only: `US`, `MX`, `BR`, `CO`, `GB`, `IE`, `FR`, `NL`, `DE`, `AT`, `CH`, `TR`, `IL`, `EG`, `SA` and `AE`.'
          schema:
            type: string
            enum: ["tracks", "albums", "artists", "playlists", "podcasts", "profiles"]
            default: "tracks"
        - name: country
          in: query
          required: false
          description: Country whose Deezer catalog is searched (ISO 3166-1 alpha-2).
          schema:
            type: string
            enum: ["US", "CA", "MX", "BR", "AR", "CL", "CO", "PE", "GB", "IE", "FR", "BE", "LU", "NL", "DE", "AT", "CH", "ES", "PT", "IT", "DK", "SE", "NO", "FI", "PL", "CZ", "HU", "RO", "GR", "TR", "UA", "IL", "EG", "SA", "AE", "ZA", "NG", "JP", "ID", "PH", "TH", "VN", "MY", "SG", "AU", "NZ"]
            default: "US"
        - name: page
          in: query
          required: false
          description: Page of results. The last page holds result 300, so with `num` 25 it is page 12.
          schema:
            type: integer
            minimum: 1
            default: 1
        - name: num
          in: query
          required: false
          description: Number of results per page.
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
      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'
        search_information:
          $ref: '#/components/schemas/SearchInformation'
        tracks:
          type: array
          description: Tracks Deezer lists for the search, in Deezer's order.
          items:
            $ref: '#/components/schemas/Track'
        albums:
          type: array
          description: Albums Deezer lists for the search, in Deezer's order.
          items:
            $ref: '#/components/schemas/Album'
        artists:
          type: array
          description: Artists Deezer lists for the search, in Deezer's order.
          items:
            $ref: '#/components/schemas/Artist'
        playlists:
          type: array
          description: Playlists Deezer lists for the search, in Deezer's order.
          items:
            $ref: '#/components/schemas/Playlist'
        podcasts:
          type: array
          description: Podcasts Deezer lists for the search, in Deezer's order.
          items:
            $ref: '#/components/schemas/Podcast'
        profiles:
          type: array
          description: User profiles Deezer lists for the search, in Deezer's order.
          items:
            $ref: '#/components/schemas/Profile'
        pagination:
          $ref: '#/components/schemas/Pagination'
        error:
          type: string
          description: Why the search 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"
        request_url:
          type: string
          description: "Deezer search page 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: Search engine used
        q:
          type: string
          description: The terms searched for
        type:
          type: string
          description: The kind of result returned
        country:
          type: string
          description: Country whose catalog was searched
        page:
          type: integer
          description: Page of results
        num:
          type: integer
          description: Number of results per page
    SearchInformation:
      type: object
      properties:
        total_results:
          type: integer
          description: Approximate number of results Deezer has for the search, at most 300.
    Track:
      type: object
      required: [position, id, title, title_short, link, isrc, duration, rank, thumbnail, artist, album]
      properties:
        position:
          type: integer
          description: Position of the track in the results, counting from the first page.
        id:
          type: integer
          description: Deezer track id.
        title:
          type: string
          description: Full title of the track.
        title_short:
          type: string
          description: Title of the track without its version.
        title_version:
          type: string
          description: Version of the track, such as a remix or a featured artist.
        link:
          type: string
          description: Link to the track on Deezer.
        isrc:
          type: string
          description: International Standard Recording Code of the track.
        duration:
          type: integer
          description: Length of the track in seconds.
        rank:
          type: integer
          description: Deezer popularity score of the track.
        is_explicit:
          type: boolean
          description: Whether the track has explicit lyrics.
        preview:
          type: string
          description: Link to an MP3 preview of the track.
        preview_expires_at:
          type: string
          format: date-time
          description: Time at which the preview link stops working.
        thumbnail:
          type: string
          description: Album cover of the track, 1000 by 1000 pixels.
        artist:
          $ref: '#/components/schemas/ArtistReference'
        album:
          $ref: '#/components/schemas/AlbumReference'
    Album:
      type: object
      required: [position, id, title, link, album_type, tracks_count, genre_id, thumbnail, artist]
      properties:
        position:
          type: integer
          description: Position of the album in the results, counting from the first page.
        id:
          type: integer
          description: Deezer album id.
        title:
          type: string
          description: Title of the album.
        link:
          type: string
          description: Link to the album on Deezer.
        album_type:
          type: string
          description: Kind of release, such as `album`, `single` or `ep`.
        tracks_count:
          type: integer
          description: Number of tracks on the album.
        genre_id:
          type: integer
          description: Deezer genre id of the album.
        is_explicit:
          type: boolean
          description: Whether the album has explicit lyrics.
        thumbnail:
          type: string
          description: Album cover, 1000 by 1000 pixels.
        artist:
          $ref: '#/components/schemas/ArtistReference'
    Artist:
      type: object
      required: [position, id, name, link, albums_count, fans, thumbnail]
      properties:
        position:
          type: integer
          description: Position of the artist in the results, counting from the first page.
        id:
          type: integer
          description: Deezer artist id.
        name:
          type: string
          description: Name of the artist.
        link:
          type: string
          description: Link to the artist on Deezer.
        albums_count:
          type: integer
          description: Number of albums the artist has on Deezer.
        fans:
          type: integer
          description: Number of Deezer users who follow the artist.
        has_radio:
          type: boolean
          description: Whether Deezer has a radio for the artist.
        thumbnail:
          type: string
          description: Picture of the artist, 1000 by 1000 pixels.
    Playlist:
      type: object
      required: [position, id, title, link, tracks_count, creation_date, modification_date, thumbnail, owner]
      properties:
        position:
          type: integer
          description: Position of the playlist in the results, counting from the first page.
        id:
          type: integer
          description: Deezer playlist id.
        title:
          type: string
          description: Title of the playlist.
        link:
          type: string
          description: Link to the playlist on Deezer.
        tracks_count:
          type: integer
          description: Number of tracks in the playlist.
        is_public:
          type: boolean
          description: Whether the playlist is public.
        creation_date:
          type: string
          description: Date and time the playlist was created, with no time zone.
        modification_date:
          type: string
          description: Date and time the playlist last changed, with no time zone.
        thumbnail:
          type: string
          description: Cover of the playlist, 1000 by 1000 pixels.
        owner:
          $ref: '#/components/schemas/ProfileReference'
    Podcast:
      type: object
      required: [position, id, title, link, fans, thumbnail]
      properties:
        position:
          type: integer
          description: Position of the podcast in the results, counting from the first page.
        id:
          type: integer
          description: Deezer podcast id.
        title:
          type: string
          description: Title of the podcast.
        link:
          type: string
          description: Link to the podcast on Deezer.
        description:
          type: string
          description: Description of the podcast.
        fans:
          type: integer
          description: Number of Deezer users who follow the podcast.
        is_available:
          type: boolean
          description: Whether the podcast can be played on Deezer.
        thumbnail:
          type: string
          description: Cover of the podcast, 1000 by 1000 pixels.
    Profile:
      type: object
      required: [position, id, name, link, thumbnail]
      properties:
        position:
          type: integer
          description: Position of the profile in the results, counting from the first page.
        id:
          type: integer
          description: Deezer user id.
        name:
          type: string
          description: Name of the user.
        link:
          type: string
          description: Link to the user's profile on Deezer.
        thumbnail:
          type: string
          description: Picture of the user, 1000 by 1000 pixels.
    ArtistReference:
      type: object
      required: [id, name, link, thumbnail]
      properties:
        id:
          type: integer
          description: Deezer artist id.
        name:
          type: string
          description: Name of the artist.
        link:
          type: string
          description: Link to the artist on Deezer.
        thumbnail:
          type: string
          description: Picture of the artist, 1000 by 1000 pixels.
    AlbumReference:
      type: object
      required: [id, title, link, thumbnail]
      properties:
        id:
          type: integer
          description: Deezer album id.
        title:
          type: string
          description: Title of the album.
        link:
          type: string
          description: Link to the album on Deezer.
        thumbnail:
          type: string
          description: Album cover, 1000 by 1000 pixels.
    ProfileReference:
      type: object
      required: [id, name, link]
      properties:
        id:
          type: integer
          description: Deezer user id.
        name:
          type: string
          description: Name of the user.
        link:
          type: string
          description: Link to the user's profile on Deezer.
    Pagination:
      type: object
      required: [current]
      properties:
        current:
          type: integer
          description: The current page.
        next_page:
          type: integer
          description: Value to pass as `page` for the next page.
    ErrorResponse:
      type: object
      required: [error]
      properties:
        error:
          type: string
          description: Error message describing what went wrong
