Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • new Rainwave(options: { apiKey: string; debug?: undefined | ((msg: string | Error) => void); onSocketError?: undefined | OnSocketErrorType; sid: Station; url?: undefined | string; userId: number }): Rainwave
  • Parameters

    • options: { apiKey: string; debug?: undefined | ((msg: string | Error) => void); onSocketError?: undefined | OnSocketErrorType; sid: Station; url?: undefined | string; userId: number }
      • apiKey: string
      • Optional debug?: undefined | ((msg: string | Error) => void)
      • Optional onSocketError?: undefined | OnSocketErrorType
      • sid: Station
      • Optional url?: undefined | string
        defaultvalue

        "wss://rainwave.cc/api4/websocket/"

      • userId: number

    Returns Rainwave

Connection Methods

startWebSocketSync

  • startWebSocketSync(): Promise<boolean>
  • Connect, authenticate, get current Rainwave status, and subscribe to Rainwave API events.

    Returns Promise<boolean>

stopWebSocketSync

  • stopWebSocketSync(): Promise<void>
  • Disconnect from the Rainwave API.

    Returns Promise<void>

Event Handling Methods

off

  • Remove a callback from the Rainwave API event handling.

    Type parameters

    • K: "albums" | "artists" | "songs" | "album" | "all_albums_paginated" | "all_artists_paginated" | "all_faves" | "all_groups_paginated" | "all_songs" | "artist" | "group" | "listener" | "ping" | "pong" | "playback_history" | "request_line" | "song" | "station_song_count" | "stations" | "top_100" | "unrated_songs" | "user_info" | "user_recent_votes" | "user_requested_history" | "wserror" | "rate_result" | "requests" | "fave_album_result" | "fave_all_songs_result" | "fave_song_result" | "all_stations_info" | "order_requests_result" | "pause_request_queue_result" | "user" | "request_favorited_songs_result" | "request_unrated_songs_result" | "unpause_request_queue_result" | "vote_result" | "album_diff" | "already_voted" | "api_info" | "build_version" | "cookie_domain" | "delete_request_result" | "error_report_result" | "error" | "live_voting" | "locale" | "locales" | "message_id" | "mobile" | "on_draw" | "on_init" | "on_measure" | "pongConfirm" | "redownload_m3u" | "relays" | "request_result" | "sched_current" | "sched_history" | "sched_next" | "sdk_exception" | "sdk_error_clear" | "sdk_schedule_synced" | "station_list" | "stream_filename" | "sync_result" | "websocket_host" | "wsok" | "wsthrottle"

    Parameters

    Returns void

on

  • Add a callback to handle a Rainwave API event.

    Type parameters

    • K: "albums" | "artists" | "songs" | "album" | "all_albums_paginated" | "all_artists_paginated" | "all_faves" | "all_groups_paginated" | "all_songs" | "artist" | "group" | "listener" | "ping" | "pong" | "playback_history" | "request_line" | "song" | "station_song_count" | "stations" | "top_100" | "unrated_songs" | "user_info" | "user_recent_votes" | "user_requested_history" | "wserror" | "rate_result" | "requests" | "fave_album_result" | "fave_all_songs_result" | "fave_song_result" | "all_stations_info" | "order_requests_result" | "pause_request_queue_result" | "user" | "request_favorited_songs_result" | "request_unrated_songs_result" | "unpause_request_queue_result" | "vote_result" | "album_diff" | "already_voted" | "api_info" | "build_version" | "cookie_domain" | "delete_request_result" | "error_report_result" | "error" | "live_voting" | "locale" | "locales" | "message_id" | "mobile" | "on_draw" | "on_init" | "on_measure" | "pongConfirm" | "redownload_m3u" | "relays" | "request_result" | "sched_current" | "sched_history" | "sched_next" | "sdk_exception" | "sdk_error_clear" | "sdk_schedule_synced" | "station_list" | "stream_filename" | "sync_result" | "websocket_host" | "wsok" | "wsthrottle"

    Parameters

    Returns void

API Request Methods

album

  • album(params: { id: number; sort?: undefined | "added_on" }): Promise<{ album: AlbumWithDetail }>
  • Get detailed information about an album, including a list of songs in the album.

    api4

    album

    Parameters

    • params: { id: number; sort?: undefined | "added_on" }
      • id: number

        ID of album to load from API.

      • Optional sort?: undefined | "added_on"

        How songs in the album will be sorted.

        • undefined | null: alphabetically.
        • added_on: when song was added to Rainwave.

    Returns Promise<{ album: AlbumWithDetail }>

allAlbums

  • allAlbums(progressCallback?: (progress: number) => void): Promise<AlbumInList[]>
  • Gets all albums from the service. Provide a callback if you want percentage progress while the data loads.

    Parameters

    • Optional progressCallback: (progress: number) => void

      accepts a number from 0 to 100 representing loading progress

        • (progress: number): void
        • Parameters

          • progress: number

          Returns void

    Returns Promise<AlbumInList[]>

allAlbumsPaginated

  • allAlbumsPaginated(params?: { after?: undefined | number }): Promise<{ all_albums_paginated: AllAlbumsPaginated }>
  • Gets a list of all albums on the server by paging 1000 albums at a time.

    api4

    all_albums_paginated

    Parameters

    • Optional params: { after?: undefined | number }
      • Optional after?: undefined | number

    Returns Promise<{ all_albums_paginated: AllAlbumsPaginated }>

allArtists

  • allArtists(progressCallback?: (progress: number) => void): Promise<ArtistInList[]>
  • Gets all artists from the service. Provide a callback if you want percentage progress while the data loads.

    Parameters

    • Optional progressCallback: (progress: number) => void

      accepts a number from 0 to 100 representing loading progress

        • (progress: number): void
        • Parameters

          • progress: number

          Returns void

    Returns Promise<ArtistInList[]>

allArtistsPaginated

  • allArtistsPaginated(params?: { after?: undefined | number }): Promise<{ all_artists_paginated: AllArtistsPaginated }>
  • Gets all artists from Rainwave in by paging 1000 artists at a time.

    api4

    all_artists_paginated

    Parameters

    • Optional params: { after?: undefined | number }
      • Optional after?: undefined | number

    Returns Promise<{ all_artists_paginated: AllArtistsPaginated }>

allFaves

  • allFaves(): Promise<{ all_faves: FaveSong[] }>
  • Get all songs that have been faved by the user by page.

    api4

    all_faves

    Returns Promise<{ all_faves: FaveSong[] }>

allGroups

  • allGroups(progressCallback?: (progress: number) => void): Promise<GroupInList[]>
  • Gets all groups from the service. Provide a callback if you want percentage progress while the data loads.

    Parameters

    • Optional progressCallback: (progress: number) => void

      accepts a number from 0 to 100 representing loading progress

        • (progress: number): void
        • Parameters

          • progress: number

          Returns void

    Returns Promise<GroupInList[]>

allGroupsPaginated

  • allGroupsPaginated(params?: { after?: undefined | number }): Promise<{ all_groups_paginated: AllGroupsPaginated }>
  • Get a list of all song groups on the station playlist by paging 1000 groups at a time.

    api4

    all_groups_paginated

    Parameters

    • Optional params: { after?: undefined | number }
      • Optional after?: undefined | number

    Returns Promise<{ all_groups_paginated: AllGroupsPaginated }>

allSongs

artist

  • Get detailed information about an artist.

    api4

    artist

    Parameters

    • params: { id: number }
      • id: number

        ID of Artist to load from the API.

    Returns Promise<{ artist: ArtistWithSongs }>

clearRating

  • clearRating(params: { song_id: number }): Promise<{ rate_result: RateResult }>
  • Remove a user's song rating.

    api4

    clear_rating

    Parameters

    • params: { song_id: number }
      • song_id: number

        Song ID of rating to clear.

    Returns Promise<{ rate_result: RateResult }>

clearRequests

  • clearRequests(): Promise<{ requests: Requests }>
  • Clears all requests from the user's queue.

    api4

    clear_requests

    Returns Promise<{ requests: Requests }>

clearRequestsOnCooldown

  • clearRequestsOnCooldown(): Promise<{ requests: Requests }>
  • Clears all requests from the user's queue that are on a cooldown of 20 minutes or more.

    api4

    clear_requests_on_cooldown

    Returns Promise<{ requests: Requests }>

deleteRequest

  • deleteRequest(params: { song_id: number }): Promise<{ requests: Requests }>
  • Removes a request from the user's queue.

    api4

    delete_request

    Parameters

    • params: { song_id: number }
      • song_id: number

        ID of Song in user's RequestQueue to delete.

    Returns Promise<{ requests: Requests }>

faveAlbum

  • faveAlbum(params: { album_id: number; fave: boolean }): Promise<{ fave_album_result: FaveAlbumResult }>
  • Fave or un-fave an album, specific to the station the request is being made on.

    api4

    fave_album

    Parameters

    • params: { album_id: number; fave: boolean }
      • album_id: number

        ID of Album to update.

      • fave: boolean

        true to set album as a fave, false to un-fave.

    Returns Promise<{ fave_album_result: FaveAlbumResult }>

faveAllSongs

  • faveAllSongs(params: { album_id: number; fave: boolean }): Promise<{ fave_all_songs_result: FaveAllSongsResult }>
  • Faves or un-faves all songs in an album. Only songs on the station the websocket is conneted to will be faved.

    api4

    fave_all_songs

    Parameters

    • params: { album_id: number; fave: boolean }
      • album_id: number

        ID of Album to update. All songs in this Album will be updated.

      • fave: boolean

        true to set all Songs in the Album as faves, false to un-fave all Songs in the Album.

    Returns Promise<{ fave_all_songs_result: FaveAllSongsResult }>

faveSong

  • faveSong(params: { fave: boolean; song_id: number }): Promise<{ fave_song_result: FaveSongResult }>
  • Fave or un-fave a song.

    api4

    fave_song

    Parameters

    • params: { fave: boolean; song_id: number }
      • fave: boolean

        true to set Song as a fave, false to un-fave.

      • song_id: number

        ID of Song to update.

    Returns Promise<{ fave_song_result: FaveSongResult }>

group

  • Get detailed information about a song group.

    api4

    group

    Parameters

    • params: { id: number }
      • id: number

        ID of Group to load.

    Returns Promise<{ group: GroupWithDetail }>

infoAll

  • Returns a basic dict containing rudimentary information on what is currently playing on all stations.

    api4

    info_all

    Returns Promise<{ all_stations_info: Record<Station, StationInfo> }>

listener

  • listener(params: { id: number }): Promise<{ listener: Listener }>
  • Gets detailed information, such as favourite albums and rating histogram, on a particular user.

    api4

    listener

    Parameters

    • params: { id: number }
      • id: number

        ID of User to load.

    Returns Promise<{ listener: Listener }>

orderRequests

  • orderRequests(params: { order: number[] }): Promise<{ order_requests_result: BooleanResult; requests: Requests }>
  • Change the order of requests in the user's queue. Submit a comma-separated list of Song IDs, in desired order.

    api4

    order_requests

    Parameters

    • params: { order: number[] }
      • order: number[]

    Returns Promise<{ order_requests_result: BooleanResult; requests: Requests }>

pauseRequestQueue

  • pauseRequestQueue(): Promise<{ pause_request_queue_result: BooleanResult; user: User }>
  • Stops the user from having their request queue processed while they're listening. Will remove them from the request line.

    api4

    pause_request_queue

    Returns Promise<{ pause_request_queue_result: BooleanResult; user: User }>

playbackHistory

  • Get the last 100 songs that played on the station.

    api4

    playback_history

    Returns Promise<{ playback_history: PlaybackHistory }>

rate

  • Rate a song.

    For new users, the user must have been tuned in for this song to rate it, or they must be tuned in if it's the currently playing song.

    For users who have rated 100 songs, they are allowed to rate any song at any time.

    Songs that are part of RainwaveEventSong have a rating_allowed property you can use to check before submission if the user can rate. For other songs, you can use the rate_anything property of User to check before submission. The API will return a RainwaveErrorObject if the user is not allowed to rate the song yet.

    api4

    rate

    Parameters

    Returns Promise<{ rate_result: RateResult }>

request

  • request(params: { song_id: number }): Promise<{ requests: Requests }>
  • Submits a request for a song.

    api4

    request

    Parameters

    • params: { song_id: number }
      • song_id: number

        ID of Song to request.

    Returns Promise<{ requests: Requests }>

requestFavoritedSongs

  • requestFavoritedSongs(params?: { limit?: undefined | number }): Promise<{ request_favorited_songs_result: BooleanResult; requests: Requests }>
  • Fills the user's request queue with favorited songs.

    api4

    request_favorited_songs

    Parameters

    • params: { limit?: undefined | number } = ...
      • Optional limit?: undefined | number

        Maximum number of songs to add to user's request queue. Not providing this will fill the entire user's request queue.

    Returns Promise<{ request_favorited_songs_result: BooleanResult; requests: Requests }>

requestLine

  • requestLine(): Promise<{ request_line_result: RequestLine }>
  • Gives a list of who is waiting in line to make a request on the given station, plus their current top-requested song if they have one available.

    api4

    request_line

    Returns Promise<{ request_line_result: RequestLine }>

requestUnratedSongs

  • requestUnratedSongs(params?: { limit?: undefined | number }): Promise<{ request_unrated_songs_result: BooleanResult; requests: Requests }>
  • Fills the user's request queue with unrated songs.

    api4

    request_unrated_songs

    Parameters

    • params: { limit?: undefined | number } = ...
      • Optional limit?: undefined | number

        Maximum number of songs to add to user's request queue. Not providing this will fill the entire user's request queue.

    Returns Promise<{ request_unrated_songs_result: BooleanResult; requests: Requests }>

search

  • Search artists, albums, and songs for a matching string. Case insensitive. Submitted string will be stripped of accents and punctuation.

    api4

    search

    Parameters

    • params: { search: string }
      • search: string

        Term to search for. Must be three letters or longer.

    Returns Promise<{ albums: SearchAlbum[]; artists: SearchArtist[]; songs: SearchSong[] }>

song

  • Get detailed information about a song.

    api4

    song

    Parameters

    • params: { id: number }
      • id: number

        ID of Song to load from API.

    Returns Promise<{ song: SongWithDetail }>

stationSongCount

  • Get the total number of songs in the playlist on each station.

    api4

    station_song_count

    Returns Promise<{ station_song_count: StationSongCount }>

stations

  • stations(): Promise<{ stations: Stations }>
  • Get information about all available stations.

    api4

    stations

    Returns Promise<{ stations: Stations }>

top100

  • top100(): Promise<{ top_100: Top100 }>
  • Get the 100 highest-rated songs on the station the websocket is connected to.

    api4

    top_100

    Returns Promise<{ top_100: Top100 }>

unpauseRequestQueue

  • unpauseRequestQueue(): Promise<{ unpause_request_queue_result: BooleanResult; user: User }>
  • Allows the user's request queue to continue being processed. Adds the user back to the request line.

    api4

    unpause_request_queue

    Returns Promise<{ unpause_request_queue_result: BooleanResult; user: User }>

unratedSongs

  • Get all of a user's unrated songs by page.

    api4

    unrated_songs

    Returns Promise<{ unrated_songs: UnratedSongs }>

userRecentVotes

  • Shows the songs the user recently voted for.

    api4

    user_recent_votes

    Returns Promise<{ user_recent_votes: UserRecentVotes }>

userRequestedHistory

  • userRequestedHistory(): Promise<{ user_requested_history: UserRecentVotes }>
  • Shows requests of a user that were entered into an election.

    api4

    user_requested_history

    Returns Promise<{ user_requested_history: UserRecentVotes }>

vote

  • vote(params: { entry_id: number }): Promise<{ vote: VoteResult }>
  • Vote for a candidate in an election.

    If user has already voted, the vote will be changed to the submitted song.

    api4

    vote

    Parameters

    • params: { entry_id: number }

    Returns Promise<{ vote: VoteResult }>

Generated using TypeDoc