Skip to content

Commit cbdfabf

Browse files
committed
add searchAllTypes utility for SearchApi
Signed-off-by: Adam Ratzman <[email protected]>
1 parent 6b32bb2 commit cbdfabf

File tree

1 file changed

+21
-0
lines changed
  • src/commonMain/kotlin/com.adamratzman.spotify/endpoints/public

1 file changed

+21
-0
lines changed

src/commonMain/kotlin/com.adamratzman.spotify/endpoints/public/SearchApi.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,27 @@ public open class SearchApi(api: GenericSpotifyApi) : SpotifyEndpoint(api) {
222222
): PagingObject<Track> = get(build(query, market, limit, offset, SearchType.TRACK))
223223
.toNonNullablePagingObject(Track.serializer(), "tracks", api, json)
224224

225+
/**
226+
* Get Spotify Catalog information about any searchable type that match the keyword string. See [SearchApi.search] for more information
227+
*
228+
* **[Api Reference](https://developer.spotify.com/documentation/web-api/reference/search/search/)**
229+
*
230+
* @param query Search query keywords and optional field filters and operators.
231+
* @param market Provide this parameter if you want to apply [Track Relinking](https://github.com/adamint/spotify-web-api-kotlin#track-relinking)
232+
* @param limit The number of objects to return. Default: 50 (or api limit). Minimum: 1. Maximum: 50.
233+
* @param offset The index of the first item to return. Default: 0. Use with limit to get the next set of items
234+
*
235+
* @see [SearchApi.search]
236+
*
237+
* @throws BadRequestException if filters are illegal or query is malformed
238+
*/
239+
public suspend fun searchAllTypes(
240+
query: String,
241+
limit: Int? = api.spotifyApiOptions.defaultLimit,
242+
offset: Int? = null,
243+
market: Market? = null
244+
): SpotifySearchResult = search(query, *SearchType.values(), limit = limit, offset = offset, market = market)
245+
225246
protected fun build(
226247
query: String,
227248
market: Market?,

0 commit comments

Comments
 (0)