Skip to content

πŸ’½ Fetch cover art for an artist or album: "The Beatles" βž” http://path/to/beatles.jpg

License

Notifications You must be signed in to change notification settings

lacymorrow/album-art

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Feb 1, 2024
ab4c4a3 Β· Feb 1, 2024

History

91 Commits
Mar 26, 2018
Nov 29, 2022
Apr 7, 2014
Nov 29, 2022
Nov 14, 2017
Apr 7, 2014
Oct 31, 2023
Feb 18, 2020
Feb 13, 2018
Jan 31, 2024
Feb 1, 2024
Dec 10, 2022
Jan 31, 2024

Repository files navigation

Important

This library is considered feature-complete and will only receive updates for bug fixes. You may still create an issue if you have a feature request.

album-art

npm version Maintainability Try movie-art on RunKit

Fetch an album or artist image url: "The Beatles" βž” http://path/to/beatles.jpg

album-art

NOTE: Last.fm cannabilized their own API and broke many applications, including this one. This library now uses Spotify for image data. The usage for album-art has changed slightly but is fully backwards-compatible. Please report any errors.

Features

  • Use anywhere, browser or Node - UMD (Browser Support)
  • Works in React + NextJS client/server (uses isomorphic-fetch)
  • Promise and Callback API
  • Fetch images for albums or artists
  • Multiple size options
  • Uses Spotify for image data

Install

Using NPM:

$ npm install album-art

In the browser:

<!-- albumArt window global -->
<script type="text/javascript" src="https://unpkg.com/album-art"></script>

(via Unpkg, or via JSDelivr)

Usage

const albumArt = require( 'album-art' )

await albumArt( 'Rush' ).then( console.log )
//=> http://path/to/rush.jpg
Callback
await albumArt( 'Rush', ( error, response ) => {
   console.log( response )

   //=> http://path/to/rush.jpg
})
Usage with album and size options
await albumArt( 'Rush', {album: '2112', size: 'small'} )
  .then( console.log )

//=> http://path/to/rush_2112_small.jpg

API

albumArt(artist [, options] [, callback])

Accepts an artist string to search for. Returns a Promise which resolves to a string URL.

artist

Required
Type: string

Artist to search for.

callback(error, response)

Function to be called on complete or on error.

Options

A JavaScript object with the following properties:

album

Type: string

Album to search for.

size

Type: string

Requested image size. possible values: small, medium, large

CLI Usage

You can also run as a CLI app by installing it globally:

$ npm install --global album-art

$ album-art --help

Usage
  $ album-art artist [album] [size]

Example
  $ album-art 'The Beatles' --album 'Abbey Road' --size 'large'
  http://path/to/beatles/abbey_road_large.jpg

Related

License

This package uses the Last.fm Spotify API for it's data. You may consult the Spotify API Terms of Service for license details.

MIT Β© Lacy Morrow