Method: RSpotify::Category#playlists

Defined in:
lib/rspotify/category.rb

#playlists(limit: 20, offset: 0, **options) ⇒ Array<Playlist>

Get a list of Spotify playlists tagged with a particular category.

Examples:

playlists = category.playlists
playlists = category.playlists(country: 'BR')
playlists = category.playlists(limit: 10, offset: 20)

Parameters:

  • limit (Integer) (defaults to: 20)

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

  • offset (Integer) (defaults to: 0)

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

  • country (String)

    Optional. A country: an ISO 3166-1 alpha-2 country code. Provide this parameter if you want to narrow the list of returned playlists to those relevant to a particular country. If omitted, the returned playlists will be globally relevant.

Returns:



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/rspotify/category.rb', line 89

def playlists(limit: 20, offset: 0, **options)
  url = "browse/categories/#{@id}/playlists"\
        "?limit=#{limit}&offset=#{offset}"

  options.each do |option, value|
    url << "&#{option}=#{value}"
  end

  response = RSpotify.get(url)
  return response if RSpotify.raw_response
  response['playlists']['items'].map { |i| Playlist.new i }
end