Home Reference Source
import TuneIn from 'node-tunein-radio'
public class | source

TuneIn

TuneIn class, the main class implementing the module

Example:

let tuneinOptions = {
 protocol: 'https',                        // Protocol to use, either http or https
 cacheRequests: true,                      // Wheter to cache results or not, default false
 cacheTTL: 1000 * 60 * 60,                 // Cache TTL, default 5 minutes
 partnerId: process.env.TUNEIN_PARTNERID,  // PartnerID to be used when interacting with the TuneIn API
 };

let tunein = new TuneIn(tuneinOptions);

Constructor Summary

Public Constructor
public

constructor(options: object)

Constructur for a TuneIn object.

Method Summary

Public Methods
public

authenticate(options: object): *

Authenticate with supplied username / password, to get access to favorite and customised results

public

browse(options: object): object

Browse will browse the TuneIn directory depending on the supplied options paramethers

public

browse_best(username: string): *

Browse the best streams category

public

browse_langs(username: string): *

Browse streams languages

public

browse_local(username: string): *

Browse the local streams category

public

browse_locations(username: string): *

Browse streams locations

public

browse_music(username: string): *

Browse the Music streams category

public

browse_podcast(username: string): *

Browse the podcasts directory

public

browse_popular(username: string): *

Browse the popular streams category

public

browse_show(options: object): *

Browse a podcast (Show) for episodes details

public

browse_sports(username: string): *

Browse the sports streams category

public

browse_talk(username: string): *

Browse the talk streams category

public

describe(id: string, nowplaying: boolean): *

Describe a stream.

public

search(query: string): *

Search TuneIn for a match

public

tune_radio(id: string): *

Tune a stream.

Private Methods
private

_call_browse(options: *, req: *): *

private

_call_tunein_get(req: *): *

private

_call_tunein_post(req: *, postData: *): *

Public Constructors

public constructor(options: object) source

Constructur for a TuneIn object.

Params:

NameTypeAttributeDescription
options object

this is an options object with all the optionals parameters used to initialise the TuneIn client

Example:

let tuneinOptions = {
  protocol: 'https',                        // Protocol to use, either http or https
  cacheRequests: true,                      // Wheter to cache results or not, default false
  cacheTTL: 1000 * 60 * 60,                 // Cache TTL, default 5 minutes
  partnerId: process.env.TUNEIN_PARTNERID,  // PartnerID to be used when interacting with the TuneIn API
};

Public Methods

public authenticate(options: object): * source

Authenticate with supplied username / password, to get access to favorite and customised results

Params:

NameTypeAttributeDescription
options object

Options to be passed to the POST call, must contain user's credential

Return:

*

Example:

let authOptions = {
  username: 'user@example.com',
  password: 'secretpassword'
};
let auth = tunein.authenticate(authOptions);
auth.then(function(results) {
  console.log(results[0].AccountId);
});

public browse(options: object): object source

Browse will browse the TuneIn directory depending on the supplied options paramethers

Params:

NameTypeAttributeDescription
options object

Options object for browsing

Return:

object

results - A JSON object with results from the remote API

public browse_best(username: string): * source

Browse the best streams category

Params:

NameTypeAttributeDescription
username string

Currently ignored

Return:

*

public browse_langs(username: string): * source

Browse streams languages

Params:

NameTypeAttributeDescription
username string

Currently ignored

Return:

*

public browse_local(username: string): * source

Browse the local streams category

Params:

NameTypeAttributeDescription
username string

Currently ignored

Return:

*

public browse_locations(username: string): * source

Browse streams locations

Params:

NameTypeAttributeDescription
username string

Currently ignored

Return:

*

public browse_music(username: string): * source

Browse the Music streams category

Params:

NameTypeAttributeDescription
username string

Currently ignored

Return:

*

public browse_podcast(username: string): * source

Browse the podcasts directory

Params:

NameTypeAttributeDescription
username string

Currently ignored

Return:

*

Browse the popular streams category

Params:

NameTypeAttributeDescription
username string

Currently ignored

Return:

*

public browse_show(options: object): * source

Browse a podcast (Show) for episodes details

Params:

NameTypeAttributeDescription
options object

Options object including the show ID

Return:

*

Example:

let showOptions = {
  c: 'pbrowse',
  id: 'p191418'
};
let show = tunein.browse_show(showOptions);
show.then(function(results) {
  console.log(results);
});

public browse_sports(username: string): * source

Browse the sports streams category

Params:

NameTypeAttributeDescription
username string

Currently ignored

Return:

*

public browse_talk(username: string): * source

Browse the talk streams category

Params:

NameTypeAttributeDescription
username string

Currently ignored

Return:

*

public describe(id: string, nowplaying: boolean): * source

Describe a stream. This method will retrieve detailed information about a stream.

Params:

NameTypeAttributeDescription
id string

The ID of the stream to fetch information for

nowplaying boolean

If true it also fetches information about the show being currently aired

Return:

*

Search TuneIn for a match

Params:

NameTypeAttributeDescription
query string

a query string to search for in the TuneIn catalog

Return:

*

Example:

let queryString = 'rai radio';
let search = tunein.search(queryString);
search.then(function(results) {
  console.log(results);
});

public tune_radio(id: string): * source

Tune a stream. This will return an object containing details for the specific stream, including URL and format.

Params:

NameTypeAttributeDescription
id string

The ID of the stream to tune, usually resulting from a browsing or a search call

Return:

*

Private Methods

private _call_browse(options: *, req: *): * source

Params:

NameTypeAttributeDescription
options *
req *

Return:

*

private _call_tunein_get(req: *): * source

Params:

NameTypeAttributeDescription
req *

Return:

*

private _call_tunein_post(req: *, postData: *): * source

Params:

NameTypeAttributeDescription
req *
postData *

Return:

*