![]() |
[How To] access the API via HTTP using curl - Printable Version +- Moode Forum (https://moodeaudio.org/forum) +-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3) +--- Forum: FAQ and Guides (https://moodeaudio.org/forum/forumdisplay.php?fid=9) +--- Thread: [How To] access the API via HTTP using curl (/showthread.php?tid=2342) |
[How To] access the API via HTTP using curl - TheOldPresbyope - 04-05-2020 Included in moOde is a command API accessible via HTTP and ssh. Using ssh is pretty self-explanatory but accessing the API via HTTP may not be. Yes, you can manually type commands like
Linux, macOS, and Windows 10 [1] now all include a command-line tool named curl (sometimes written in text as cURL). This is a classic "Swiss Army knife" tool with lots of options. With it, we can easily script HTTP-based commands to the moOde API. You can read the curl man page, but here's some examples of its use with moOde to get you started. Code: curl -G http://moode/command/ -d "cmd=play" The -G option tells curl to send an HTTP GET request rather than a POST request. Essentially this causes the same HTTP transaction as the "?" in the http://moode/command/?cmd=... strings does in browsers. The -d (or --data) option indicates the item following it is the request payload. Be sure to use the correct hostname or IP for your moOde player. Use and enjoy. Regards, Kent [1] I don't own any Macs so I have to rely on what I read on the InterWeb. I've used curl in both Linux and Windows 10 systems (in cmd.exe, Powershell, and, of course, any Linux installed in Windows Subsystem for Linux). RE: [How To] access the API via HTTP using curl - Coustard - 04-05-2020 Great, thanks. Is there a list of commands available somewhere? I can confirm, BTW, that it works fine from a Mac. RE: [How To] access the API via HTTP using curl - TheOldPresbyope - 04-06-2020 (04-05-2020, 09:31 PM)Coustard Wrote: Great, thanks. Is there a list of commands available somewhere? Currently, the -d "cmd=..." construct works with
Thanks for checking macOS. Regards, Kent [1] A strict reading of the output from /var/www/vol.sh --help indicates the verb up|dn|mute|restore should be preceded by a minus sign. Turns out it accepts the verbs with or without the preceding minus sign. RE: [How To] access the API via HTTP using curl - Coustard - 04-06-2020 Very cool. Thanks. |