Skip to content

Commit a648772

Browse files
committed
feat: genres API
1 parent 49481b9 commit a648772

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

src/api/albums.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Market, PaginatedResults } from '@/types/common'
55
import type { AlbumObject, GetAlbumsOptions, SavedAlbumObject, SimplifiedAlbumObject } from '@/types/album'
66
import type { SimplifiedTrackObject } from '@/types/track'
77

8-
export class AlbumsAPI extends ApiPart {
8+
export class AlbumsApi extends ApiPart {
99
/**
1010
* Get Spotify catalog information for a single album.
1111
* @param albumId The [Spotify ID](https://developer.spotify.com/documentation/web-api/#spotify-uris-and-ids) for the album.

src/api/client.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { $Fetch } from 'ofetch'
22
import { Headers, ofetch } from 'ofetch'
3-
import { AlbumsAPI, ArtistsApi, UsersApi } from '.'
3+
import { AlbumsApi, ArtistsApi, GenresApi, UsersApi } from '.'
44

55
export class SpotifyClient {
66
private token: null | string = null
@@ -18,8 +18,9 @@ export class SpotifyClient {
1818
},
1919
})
2020

21-
this.albums = new AlbumsAPI(this.$fetch)
21+
this.albums = new AlbumsApi(this.$fetch)
2222
this.artists = new ArtistsApi(this.$fetch)
23+
this.genres = new GenresApi(this.$fetch)
2324
this.users = new UsersApi(this.$fetch)
2425
}
2526

@@ -29,9 +30,11 @@ export class SpotifyClient {
2930
return this
3031
}
3132

32-
public albums: AlbumsAPI
33+
public albums: AlbumsApi
3334

3435
public artists: ArtistsApi
3536

37+
public genres: GenresApi
38+
3639
public users: UsersApi
3740
}

src/api/genres.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ApiPart } from './api.part'
2+
3+
export class GenresApi extends ApiPart {
4+
/**
5+
* Retrieve a list of available genres seed parameter values
6+
* for [recommendations](https://developer.spotify.com/documentation/web-api/reference/get-recommendations).
7+
*/
8+
public getAvailableGenreSeeds(): Promise<{ genres: string[] }> {
9+
return this.$fetch<{ genres: string[] }>('/recommendations/available-genre-seeds')
10+
}
11+
}

src/api/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './albums'
22
export * from './artists'
3+
export * from './genres'
34
export * from './users'

0 commit comments

Comments
 (0)