Skip to content
← Public packages

@kentcdodds/spotify

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

src/exports/get-top-items.ts

17 lines · 695 B · TypeScript
import { getTopItems } from '../lib/spotify-api.ts'
import type { GetTopItemsParams } from '../lib/export-types.ts'

/**
 * Read the user's top Spotify tracks or artists for a time range.
 * All params accept an optional `account` ('personal' | 'family', default 'personal').
 * @returns Array of normalized track or artist objects.
 * @example
 * import getTopItems from 'kody:@kentcdodds/spotify/get-top-items'
const tracks = await getTopItems({ type: 'tracks', timeRange: 'short_term', limit: 5 })
// => [{ id: '...', name: '...', popularity: 80 }]
 */
async function spotifyGetTopItems(params: GetTopItemsParams = {}) {
	return await getTopItems(params)
}

export default spotifyGetTopItems