#api #query-api #api-bindings

radiobrowser

Client library for radiobrowser compatible servers with auto fallback to other available servers

8 releases (5 breaking)

0.6.1 Oct 20, 2023
0.6.0 Sep 13, 2023
0.5.0 Jan 27, 2023
0.4.1 Sep 14, 2022
0.1.0 Apr 21, 2022

#104 in Audio

Download history 8/week @ 2024-01-25 28/week @ 2024-02-22 64/week @ 2024-02-29 5/week @ 2024-03-07 4/week @ 2024-03-14

81 downloads per month

MIT license

46KB
1K SLoC

Radiobrowser Lib Rust

Client library for radio-browser.info and other radio-browser-rust servers

Features

  • Async / Blocking API
  • Clean query api with builder pattern
  • Countries, languages, tags, stations, serverconfig
  • Server statistics
  • Station actions: click, vote
  • Add streams

Crate features

  • "blocking" - support for non-async (blocking) mode
  • "chrono" - return DateTime objects instead of strings

Getting started (Blocking)

Example:

It needs to have the feature "blocking" enabled. Cargo.toml entry:

radiobrowser = { version = "*", features = ["blocking"] }
use radiobrowser::blocking::RadioBrowserAPI;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    let mut api = RadioBrowserAPI::new()?;
    let servers = RadioBrowserAPI::get_default_servers()?;
    println!("Servers: {:?}", servers);
    let status = api.get_server_status()?;
    println!("Status: {:?}", status);
    let countries = api.get_countries().send()?;
    println!("Countries: {:?}", countries);
    let stations = api.get_stations().name("jazz").send()?;
    println!("Stations: {:?}", stations);
    Ok(())
}

Getting started (Async)

Cargo.toml entry

radiobrowser = "*"

Example:

use radiobrowser::RadioBrowserAPI;
use radiobrowser::StationOrder;
use std::error::Error;

#[async_std::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let mut api = RadioBrowserAPI::new().await?;
    let stations = api
        .get_stations()
        .name("jazz")
        .reverse(true)
        .order(StationOrder::Clickcount)
        .send()
        .await?;

    println!("Stations found: {}", stations?.len());
    Ok(())
}

Usage

Documentation is at https://docs.rs/radiobrowser

License

This project is MIT licensed.

Dependencies

~15–32MB
~542K SLoC