Skip to content

REST API

Elijah Lopez edited this page Apr 1, 2021 · 36 revisions

This is some of the REST API that you can call to control music caster. The default API endpoint is http://localhost:2001/. In cases where the port 2001 is already being used, Music Caster will keep trying to bind to the next highest port (e.g. 2002, 2003, etc.).

GET /running/

  • this method is useful for verifying Music Caster is running on the port you assumed it was running on
  • tip check if Music Caster is a live process before iterating port numbers [2001, 2010] and and trying to call the API
  • returns true

GET /?is_api&play

  • the is_api flag is used to return API messages. If you don't supply it, you will get redirected to / instead of receiving a API response
  • if paused, resume playback.
  • else if tracks are in the queue, play the first item (index 0).
  • else if there are no tracks in the queue, library is shuffled and played (if any tracks were queued).

GET /?is_api&pause

  • pauses the player

GET /?is_api&next

  • try to play the next track
  • return value does not indicate success

GET /?is_api&prev

  • try to play the previous track
  • return value does not indicate success

GET /?is_api&repeat

  • cycles repeat
  • repeat states include: off, one (repeat current track), and all (plays queue on repeat)

GET /?is_api&shuffle

  • toggles shuffle for playlists

GET /now-playing/

  • returns the metadata of the current track, volume, and the playing status

POST /play/

  • play or queue files/folders/urls/playlists
  • json = {'uris': ['file_path', 'folder_path', 'url', 'playlist_name']}
  • json = {'uri': 'file_path/folder_path/url/playlist_name', 'queue': true}
  • DEFAULTS: queue: false

GET/POST /exit/

  • stop playing and exit

GET /refresh-devices/

  • scan for Chromecasts on the network

GET/POST /timer/

  • GET the current timer
  • POST possible_args = 'cancel', minutes, 'HH:MM'
Clone this wiki locally