Method: RSpotify::Album.search

Defined in:
lib/rspotify/album.rb

.search(query, limit: 20, offset: 0, market: nil) ⇒ Array<Album>

Returns array of Album objects matching the query, ordered by popularity. It’s also possible to find the total number of search results for the query

Examples:

albums = RSpotify::Album.search('AM')
albums = RSpotify::Album.search('AM', limit: 10, market: 'US')
albums = RSpotify::Album.search('AM', market: { from: user })

RSpotify::Album.search('AM').total #=> 9374

Parameters:

  • query (String)

    The search query’s keywords. For details access here and look for the q parameter description.

  • limit (Integer) (defaults to: 20)

    Maximum number of albums to return. Maximum: 50. Default: 20.

  • offset (Integer) (defaults to: 0)

    The index of the first album to return. Use with limit to get the next set of albums. Default: 0.

  • market (String, Hash) (defaults to: nil)

    Optional. An ISO 3166-1 alpha-2 country code or the hash { from: user }, where user is a RSpotify user authenticated using OAuth with scope user-read-private. This will take the user’s country as the market value. For details access here and look for the market parameter description.

Returns:



70
71
72
# File 'lib/rspotify/album.rb', line 70

def self.search(query, limit: 20, offset: 0, market: nil)
  super(query, 'album', limit: limit, offset: offset, market: market)
end