api server

intarstudents edited this page Mar 31, 2011 · 1 revision
Clone this wiki locally

Getting Started

What, what?

keyMazony API server ( internally known as acpAPI ) listens to HTTP 1.1 requests ( to specified port, with default tunned to 9900 ), those can be used to remotely control Amazon Cloud Player , who is siting inside Firefox or Prism.

Configure API server in keyMazony

Be sure that you know what is Firewall and what evil it can do, when configuring desired port number;

  • In Firefox main window go to Tools > Add-ons > (in list find keyMazony and press Preferences);
  • If server is running, press Stop;
  • Now in Port input box, select your desired port number;
  • Check Start with ... checkbox, if you want to start API server, when you open Firefox or Prism;
  • Press Start to run server;

FYI

Replace PORT in this wiki, with port number that you have chosen in keyMazony or with default one – 9900.

Sample usage (with wget in Ubuntu)

If you’re lazy terminal guy, you could write this wget command to play/pause current song, never leaving terminal window!

$ wget http://localhost:PORT/play --spider --no-cache

Simple and fast, isn’t it? Just remember that “With great power comes great responsibility.” ;)

Methods

API server has access to every keyboard shortcut toggle in keyMazony, so you can play, stop, select next song etc. easily with one of these methods.

List of them

Play/Pause current song

http://localhost:PORT/play

Stop playing current song

http://localhost:PORT/stop

Select previous song in playlist

http://localhost:PORT/previous

Select next song in playlist

http://localhost:PORT/next

Toggle mute

http://localhost:PORT/mute

Decrease volume

http://localhost:PORT/voldown

Increase volume

http://localhost:PORT/volup

Responses and Errors

In world, nothing is perfect, so same applies to this API. But luckily, if you really care what has gone wrong, you can see it.

200 – Method executed fine

If answer header to one of these methods has status code 200, you should be fine and method executed as supposed.

TOGGLING (play) OK

500 – Problems while executing method

If answer header to one of these methods has status code 500, you may experiencing little turbulence:

  • keyMazony couldn’t find Amazon Cloud Player;
  • Javascript API has been changed in Amazon Cloud Player;
TOGGLING (play) FAILED

501 – Not implemented

If answer header to one of these methods has status code 501, you have requested method that doesn’t exist in API.