Web API for Google Cast enabled devices, based on the node-castv2 implementation by thibauts.
This API is only intended to be used on your local network not for hosting on the public internet.
$ npm install cast-web-api -g
You might run into issues with the optional Google-Assistant integration.
$ cast-web-api start
The server runs on your network IP:3000 by default. On error it defaults to 127.0.0.1. Adjustable via:
$ cast-web-api start -H 192.168.0.11 -p 8080
$ cast-web-api -h
USAGE
cast-web-api <command> [options]
COMMANDS
start Start cast-web-api as daemon
stop Stop the cast-web-api daemon
status Check status of the cast-web-api daemon
startup Start the cast-web-api daemon on system startup
unstartup Remove the cast-web-api daemon start on system startup
fix-perm Changes permissions on /config to current user
help <command> Display help for a specific command
GLOBAL OPTIONS
-h, --help Display help
-V, --version Display version
cast-web-api tries to behave like the Google Home app. All available devices will be connected to, if a device goes down, it'll be removed. If it randomly disconnects, it'll try to reconnect.
The autoConnect behavior can be turned of with the config parameter autoConnect
. This can be helpful for large speaker groups.
Every changed parameter will be saved in /config/config.json
.
Enable start cast-web-api on startup.
$ cast-web-api startup
Disable start cast-web-api on startup.
$ cast-web-api unstartup
Parse the swagger.json, in the online editor.
Install the devDependencies for instance git clone
this repo then npm install
into the repo. Docs now available at /swagger
.
Every log output follows this format: {time} {device id} {function name}: {message}. For easy differentiation between those components, device id is inverted in color and function name underlined. Info messages appear in your standard terminal color. Error messages in red, warning messages in red and server related messages in blue.
2018-03-31T18:27:09.508Z a90824f40764eb5df1fccc4f5cb95dd3 reconnectionManagement(): reconnecting
cast-web-js uses npm's debug package. Debugging can be enabled with the following command:
$ DEBUG=cast-web-api node (yourdirectory)/castWebApi.js
If you need further information you can enable debugging for the underlying castv2 module. You can either set the scope to castv2 or to everything:
$ DEBUG=* node (yourdirectory)/castWebApi.js
thibauts wrote a great protocol description. I can only highly recommend reading it.
If you read the first sentences of this file it goes without saying that you should not run this API on the internet. Run it behind a firewall only in your local network!
If you find a bug or typo, feel free to contact me, open an issue, fork it, open prs, you name it.