Skip to content
← Public packages

@kentcdodds/spotify

Spotify playback, playlist, search, library, and device helpers.

src/exports/search.ts

17 lines · 757 B · TypeScript
import { searchCatalog } from '../lib/spotify-api.ts'
import type { SearchParams } from '../lib/export-types.ts'

/**
 * Search the Spotify catalog for tracks, albums, artists, or playlists.
 * Pass `types` (preferred) or `type` as an alias. All params accept an optional `account` ('personal' | 'family', default 'personal').
 * @returns Object keyed by result type (e.g. tracks, artists) with normalized items.
 * @example
 * import search from 'kody:@kentcdodds/spotify/search'
const results = await search({ query: 'radiohead', types: ['track'], limit: 5 })
// => { tracks: [{ id: '...', name: '...', artists: ['...'] }] }
 */
async function spotifySearch(params: SearchParams = {}) {
	return await searchCatalog(params)
}

export default spotifySearch