The SDK provides a typed interface to the public Rainwave Websocket API. It is currently only available in NodeJS environments.
Once connected, the Rainwave SDK instance will emit events from the Rainwave Websocket.
npm i rainwave-websocket-sdk
Obtain your own API key and numeric User ID:
Use them with the SDK:
const rw = new Rainwave({
apiKey: "aaaaaaaaa",
userId: 2,
sid: Station.game,
});
rw.on("sched_current", (current) => {
console.log(`${current.songs[0].albums[0].name} - ${current.songs[0].title}`);
});
await rw.startWebSocketSync();
The following events are emitted by the API when you connect, and on every song change:
user
: types.Useralbum_diff
: types.AlbumDiffrequest_line
: types.RequestLinesched_current
: types.RainwaveEventsched_next
: An array of types.RainwaveEventsched_history
: An array of types.RainwaveEventall_stations_info
: types.AllStationsInfoGenerated using TypeDoc