Skip to content

Service API

salendron edited this page Jan 24, 2013 · 8 revisions

Snakeberry is a RESTful webservice. So you can control it by callong following webservice endpoint URLs.

All methods return a JSON Response object. Containing an ErrorCode (0 if no error occured), an ErrorMessage (empty if no error occured) and a ResponseData-Object. This ResponseData-Object is different for every method of the service an described below.

ListServices

Method GET

URL: :8888/

Returns a list of all available services in the ResponseData-Object.

Example Response:

{"ErrorCode": 0, "ResponseData": {"Services": [{"DisplayName": "Radio", "BaseUrl": "/radio"}]}, "ErrorMessage": ""}

ListRadioStations

Method GET

URL: :8888/

Returns a list of all available radio stations.

Example Response:

{"ErrorCode": 0, "ResponseData": {"Radios": [{"StreamUrl": "mms://apasf.apa.at/OE3_Live_Audio", "DisplayName": "OE3", "RadioId": "OE3"}, {"StreamUrl": "http://mp3stream1.apasf.apa.at:8000", "DisplayName": "FM4", "RadioId": "FM4"}, {"StreamUrl": "http://bbc.co.uk/radio/listen/live/r1_aaclca.pls", "DisplayName": "BBC1", "RadioId": "BBC1"}, {"StreamUrl": "http://www.antennestream.at", "DisplayName": "Antenne Kaernten", "RadioId": "ATNKTN"}]}, "ErrorMessage": ""}

GetMac

Method GET

URL: :8888/getmac

Returns the hardware adress of the raspberry as decimal not as HEX.

Example Response:

{"ErrorCode": 0, "ResponseData": 100068776059597, "ErrorMessage": ""}

Play Radio

Method GET

URL: :8888/radio/play/

Starts to play a radio station on Raspberry.

Example Response:

{"ErrorCode": 0, "ResponseData": null, "ErrorMessage": ""}

Stop Radio

Method GET

URL: :8888/radio/stop

Stops radio station on Raspberry.

Example Response:

{"ErrorCode": 0, "ResponseData": null, "ErrorMessage": ""}

Radio now playing

Method GET

URL: :8888/radio/nowplaying

Stops radio station on Raspberry.

Example Response:

{"ErrorCode": 0, "ResponseData": {"MediaURI": "mms://apasf.apa.at/OE3_Live_Audio", "PID": 2069, "MediaType": "Radio", "Description": "OE3"}, "ErrorMessage": ""}

GetVolume

Method GET

URL: :8888/getvolume

Gets the system volume. This is a value between -10239 (0%) and 400 (100%).

Example Response:

{"ErrorCode": 0, "ResponseData": -400, "ErrorMessage": ""}

SetVolume

Method GET

URL: :8888/setvolume/

Sets the system volume. This is a value between -10239 (0%) and 400 (100%).

Example Response:

{"ErrorCode": 0, "ResponseData": null, "ErrorMessage": ""}

Clone this wiki locally