Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jakemmarsh/node-bandcamp
node.js (unofficial) Bandcamp API.
https://github.com/jakemmarsh/node-bandcamp
Last synced: about 2 months ago
JSON representation
node.js (unofficial) Bandcamp API.
- Host: GitHub
- URL: https://github.com/jakemmarsh/node-bandcamp
- Owner: jakemmarsh
- License: mit
- Created: 2015-03-06T19:31:55.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-08-31T03:14:11.000Z (over 9 years ago)
- Last Synced: 2024-09-07T04:10:40.268Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 164 KB
- Stars: 17
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
node-bandcamp [![npm version](https://badge.fury.io/js/node-bandcamp.svg)](http://badge.fury.io/js/node-bandcamp)
=================================================================================================================node.js (unofficial) Bandcamp API.
---
### Getting Started
1. `npm install --save node-bandcamp`
2. `var bandcamp = require('node-bandcamp')`---
### Searching for tracks
Specific tracks can be searched for using the `trackSearch` method. This function takes the following parameters:
- `query` (str): The search query for which you want results.
- `limit` (defaults to 20): The maximum number of results you want returned. Defaults to `20`.The function will recursively query Bandcamp until results are exhausted or the limit is hit.
```javascript
var bandcamp = require('node-bandcamp');bandcamp.trackSearch('tibetan pop stars', 30).then(function(results){
// do something with search results
}).catch(function(err) {
// handle error
});
```Returns a `promise`, which will eventually resolve as an array of search results. Results are in the format:
```json
[
{
"title": "title",
"album": "album name",
"artist": "artist name",
"image": "URL to track artwork",
"url": "URL to be passed to getTrack method"
},
...
]```
---
### Streaming a track
A specific track can be streamed using the `getTrack` method. This function takes just one parameter, the Bandcamp URL string retrieved using the previously discussed `trackSearch` method.
```javascript
var bandcamp = require('node-bandcamp');bandcamp.getTrack('http://hopalong.bandcamp.com/track/tibetan-pop-stars').then(function(stream) {
// pipe audio stream to res, etc.
}).catch(function(err) {
// handle error
});
```Returns a `promise`, which will eventually resolve as an audio stream.
---
### Getting track details
The details for a specific track (title, duration, etc.) can be retrieved using the `getDetails` method. This function takes the Bandcamp URL string for the track as a parameter, and returns a `promise` which will eventually resolve as an object in the same format as search results:
```javascript
var bandcamp = require('node-bandcamp');bandcamp.getDetails('http://hopalong.bandcamp.com/track/tibetan-pop-stars').then(function(details) {
// return details to res, etc.
}).catch(function(err) {
// handle error
});
```and the promise resolves with an object in the format:
```json
{
"title": "title",
"album": "album name",
"artist": "artist name",
"image": "URL to track artwork",
"url": "URL to be passed to getTrack method"
}
```---
### Testing
All tests for this package are within the `__tests__/` directory. If you wish to run the tests:
1. `git clone [email protected]:jakemmarsh/node-bandcamp.git`
2. `cd node-bandcamp`
3. `npm install`
4. `npm test`