# radio-browser

> nodejs module for radio-browser API (http://www.radio-browser.info/webservice)

Latest version **2.2.3** (published 2023-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install radio-browser
pnpm add radio-browser
yarn add radio-browser
bun add radio-browser
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.3 |
| Published | 2023-01-03 |
| First published | 2018-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/radio-browser) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 25.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 66 |
| Author | nepodev |
| Maintainers | nepodev |
| Keywords | webradio, radiobrowser, api, javascript |

## Links

- npm: https://www.npmjs.com/package/radio-browser
- Repository: https://github.com/nepodev/radio-browser
- Homepage: https://github.com/nepodev/radio-browser#readme
- Issues: https://github.com/nepodev/radio-browser/issues
- npm.io page: https://npm.io/package/radio-browser

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.2.3 (latest) — 2023-01-03
- 2.2.2 — 2022-11-14
- 2.2.1 — 2022-08-01
- 2.2.0 — 2022-07-03
- 2.1.10 — 2022-02-06
- 2.1.9 — 2021-11-28
- 2.1.8 — 2021-08-16
- 2.1.7 — 2021-04-17
- 2.1.6 — 2021-01-07
- 2.1.5 — 2020-11-21
- 2.1.4 — 2020-11-15
- 2.1.3 — 2020-09-13
- 2.1.2 — 2020-07-22
- 2.1.0 — 2020-05-25
- 2.0.3 — 2020-05-03
- … 18 more at https://npm.io/package/radio-browser/versions

## README

# RadioBrowser API Client

Nodejs module for [Radio-browser API](https://de1.api.radio-browser.info/)

## Install

```bash
npm install radio-browser
```

## Usage

Every method returns a promise so you have to use `then` and `catch` or `async` and `await`.

```js
const RadioBrowser = require('radio-browser')

let filter = {
    limit: 5,          // list max 5 items
    by: 'tag',         // search in tag
    searchterm: 'jazz' // term in tag
}
RadioBrowser.getStations(filter)
    .then(data => console.log(data))
    .catch(error => console.error(error))
```

## Methods

* `addStation(<params>)` [Add radio station](https://de1.api.radio-browser.info/#Add_radio_station)
* `clickStation(<stationuuid>)` [Station click counter](https://de1.api.radio-browser.info/#Count_station_click)
* `getCategory(<category>[, filter])` Get a list of [codecs](https://de1.api.radio-browser.info/#List_of_codecs), [countries](https://de1.api.radio-browser.info/#List_of_countries), [countrycodes](https://de1.api.radio-browser.info/#List_of_countrycodes), [languages](https://de1.api.radio-browser.info/#List_of_languages), [states](https://de1.api.radio-browser.info/#List_of_states), [tags](https://de1.api.radio-browser.info/#List_of_tags)
* `getChecks([stationuuid][, seconds])` [List of station check results](https://de1.api.radio-browser.info/#List_of_station_check_results)
* `getChecksteps(<uuids>)` [List of station check steps](https://de1.api.radio-browser.info/#List_of_station_check_steps)
* `getClicks([stationuuid][, seconds])` [List of station clicks](https://de1.api.radio-browser.info/#List_of_station_clicks)
* `getRandomHost()` Convenience function to get a random host without api request.
* `getServerConfig()` [Server config](https://de1.api.radio-browser.info/#Server_config)
* `getServerMirrors()` [Server mirrors](https://de1.api.radio-browser.info/#Server_mirrors)
* `getServerStats()` [Server stats](https://de1.api.radio-browser.info/#Server_stats)
* `getStations([filter])` [List of radio stations](https://de1.api.radio-browser.info/#List_of_radio_stations), Stations by [clicks](https://de1.api.radio-browser.info/#Stations_by_clicks), [Url](https://de1.api.radio-browser.info/#Search_radio_stations_by_url),  [vote](https://de1.api.radio-browser.info/#Stations_by_votes), [recent click](https://de1.api.radio-browser.info/#Stations_by_recent_click), [recent changed](https://de1.api.radio-browser.info/#Stations_by_recently_changed), [deleted](https://de1.api.radio-browser.info/#Stations_that_got_deleted), [need improvements](https://de1.api.radio-browser.info/#Stations_that_need_improvements), [broken](https://de1.api.radio-browser.info/#Broken_stations)
* `searchStations([params])` [Advanced station search](https://de1.api.radio-browser.info/#Advanced_station_search)
* `voteStation(<stationuuid>)` [Vote for station](https://de1.api.radio-browser.info/#Vote_for_station)

## Properties

* `filter_by_types` list of types using in getStations({by: {type}, ...})
* `category_types` list of categories using in getCategory({type} ...)
* `service_url` get or set the api-url. Default is `null` to get a random API host at first request.

## Examples:

Get Server Stats from a random API-Host by using async/await

```js
// file: examples/server-stats.js

const RadioBrowser = require('radio-browser')

const start = async () => {
    try {
        let data = await RadioBrowser.getServerStats()
        console.log(`API Server: ${RadioBrowser.service_url}`)
        console.log('stats', data)
    }
    catch (e) {
        console.error(e)
    }
}

start()
```

```bash
// example output
API Server: https://de1.api.radio-browser.info/
stats { supported_version: 1,
  software_version: '0.6.14',
  status: 'OK',
  stations: 25603,
  stations_broken: 767,
  tags: 6757,
  clicks_last_hour: 2707,
  clicks_last_day: 59547,
  languages: 374,
  countries: 246 }
```

Get the 5 top voted station 

```js
let filter = {
	by: 'topvote', // stations by topvote
	limit: 5    // top 5 stations
}
RadioBrowser.getStations(filter)
    .then(data => console.log(data))
    .catch(err => console.error(err))
```

`data` looks like [this](https://de1.api.radio-browser.info/json/stations/topvote/5)

---
_Source: https://npm.io/package/radio-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
