Skip to content

Methods (v1)

Chezzer edited this page Nov 15, 2021 · 11 revisions

/api/treble/stats

Get stats from Bunker's or any Azura Cast API URL specified in config.json.

Example Request

http://localhost:5050/api/treble/stats

Response Breakdown

{
  "success": true, whether the response has an error
  "song": {
    "title": "Power", song title
    "artist": "Brad Wood (UK)", artist title
    "album": "Brad Wood (UK)" album title
  },
  "on_air": {
    "live": "AutoDJ" current live DJ, shows "AutoDJ" when no one is live
  },
  "listeners": {
    "total": 0, total listeners
    "current": 0, current listeners
    "unique": 0 unique IP listeners
  },
  "important": { must be included for any request
    "notice": "This API is for bunker.dance, if you'd like to use this for your own station, please include this notice and the source.",
    "source": "https://github.com/bunkerradio/api"
  }
}

/api/treble/lookup

Lookup song data using the Deezer & Spotify API. An alternative to xonos.tools

Query Parameters

search: the search to conduct.

Possible field filters:

track:<String>: Track name

artist:<String>: Artist name

album:<String>: Album name

isrc:<String>: ISRC ID

genre:<String>: Genre name

year:<String>: Year number

You can also use the NOT operator to exclude keywords from your search.

Example Request

http://localhost:5050/api/treble/lookup?search=track:Gods Plan artist:Drake album:Scorpion NOT track:f

JQuery Exmaple

let search = encodeURIComponent("track:Gods Plan artist:Drake");
$.getJSON(`https://bunker.dance/api/treble/lookup?search=${search}`, (track) => {
    console.log(track)
})

Note: the encodeURIComponent function is crucial to allow /'s and other URL characters into the search.

Response Breakdown

{
  "success": true, if there is an error or not
  "result": {
    "title": "God's Plan", title of track
    "artist": {
      "names": "Drake", a list of names of the artists
      "spotify_id": "3TVXtAsR1Inumwj472S9r4", spotify ID of the main artist
      "deezer_id": 246791, deezer ID of the main artist
      "picture": { an array of pictures for the main artist
        "xl": "https://e-cdns-images.dzcdn.net/images/artist/5d2fa7f140a6bdc2c864c3465a61fc71/1000x1000-000000-80-0-0.jpg",
        "large": "https://e-cdns-images.dzcdn.net/images/artist/5d2fa7f140a6bdc2c864c3465a61fc71/500x500-000000-80-0-0.jpg",
        "medium": "https://e-cdns-images.dzcdn.net/images/artist/5d2fa7f140a6bdc2c864c3465a61fc71/250x250-000000-80-0-0.jpg",
        "small": "https://e-cdns-images.dzcdn.net/images/artist/5d2fa7f140a6bdc2c864c3465a61fc71/56x56-000000-80-0-0.jpg"
      }
    },
    "album": {
      "title": "Scorpion", title of album
      "spotify_id": "1ATL5GLyefJaxhQzSPVrLX", spotify ID of the album
      "deezer_id": 69319552 deezer ID of the album
    },
    "color": [ RGB value of dominant color in the track cover
      51,
      51,
      51
    ],
    "covers": { an array of pictures for the track
      "xl": "https://e-cdns-images.dzcdn.net/images/cover/b69d3bcbd130ad4cc9259de543889e30/1000x1000-000000-80-0-0.jpg",
      "large": "https://e-cdns-images.dzcdn.net/images/cover/b69d3bcbd130ad4cc9259de543889e30/500x500-000000-80-0-0.jpg",
      "medium": "https://e-cdns-images.dzcdn.net/images/cover/b69d3bcbd130ad4cc9259de543889e30/250x250-000000-80-0-0.jpg",
      "small": "https://e-cdns-images.dzcdn.net/images/cover/b69d3bcbd130ad4cc9259de543889e30/56x56-000000-80-0-0.jpg"
    },
    "spotify_id": "6DCZcSspjsKoFjzjrWoCdn", spotify ID of the track (https://open.spotify.com/track/<id here>)
    "deezer_id": 533609232, deezer ID of the track (https://deezer.com/track/<id here>)
    "musixmatch_id": 153545185, musixmatch id of track (https://musixmatch.com/track/<id here>)
    "soundcloud_id": false, false if not found (very loose)
    "isrc": "USCM51800004", ISRC of the track
    "duration": 198973, duration in milliseconds
    "bpm": 85, bpm of track, will be 0 if not found
    "gain": -1.4 the gain of the track (loudness)
    "popularity": 83, the popularity of the track on Spotify, in percentage
    "rank": 33061, Deezer track rank
    "preview": "https://cdns-preview-9.dzcdn.net/stream/c-9990cd5b96f85daf3f3dc57ed801a899-6.mp3", thirty-second preview of the track
    "lyrics": "Bla Bla Bla", lyrics of the song, will return false if lyrics aren't found
    "lyrics_copyright": "...", copyright of lyrics, this is a good idea to include
    "release_date": 1530230400, release date in unix time
    "problems": [ array of problems with the song. Possible errors: "explicit_lyrics", "explicit_cover"
      {
        "code": "explicit_lyrics",
        "description": "This track has explicit lyrics."
      },
      {
        "code": "explicit_cover",
        "description": "This track has an explicit cover."
      }
    ],
    "powered_by": { copyright notice, this has to be included if forked / cloned
      "website": "https://bunker.dance",
      "copyright": "Copyright 2021-Present Bunker | Source: https://github.com/bunkerradio/api"
    },
    "version": "1.0.0", api version
    "cache": 1635592402422 when this track was cached
  }
}

Clone this wiki locally