radiobrowser-api-client
Version:
Client for Radio Browser API
258 lines (257 loc) • 14.3 kB
TypeScript
import { Codec, Country, Language, Server, ServerConfig, ServerStats, State, Station, StationCheck, StationCheckStep, StationClick, StationOldVersion, Tag } from './types/data';
import { ICodecs, ICountries, ILanguages, ISearchStation, IStates, IStationChecks, IStationCheckSteps, IStationClicks, IStationOldVersion, ITags } from './types/queries';
import { ListOutputFormat, ObjectOutputFromat, StationsListOutputFormat } from './types/formats';
export declare class RadioBrowserClient {
private readonly axios;
private readonly jsonSerializer;
/**
* Constructor for RadioBrowserClient class.
* @param appName - Name of your application
* @param appVersion - Version of your application
*/
constructor(appName?: string, appVersion?: string);
/**
* Sends request to the Radio Browser API.
* @param endpoint - The endpoint of the API
* @param outputFormat - The format of the server response
* @param params - The parameters for the request
* @param baseURL - The base URL of the server (if axios.defaults.baseURL is set, it is not required)
* @returns The server response
*/
private sendRequest;
/**
* Fetches the list of available servers from the Radio Browser API.
* @param outputFormat - The output format for the list of servers (default is JSON)
* @see {@link https://all.api.radio-browser.info/#Server_mirrors} for more information on the API endpoint
* @returns A promise that resolves to the list of servers
*/
fetchServers(outputFormat?: StationsListOutputFormat): Promise<string>;
/**
* Fetches and parses the list of available servers from the Radio Browser API.
* @see {@link https://all.api.radio-browser.info/#Server_mirrors} for more information on the API endpoint
* @returns A promise that resolves to the list of servers
*/
getServers(): Promise<Server[]>;
/**
* Sets the server to be used for subsequent requests.
* @param serverName - The name of the server
*/
setServer(serverName: string): void;
/**
* Fetches stations from the Radio Browser API.
* @param params - The search parameters
* @param outputFormat - The output format for the list of stations (default is JSON)
* @see {@link https://all.api.radio-browser.info/#Advanced_station_search} for more information on the API endpoint
* @returns A promise that resolves to the list of stations
*/
fetchStations(params: ISearchStation, outputFormat?: StationsListOutputFormat): Promise<string>;
/**
* Fetches and parses stations from the Radio Browser API.
* @param params - The search parameters
* @returns A promise that resolves to the list of stations
*/
searchStations(params: ISearchStation): Promise<Station[]>;
/**
* Fetches stations from the Radio Browser API by given UUIDs.
* @param params - The search parameters
* @param outputFormat - The output format for the list of stations (default is JSON)
* @see {@link https://all.api.radio-browser.info/#Search_radio_stations_by_uuid} for more information on the API endpoint
* @returns A promise that resolves to the list of stations by given UUIDs
*/
fetchStationsByUUIDs(params: {
stationUUIDs: string[];
}, outputFormat?: StationsListOutputFormat): Promise<string>;
/**
* Fetches and parses stations from the Radio Browser API by given UUIDs.
* @param params - The search parameters
* @see {@link https://all.api.radio-browser.info/#Search_radio_stations_by_uuid} for more information on the API endpoint
* @returns A promise that resolves to the list of stations by given UUIDs
*/
getStationsByUUIDs(params: {
stationUUIDs: string[];
}): Promise<Station[]>;
/**
* Fetches countries from the Radio Browser API.
* @param params - The search parameters
* @param query - The search query
* @param outputFormat - The output format for the list of countires (default is JSON)
* @see {@link https://all.api.radio-browser.info/#List_of_countries} for more information on the API endpoint
* @returns A promise that resolves to the list of countires
*/
fetchCountries(params: ICountries, query?: string, outputFormat?: ListOutputFormat): Promise<string>;
/**
* Fetches and parses list of countries from the Radio Browser API.
* @param params - The search parameters
* @param query - The search query
* @see {@link https://all.api.radio-browser.info/#List_of_countries} for more information on the API endpoint
* @returns A promise that resolves to the list of countires
*/
getCountries(params: ICountries, query?: string): Promise<Country[]>;
/**
* Fetches codecs from the Radio Browser API.
* @param params - The search parameters
* @param query - The search query
* @param outputFormat - The output format for the list of codecs (default is JSON)
* @see {@link https://all.api.radio-browser.info/#List_of_codecs} for more information on the API endpoint
* @returns A promise that resolves to the list of codecs
*/
fetchCodecs(params: ICodecs, query?: string, outputFormat?: ListOutputFormat): Promise<string>;
/**
* Fetches and parses codecs from the Radio Browser API.
* @param params - The search parameters
* @param query - The search query
* @see {@link https://all.api.radio-browser.info/#List_of_codecs} for more information on the API endpoint
* @returns A promise that resolves to the list of codecs
*/
getCodecs(params: ICodecs, query?: string): Promise<Codec[]>;
/**
* Fetches states from the Radio Browser API.
* @param params - The search parameters
* @param query - The search query
* @param outputFormat - The output format for the list of states (default is JSON)
* @see {@link https://all.api.radio-browser.info/#List_of_states} for more information on the API endpoint
* @returns A promise that resolves to the list of states
*/
fetchStates(params: IStates, query?: string, outputFormat?: ListOutputFormat): Promise<string>;
/**
* Fetches and parses states from the Radio Browser API.
* @param params - The search parameters
* @param query - The search query
* @see {@link https://all.api.radio-browser.info/#List_of_states} for more information on the API endpoint
* @returns A promise that resolves to the list of states
*/
getStates(params: IStates, query?: string): Promise<State[]>;
/**
* Fetches languages from the Radio Browser API.
* @param params - The search parameters
* @param query - The search query
* @param outputFormat - The output format for the list of languages (default is JSON)
* @see {@link https://all.api.radio-browser.info/#List_of_languages} for more information on the API endpoint
* @returns A promise that resolves to the list of languages
*/
fetchLanguages(params: ILanguages, query?: string, outputFormat?: ListOutputFormat): Promise<string>;
/**
* Fetches and parses languages from the Radio Browser API.
* @param params - The search parameters
* @param query - The search query
* @see {@link https://all.api.radio-browser.info/#List_of_languages} for more information on the API endpoint
* @returns A promise that resolves to the list of languages
*/
getLanguages(params: ILanguages, query?: string): Promise<Language[]>;
/**
* Fetches tags from the Radio Browser API.
* @param params - The search parameters
* @param query - The search query
* @param outputFormat - The output format for the list of tags (default is JSON)
* @see {@link https://all.api.radio-browser.info/#List_of_tags} for more information on the API endpoint
* @returns A promise that resolves to the list of tags
*/
fetchTags(params: ITags, query?: string, outputFormat?: ListOutputFormat): Promise<string>;
/**
* Fetches and parses tags from the Radio Browser API.
* @param params - The search parameters
* @param query - The search query
* @see {@link https://all.api.radio-browser.info/#List_of_tags} for more information on the API endpoint
* @returns A promise that resolves to the list of tags
*/
getTags(params: ITags, query?: string): Promise<Tag[]>;
/**
* Fetches station checks from the Radio Browser API.
* @param params - The search parameters
* @param outputFormat - The output format for the list of station checks (default is JSON)
* @see {@link https://all.api.radio-browser.info/#List_of_station_check_results} for more information on the API endpoint
* @returns A promise that resolves to the list of station checks
*/
fetchStationChecks(params: IStationChecks, outputFormat?: ListOutputFormat): Promise<string>;
/**
* Fetches and parses station checks from the Radio Browser API.
* @param params - The search parameters
* @see {@link https://all.api.radio-browser.info/#List_of_station_check_results} for more information on the API endpoint
* @returns A promise that resolves to the list of station checks
*/
getStationChecks(params: IStationChecks): Promise<StationCheck[]>;
/**
* Fetches station clicks from the Radio Browser API.
* @param params - The search parameters
* @param outputFormat - The output format for the list of station clicks (default is JSON)
* @see {@link https://all.api.radio-browser.info/#List_of_station_clicks} for more information on the API endpoint
* @returns A promise that resolves to the list of station clicks
*/
fetchStationClicks(params: IStationClicks, outputFormat?: ListOutputFormat): Promise<string>;
/**
* Fetches and parses station clicks from the Radio Browser API.
* @param params - The search parameters
* @see {@link https://all.api.radio-browser.info/#List_of_station_clicks} for more information on the API endpoint
* @returns A promise that resolves to the list of station clicks
*/
getStationClicks(params: IStationClicks): Promise<StationClick[]>;
/**
* Fetches station check steps from the Radio Browser API.
* @param params - The search parameters
* @param outputFormat - The output format for the list of station check steps (default is JSON)
* @see {@link https://all.api.radio-browser.info/#List_of_station_check_steps} for more information on the API endpoint
* @returns A promise that resolves to the list of station check steps
*/
fetchStationCheckSteps(params: IStationCheckSteps, outputFormat?: ListOutputFormat): Promise<string>;
/**
* Fetches and parses station check steps from the Radio Browser API.
* @param params - The search parameters
* @param outputFormat - The output format for the list of station check steps (default is JSON)
* @see {@link https://all.api.radio-browser.info/#List_of_station_check_steps} for more information on the API endpoint
* @returns A promise that resolves to the list of station check steps
*/
getStationCheckSteps(params: IStationCheckSteps): Promise<StationCheckStep[]>;
/**
* Fetches old versions of station from the Radio Browser API.
* @param params - The search parameters
* @param outputFormat - The output format for the list of station old versions (default is JSON)
* @see {@link https://all.api.radio-browser.info/#Old_versions_of_stations} for more information on the API endpoint
* @returns A promise that resolves to the list of station old versions
*/
fetchStationOldVersion(params: IStationOldVersion, stationUUID?: string, outputFormat?: ListOutputFormat): Promise<string>;
/**
* Fetches and parses old versions of station from the Radio Browser API.
* @param params - The search parameters
* @see {@link https://all.api.radio-browser.info/#Old_versions_of_stations} for more information on the API endpoint
* @returns A promise that resolves to the list of station old versions
*/
getStationOldVersion(params: IStationOldVersion, stationUUID?: string): Promise<StationOldVersion[]>;
/**
* Fetches server stats from the Radio Browser API.
* @param outputFormat - The output format for the server stats (default is JSON)
* @see {@link https://all.api.radio-browser.info/#Server_stats} for more information on the API endpoint
* @returns A promise that resolves to the server stats
*/
fetchServerStats(outputFormat?: ObjectOutputFromat): Promise<string>;
/**
* Fetches and parses server stats from the Radio Browser API.
* @see {@link https://all.api.radio-browser.info/#Server_stats} for more information on the API endpoint
* @returns A promise that resolves to the server stats
*/
getServerStats(): Promise<ServerStats>;
/**
* Fetches server config from the Radio Browser API.
* @param outputFormat - The output format for the server config (default is JSON)
* @see {@link https://all.api.radio-browser.info/#Server_config} for more information on the API endpoint
* @returns A promise that resolves to the server config
*/
fetchServerConfig(outputFormat?: ObjectOutputFromat): Promise<string>;
/**
* Fetches server config from the Radio Browser API.
* @see {@link https://all.api.radio-browser.info/#Server_config} for more information on the API endpoint
* @returns A promise that resolves to the server config
*/
getServerConfig(): Promise<ServerConfig>;
/**
* Votes for the station by given UUID.
* @see {@link https://all.api.radio-browser.info/#Vote_for_station} for more information on the API endpoint
* @param stationUUID - The UUID of the station to vote for
*/
voteForStation(stationUUID: string): Promise<void>;
/**
* Logs a click for the station by given UUID.
* @see {@link https://all.api.radio-browser.info/#Count_station_click} for more information on the API endpoint
* @param stationUUID - The UUID of the station for which the click is logged
*/
click(stationUUID: string): Promise<void>;
}