• Stars
    star
    193
  • Rank 201,081 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎵 A simple server providing a RESTful service for controlling iTunes

iTunes API!!

iTunes API is a simple REST server allowing you to query/control a local running iTunes instance. Once you have a way to make RESTful API calls to control iTunes, you can integrate its control into any of your own software.

This is especially convenient for integrating into any sort of Home Automation you might have.

Last confirmed working version of iTunes: 12.2.1.

Features

  • play/stop/pause/playpause/next/previous control over what's playing.
  • query to return what's currently playing.
  • fetch the art of the currently playing song.
  • set a specific playlist to play, by name.
  • query to return a list of available AirPlay endpoints.
  • set an AirPlay endpoint to be active. (This can be multiple, since iTunes supports it).

Setup

script/bootstrap

Running It

Get up and running immediatly with script/server.

iTunes API will run on port 8181 by default. Use the PORT environment variable to use your own port.

Forever

iTunes API has support for Forever. It uses launchd on OS X to kick it off so that it starts on boot. There is no init.d other Linux support of this type. Pull requests would be welcome for this though.

Development

You can simply run it by calling script/server. This will run it in development mode with logging to standard out.

Install as Service on OS X

script/install

Logging

iTunes API logs all of its requests. In production, it logs to a file at log/logs.log. In development mode, it just logs to stdout.

Development

Launch the app via script/server to run it in the development environment.

Docs

This is a quick overview of the service. Read app.js if you need more info.

Resources

Here's a list of resources that may be returned in a response.

NowPlaying Resource

The NowPlaying resource returns all the information about if iTunes is playing and what is playing.

{
  "player_state": "playing",
  "volume": 60,
  "muted": false,
  "id": "AC4FFD2271422B47",
  "name": "Forever",
  "artist": "HAIM",
  "album": "Days Are Gone (2013)",
  "playlist": "Summer Jams",
  "shuffle": "songs",
  "repeat": "all"
}

Playlist Resource

The Playlist resource returns all the information about a playlist in your library.

{
  "id": "outkast-the-90s",
  "name": "Outkast: The '90s",
  "loved": true,
  "duration_in_seconds": 4544,
  "time": "1:15:44"
},

AirPlayDevice Resource

The AirPlayDevice resource returns all the information about an available AirPlay device on your network.

{
  "id": "63-22-fa-1f-f5-d4",
  "name": "Living Room",
  "kind": "Apple TV",
  "active": true,
  "selected": true,
  "volume": 60,
  "supports_video": true,
  "supports_audio": true,
  "network_address": "63:22:fa:1f:f5:d4"
}

Methods

These are the endpoints you can hit to do things.

Info

Use these endpoints to query the current state of iTunes.

GET /now_playing => NowPlayingResource
GET /artwork => JPEG Data (image/jpeg)

Player Control

Use these endpoints to control what's currently playing.

PUT /playpause => NowPlayingResource
PUT /stop => NowPlayingResource
PUT /previous => NowPlayingResource
PUT /next => NowPlayingResource
PUT /play => NowPlayingResource
PUT /pause => NowPlayingResource
PUT /volume [level=20] => NowPlayingResource
PUT /volume [muted=true] => NowPlayingResource
PUT /shuffle [mode=songs] => NowPlayingResource
PUT /shuffle [mode=off] => NowPlayingResource
PUT /repeat [mode=all] => NowPlayingResource
PUT /repeat [mode=off] => NowPlayingResource

Playlists

Use this endpoint to start a specific playlist.

GET /playlists => {"playlists": [PlaylistResource, PlaylistResource, ...]}
PUT /playlists/:id/play => NowPlayingResource

AirPlay Control

Use these endpoints to query and set AirPlay devices. You can set multiple AirPlay devices to be used at the same time.

GET /airplay_devices => {"airplay_devices": [AirPlayDevice, AirPlayDevice, ...]}
GET /airplay_devices/:id => AirPlayDevice
PUT /airplay_devices/:id/on => AirPlayDevice
PUT /airplay_devices/:id/off => AirPlayDevice
PUT /volume [level=20] => AirPlayDevice

Contributions

  • fork
  • create a feature branch
  • open a Pull Request

More Repositories

1

dasher

🔘 A simple way to bridge your Amazon Dash buttons to HTTP services
JavaScript
707
star
2

magic-cards

🎩 Queue music, play movies, or trigger events with RFID cards.
JavaScript
566
star
3

magick-installer

ImageMagick installer script because macports sucks
Shell
486
star
4

actions

A collection of useful GitHub Actions
Dockerfile
393
star
5

harmony-api

🗼 A simple server allowing you to query/control multiple local Harmony Home Hubs over HTTP or MQTT
JavaScript
390
star
6

kart

🎮 Frontend for RetroArch
CoffeeScript
367
star
7

wallop

📺 A transcoding server for your HDHomeRun Prime
Ruby
167
star
8

imdb-party

IMDB client using the IMDB API that their iPhone app uses
Ruby
116
star
9

tvdb_party

Simple Ruby library to talk to thetvdb.com
Ruby
72
star
10

pluto-for-channels

📺 M3U generator optimized for Channels' custom channels.
JavaScript
69
star
11

imdb

Don't use this anymore, use maddox/imdb-party
Ruby
46
star
12

mac-api

Command your Mac from afar
Shell
32
star
13

categories

Community driven repo for awesome Objective-C categories
28
star
14

mgtwitterengine

Git fork of MGTwitterEngine
Objective-C
26
star
15

piano

Because you know you hate Apple's Stats
Ruby
26
star
16

arcade1up-tools

Arcade1Up Modding
20
star
17

freelancer

For your freelancing yo!
JavaScript
19
star
18

channels-strmlnks

Example stream links for Channels
18
star
19

gpi-tools

GPI Case Resources
18
star
20

instagrammer

Get personal RSS feed access to your Instagrams
JavaScript
15
star
21

impawards

Simple library to find high quality posters for movies
Ruby
10
star
22

regexkit

a fork of the objective-c RegexKit regular expression framework
10
star
23

tvdb

Ruby library for the TVDB
Ruby
8
star
24

movieposterdb

a simple ruby client for the MoviePosterDB api
Ruby
7
star
25

cbs_sports

A quickie library to read in sports scores
Ruby
6
star
26

trailers

library for retrieving trailer movies
Ruby
6
star
27

aim_status_helper

Rails plugin that will display a user's AIM status
Ruby
6
star
28

xbmc-library

Ruby library to talk to the XBMC sqlite database
Ruby
5
star
29

broadcatcher

find your favorite shows via nzb
Ruby
5
star
30

magic-cards-docker

Simple repo to get started with Magic Cards & Sonos right away.
Shell
5
star
31

college-humor-plex

Plex plugin for College Humor
Python
4
star
32

star-search

Cache, feed, and search your Campfire stars
Ruby
4
star
33

cocoaheads_gltouches

iPhone GL example app
Objective-C
3
star
34

giant_bomb

A simple Ruby library to talk to GiantBomb
Ruby
3
star
35

xbmc-remote

XBMC iPhone Remote
3
star
36

webcam-resolver

📺 Fetch m3u8 URLs for hosted webcams.
Ruby
3
star
37

bracket_busters

Provides scores for NCAA tournament
JavaScript
3
star
38

wrapper

GIT Mirror of The Worlds Worst Project
2
star
39

app_wiki

a place to store your app stuff
Ruby
2
star
40

broken.com

2
star
41

iphone2itunes

Browse and Watch the videos in your iTunes library from your iPhone.
JavaScript
2
star
42

test

2
star
43

mobile_scores

Finally, a simple freaking way to get your scores via your mobile
JavaScript
2
star
44

mschrag.github.com

mschrag.github.com
2
star
45

SiriProxy-Pugme

A simple SiriProxy plugin that will return a random photo of a pug
Ruby
2
star
46

star-searcher

Simple Ruby Client for Star Search - http://github.com/maddox/star-search
Ruby
2
star
47

slideshower

Simple way to generate the json that will power a future iPhone app that does simple slide shows
Ruby
2
star
48

Aeon-Slim

Slimified Aeon skin adjusted just for Plex
Python
2
star
49

nightscout-s3-proxy

🩸 Simple proxy for Nightscout data to S3
Shell
2
star
50

vlc

C
1
star
51

noodle

JavaScript
1
star
52

npe

npe
1
star
53

lol

JavaScript
1
star
54

rpi-docker-node-sonos-http-api

Docker wrapper for node-sonos-http-api for the Raspberry Pi
1
star
55

twictures

The code behind Twictur.es
Ruby
1
star