diff --git a/spotipy/client.py b/spotipy/client.py index c13be53..7c726c1 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -1453,8 +1453,25 @@ class Spotify(object): "browse/new-releases", country=country, limit=limit, offset=offset ) + def category(self, category_id, country=None, locale=None): + """ Get info about a category + + Parameters: + - category_id - The Spotify category ID for the category. + + - country - An ISO 3166-1 alpha-2 country code. + - locale - The desired language, consisting of an ISO 639 + language code and an ISO 3166-1 alpha-2 country code, joined + by an underscore. + """ + return self._get( + "browse/categories/" + category_id, + country=country, + locale=locale, + ) + def categories(self, country=None, locale=None, limit=20, offset=0): - """ Get a list of new album releases featured in Spotify + """ Get a list of categories Parameters: - country - An ISO 3166-1 alpha-2 country code. @@ -1480,7 +1497,7 @@ class Spotify(object): def category_playlists( self, category_id=None, country=None, limit=20, offset=0 ): - """ Get a list of new album releases featured in Spotify + """ Get a list of playlists for a specific Spotify category Parameters: - category_id - The Spotify category ID for the category. diff --git a/tests/integration/test_user_endpoints.py b/tests/integration/test_user_endpoints.py index ad6aa52..36de8d9 100644 --- a/tests/integration/test_user_endpoints.py +++ b/tests/integration/test_user_endpoints.py @@ -297,6 +297,10 @@ class SpotipyBrowseApiTests(unittest.TestCase): token = prompt_for_user_token(username) cls.spotify = Spotify(auth=token) + def test_category(self): + response = self.spotify.category('rock') + self.assertTrue('name' in response) + def test_categories(self): response = self.spotify.categories() self.assertGreater(len(response['categories']), 0)