npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bandcamp-scraper

v1.5.0

Published

A scraper for https://bandcamp.com

Downloads

1,029

Readme

bandcamp-scraper

npm version Test Test daily JavaScript Style Guide

Bandcamp Logo

A scraper for https://bandcamp.com

The scraper allows you to:

  • search artist, album, track, fan, label
  • get album urls from an artist url
  • get album info from an album url
  • get album products from an album url
  • get artist info from an artist url

Why ?

Because Bandcamp has shut down their public API and don't plan to reopen it.

https://bandcamp.com/developer

Installation

npm i --save bandcamp-scraper

Usage

search(params, callback)

Search any resources that match the given params.query for the current params.page.

  • params Object - query String - page Integer (default 1)
  • callback Function(error, searchResults)

Search Results

An array of resources that have different properties depending on their type property: artist, album, track, fan, or label.

Every resource matches the search-result JSON schema.

Example

const bandcamp = require('bandcamp-scraper')

const params = {
  query: 'Coeur de pirate',
  page: 1
}

bandcamp.search(params, function (error, searchResults) {
  if (error) {
    console.log(error)
  } else {
    console.log(searchResults)
  }
})

View example with output.

getAlbumsWithTag(params, callback)

Search for albums with the tag params.tag for the current params.page.

  • params Object - tag String - page Integer (default 1)
  • callback Function(error, tagResults)

Tag Results

An array of album information. Matches the tag-result JSON schema.

Example

const bandcamp = require('bandcamp-scraper')

const params = {
  tag: 'nuwrld',
  page: 1
}

bandcamp.getAlbumsWithTag(params, function (error, tagResults) {
  if (error) {
    console.log(error)
  } else {
    console.log(tagResults)
  }
})

View example with output.

getAlbumUrls(artistUrl, callback)

Retrieve the album URLs from an artist URL. Please note: for Bandcamp labels you may want to use the getArtistsUrls function to retrieve the list of signed artists first.

  • artistUrl String
  • callback Function(error, albumUrls)

Example

const bandcamp = require('bandcamp-scraper')

const artistUrl = 'http://musique.coeurdepirate.com/'
bandcamp.getAlbumUrls(artistUrl, function (error, albumUrls) {
  if (error) {
    console.log(error)
  } else {
    console.log(albumUrls)
  }
})

View example with output.

getAlbumProducts(albumUrl, callback)

Retrieves all the album's products from its URL.

  • albumUrl String
  • callback Function(error, albumProducts)

Album Products

An array of album products that matches the album-product JSON schema.

Example

const bandcamp = require('bandcamp-scraper')

const albumUrl = 'http://musique.coeurdepirate.com/album/blonde'
bandcamp.getAlbumProducts(albumUrl, function (error, albumProducts) {
  if (error) {
    console.log(error)
  } else {
    console.log(albumProducts)
  }
})

View example with output.

getAlbumInfo(albumUrl, callback)

Retrieves the album's info from its URL.

  • albumUrl String
  • callback Function(error, albumInfo)

Album Info

An Object that represents the album's info. It matches the album-info JSON schema.

Example

const bandcamp = require('bandcamp-scraper')

const albumUrl = 'http://musique.coeurdepirate.com/album/blonde'
bandcamp.getAlbumInfo(albumUrl, function (error, albumInfo) {
  if (error) {
    console.log(error)
  } else {
    console.log(albumInfo)
  }
})

View example with output.

getArtistUrls(labelUrl, callback)

Retrieves an array of artist URLs from a label's URL for further scraping.

  • labelUrl String
  • callback Function(error, albumInfo)

Example

const bandcamp = require('bandcamp-scraper')

const labelUrl = 'https://randsrecords.bandcamp.com'
bandcamp.getArtistUrls(labelUrl, function (error, artistsUrls) {
  if (error) {
    console.log(error)
  } else {
    console.log(artistsUrls)
  }
})

View example with output.

getArtistInfo(artistUrl, callback)

Retrieves the artist's info from its URL.

  • artistUrl String
  • callback Function(error, artistInfo)

Artist Info

An Object that represents the artist's info. It matches the artist-info JSON schema.

Example

const bandcamp = require('bandcamp-scraper')

const artistUrl = 'http://musique.coeurdepirate.com'
bandcamp.getArtistInfo(artistUrl, function (error, artistInfo) {
  if (error) {
    console.log(error)
  } else {
    console.log(artistInfo)
  }
})

View example with output.

getTrackInfo(trackUrl, callback)

Retrieves the track info from its URL.

  • trackUrl String
  • callback Function(error, trackInfo)

Track Info

An Object that represents the track's info. It matches the track-info JSON schema.

Example

const bandcamp = require('bandcamp-scraper')

const trackUrl = 'https://dafnez.bandcamp.com/track/serenade'
bandcamp.getTrackInfo(trackUrl, function (error, trackInfo) {
  if (error) {
    console.log(error)
  } else {
    console.log(trackInfo)
  }
})

Test

Feature tests are run daily, thanks to GitHub Action schedule actions. This way we know if the scraper is ever broken.

Run the test:

npm test

Contributing

Contribution is welcome! Open an issue first.

License

MIT.