Ákos Veres


Airapi Tunein From Golang

Ákos Veres's photo
Ákos Veres
·Sep 21, 2017·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Just a small snipet on how to send data to TuneIn’s AirAPI from golang. This way you can update your metadata information directly from your API, if you wish.

import (

func tuneinAPI(artist string, title string) {

    partnerid := os.Getenv("TUNEIN_PARTNER_ID")
    partnerkey := os.Getenv("TUNEIN_PARTNER_KEY")
    stationid := os.Getenv("TUNEIN_STATION_ID")
    if partnerid == "" || partnerkey == "" || stationid == "" {
        fmt.Println(time.Now(), "No tunein creds, skipping.")

    var URL *url.URL
    URL, err := url.Parse("http://air.radiotime.com/Playing.ashx?")
    if err != nil {
        fmt.Println(time.Now(), "Tunein URL unavailable")

    parameters := url.Values{}
    parameters.Add("partnerId", partnerid)
    parameters.Add("partnerKey", partnerkey)
    parameters.Add("id", stationid)
    parameters.Add("artist", artist)
    parameters.Add("title", title)
    URL.RawQuery = parameters.Encode()

    fmt.Printf("Encoded URL is %q\n", URL.String())
    res, err := http.Get(URL.String())
    if err != nil {
    if res.StatusCode == 200 {
        fmt.Println(time.Now(), "TuneIn: "+artist+" - "+title)
    } else {
        fmt.Println(time.Now(), "Tunein submission failed.")

Make sure you export the TUNEIN environment variables. This code is currently used over at XTRadio

Share this