mStream/docs/API.md
2017-04-28 20:56:42 -04:00

2.9 KiB

mStream API

mStream uses a REST based API for everything.

All calls to the API are done through GET and POST requests. Make sure to set your Content-Type header to application/json when making a POST request

// jQuery Example

var request = $.ajax({
  url: "login",
  type: "POST",
  contentType: "application/json",
  dataType: "json",
  data: JSON.stringify(
    {
      username: "Bojack",
      password: "family"
    }
  )
});

Pages

These pages server various parts of the webapp

  • /
  • /remote
  • /shared/playlist/[PLAYLIST ID]

File Explorer

/dirparser

Playlists

/playlist/getall

/playlist/load

/playlist/save

/playlist/delete

Metadata (Albums/Artists/Etc)

/db/metadata

/db/search

/db/albums

/db/artists

/db/artist-albums

/db/album-songs

/db/status

/db/recursive-scan

JukeBox

/jukebox/push-to-client

Download

/download

Shared

/shared/make-shared

/shared/get-token-and-playlist

Login System & Authentication

mStream uses a token based authentication. The token you get when logging in can be used to access the API endpoints and the music files.

Login Functions:

Failure Endpoints:

  • /login-failed
  • /access-denied
  • /guest-access-denied

All API endpoints past this point requires a token to access if the login system is enabled. Tokens can be passed in through the GET or POST param token. Tokens can also be put in the request header under 'x-access-token'

If you want your tokens to work between reboots you can set the secret flag when booting by using mstream -s YOUR_SECERT_STRING_HERE. The secret key is used to sign the tokens. If you do not set the secret key mStream will generate a random key on boot

The security layer is written as a plugin. If you don't set the username and password on boot the plugin won't load and your server will be accessible by to anyone.

Streaming Files

To stream a file you need a three pieces of information:

  • The filepath - this is the filepath as it would show up on your disk. It's the relative filepath to the music directory you supply
  • The vPath - This is a virtual directory that's created on boot for security reasons.
  • The token - The user token (if user system is enabled)

The vPath can be obtained through /ping

To call a stream a file create a URL with the following structure

http://yourserver.com/vPath/filepath/song.mp3?token=XXXXXXXX