# shufflerfm

> Shuffler.fm API client for Node.js

Latest version **0.2.2** (published 2015-02-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install shufflerfm
pnpm add shufflerfm
yarn add shufflerfm
bun add shufflerfm
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2015-02-07 |
| First published | 2014-10-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Dmitri Voronianski |
| Maintainers | dmitri |
| Keywords | shuffler.fm, api, client, mp3, soundcloud, music, rest |

## Links

- npm: https://www.npmjs.com/package/shufflerfm
- Repository: https://github.com/voronianski/node-shufflerfm
- Issues: https://github.com/voronianski/node-shufflerfm/issues
- npm.io page: https://npm.io/package/shufflerfm

## Dependencies (1)

- [superagent](https://npm.io/package/superagent.md) ^0.21.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.2.2 (latest) — 2015-02-07
- 0.2.1 — 2015-02-07
- 0.2.0 — 2015-02-07
- 0.1.1 — 2014-10-22
- 0.1.0 — 2014-10-20

## README

# <img src="https://d1v2xm8p2pd3wl.cloudfront.net/assets/static/images/shuffler_logo_200.png" width="45" align="left">&nbsp;node-shufflerfm

> [Shuffler.fm](https://shuffler.fm) API client for Node.js and Browserify.

## Install

```javascript
npm install shufflerfm
```

## Example

```javascript
var ShufflerFM = require('shufflerfm');

var sfm = new ShufflerFM('YOUR APP KEY', 'YOUR APP SECRET');

sfm.getGenre('uk+garage', function (err, data, response) {
    if (err) throw err;

    // do something with data
    console.dir(data);
});
```

## API

### `new ShufflerFM('APP_KEY', 'APP SECRET')`

Create an instance of a client. `'APP_KEY'` and `'APP SECRET'` are mandatory - http://developers.shuffler.fm/#app_key.

Returns a bunch of self-descripting methods. Details about every Shuffler.fm API resource is available here - http://developers.shuffler.fm/#resources.

#### Activities

http://developers.shuffler.fm/#activities

##### `getActivityById(id, callback)`

#### Artists

http://developers.shuffler.fm/#artists

##### `getArtists([query], callback)`
##### `getArtistById(id, callback)`

#### Authorizations

http://developers.shuffler.fm/#authorizations

##### `createOAuthUrl(scope, redirect_uri)`

- `scope` {String|Array} - required and should be at least one of the following: `users.r, users.favorites.r, users.favorites.m, users.subscriptions.r, users.subscriptions.m`
- `redirect_uri` {String} - required and should be under the same domain as the one in your app's settings (http://shuffler.fm/developers/apps)

Returns an uri string  (e.g. `https://shuffler.fm/authorizations/auth?app_key=YOUR-APP-KEY&scope=users.r&redir_uri=http%3A%2F%2Fmyurl.net`) that should be opened in browser.

```javascript
var ShufflerFM = require('shufflerfm');

var sfm = new ShufflerFM('YOUR APP KEY', 'YOUR APP SECRET');
var oauthUrl = sfm.createOAuthUrl(['users.r', 'users.favorites.r'], 'http://myurl.net');

console.log(oauthUrl);
// -> https://shuffler.fm/authorizations/auth?app_key=YOUR-APP-KEY&scope=users.r,users.favorites.r&redir_uri=http%3A%2F%2Fmyurl.net`
// open in browser to follow a three-legged OAuth 2.0 flow
// this will return you `code` that you will need later
```

##### `getAuthToken(code, callback)`

- `code` {String} - required, it's received as query param in redirect uri (after user follows the OAuth uri and grants access to your application)

Returns object with `access_token` and `userId` as second argument in `callback` function.

#### Charts

http://developers.shuffler.fm/#charts

##### `getChartsPopular(callback)`

#### Channels

http://developers.shuffler.fm/#channels

##### `getChannel(channel, [position], callback)`

#### Genres

http://developers.shuffler.fm/#genres

##### `getGenres(callback)`
##### `getGenreByName(genre, callback)`
##### `getGenreSites(genre, callback)`

#### Sites

http://developers.shuffler.fm/#sites

##### `getSites([query], callback)`
##### `getSiteById(id, callback)`
##### `getFeaturedSites(callback)`

#### Tracks

http://developers.shuffler.fm/#tracks

##### `getTracks(callback)`
##### `getTrackById(id, callback)`

## To Do

Implement API resources that need OAuth - http://developers.shuffler.fm/#authorizations, e.g.:

- [x] Authorizations
- [ ] Subscribtions
- [ ] Users

## License

MIT Licensed

Copyright (c) 2014-2015 Dmitri Voronianski [dmitri.voronianski@gmail.com](mailto:dmitri.voronianski@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/shufflerfm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
