Method: RSpotify::Category.list

Defined in:
lib/rspotify/category.rb

.list(limit: 20, offset: 0, **options) ⇒ Array<Category>

Get a list of categories used to tag items in Spotify

Examples:

categories = RSpotify::Category.list
categories = RSpotify::Category.list(country: 'US')
categories = RSpotify::Category.list(locale: 'es_MX', limit: 10)

Parameters:

  • limit (Integer) (defaults to: 20)

    Optional. Maximum number of categories to return. Maximum: 50. Default: 20.

  • offset (Integer) (defaults to: 0)

    Optional. The index of the first category to return. Use with limit to get the next set of categories. 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 categories to those relevant to a particular country. If omitted, the returned categories will be globally relevant.

  • locale (String)

    Optional. The desired language, consisting of a lowercase ISO 639 language code and an uppercase ISO 3166-1 alpha-2 country code, joined by an underscore. For details access / here and look for the locale parameter description.

Returns:



49
50
51
52
53
54
55
56
57
58
# File 'lib/rspotify/category.rb', line 49

def self.list(limit: 20, offset: 0, **options)
  url = "browse/categories?limit=#{limit}&offset=#{offset}"
  options.each do |option, value|
    url << "&#{option}=#{value}"
  end

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