Skip to content
Stephane Jourdan edited this page Aug 5, 2015 · 7 revisions

API

The StreamMachine API gives some information and manipulation options.

All routes are handled in api.coffee.

GETs

  • GET /api/streams outputs the available streams, source status, or HLS information
    • GET /api/streams/<stream_name> outputs specific streams configuration information
  • GET /api/config outputs all available configuration for the streams
    • GET /api/streams/<stream_name>/config outputs all available configuration for a single stream
  • GET /api/slaves outputs for each stream master/slave status information
  • GET /api/listeners couldn't get it to work but probably outputs the listener count

POSTs

  • POST /api/streams creates a new stream
  • POST /api/streams/<stream_name>/metadata
  • POST /api/streams/<stream_name>/promote
  • POST /api/streams/<stream_name>/drop

Examples:

  • to create a new stream, you need a at least a key:
curl -F 'key=test' http://a.b.c.d:port/api/streams
  • to create a new user:
curl --data "user=johndoe&password=super_secure" http://a.b.c.d:port/api/users

PUTs

  • PUT /api/streams/<stream_name>/config

Examples:

  • to update the test stream password:
$ curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT -d '{"source_password":"testing_a_new_password"}' http://a.b.c.d:port/api/streams/test1/config
  • to give a full JSON file (ie. config/test_stream.json) to configure a stream:
$ curl -H "Content-Type: application/json" -H 'Accept: application/json' -X PUT --data @config/test_stream.json http://a.b.c.d:port/api/streams/test/config 

In this case the config/test_stream.json file would look like this:

{
  "key": "test",
  "root_route": true,
  "format": "mp3",
  "seconds": 3600,
  "metaTitle": "Testing",
  "host": "localhost",
  "source_password": "testing"
}

DELETEs

  • DELETE /api/streams/<stream_name>

Examples:

  • to delete the test stream:
$ curl -X "DELETE" http://a.b.c.d:port/api/streams/test
"OK"
  • or an user:
$ curl -X "DELETE" http://a.b.c.d:port/api/users/johndoe