Skip to content
This repository

A REST (HTTP) API for interacting with iTunes written in NodeJS.

branch: master
Octocat-spinner-32 bin Workaround connect bug #298 June 18, 2011
Octocat-spinner-32 tests Globally conform to new Applescript module syntax (standard (err, rtn… September 03, 2010
Octocat-spinner-32 www Use Prototype's Element class instead of 'document.createElement()'. October 01, 2010
Octocat-spinner-32 .gitignore Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
Octocat-spinner-32 LICENSE Update year on license April 28, 2011
Octocat-spinner-32 README.md npm global installation April 28, 2011
Octocat-spinner-32 get-http-url.js Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
Octocat-spinner-32 handlers.js Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
Octocat-spinner-32 helpers.js Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
Octocat-spinner-32 iTunes.sdef Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
Octocat-spinner-32 m3u-parser.js Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
Octocat-spinner-32 nTunes-class.js Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
Octocat-spinner-32 nTunes-command.js Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
Octocat-spinner-32 nTunes-specifier.js Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
Octocat-spinner-32 nTunes.js Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
Octocat-spinner-32 package.json version 0.1.0 April 28, 2011
Octocat-spinner-32 pls-parser.js Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
Octocat-spinner-32 radio-playlist-parser.js Update for npm 1.0 compatibility. Also updated dependency versions. April 28, 2011
README.md

nTunes

A REST (HTTP) API for interacting with iTunes

nTunes is an HTTP-based API for interacting with your iTunes installation (currently only for Mac OSX), written with NodeJS.

In other words, it's the foundation for writing web applications based on your iTunes library. You could potentially write a website that:

  • Remotely controls the volume of the iTunes on your computer.
  • Acts as a remote interface for selecting music to play on your computer.
  • Accesses and plays back your library from the web interface itself (through <audio>?).
  • Automatically adds files added from a watched folder into your library.
  • Don't let this list decide for you! Be creative!

Installation

If you're lazy, just use the awesome npm of course!

npm install -g nTunes

Otherwise feel free to check out this repo and inspect as you will.

Usage

nTunes itself is presented with the familiar function(req, res, next) signature. This means it can be used in your Node code with the standard Node HTTP server with a one-liner like this:

require("http").createServer(require("nTunes")()).listen(80);

Or it can be used as a layer in connect:

var connect = require("connect");
connect.createServer(
  connect.logger(),
  connect.staticProvider(__dirname),
  require("nTunes")()
).listen(80);

Combining nTunes with connect is the recommend practice.

Stand-alone mode...

If you're only interested in seeing the examples nTunes comes packaged with, then it comes with a convenient executable file to easily start the demonstration HTTP server for you to play with. Once you've installed via npm, simply invoke:

nTunes

This starts nTunes as a stand-alone HTTP server in demonstration mode. While the server is running you can experiment with the nTunes API through simple HTTP requests sent to your computer. Here are some examples:

To get the name of the current track with a GET request:

curl localhost:8888/current%20track/name
  // Returns "Lateralus"

To set your iTunes' volume to 50% with through a POST request:

curl -d value=50 localhost:8888/sound%20volume
  // Returns 50

The API mostly returns JSON encoded values, and is mostly intended to be used with the XMLHttpRequest object and JSON.parse function in the web browser, or http.Client in Node.

Something went wrong with that request. Please try again.