Browse API questions

Hi @danny,

I have two questions about the Browse API.

In the options object a ‘zone_or_output_id’ can be specified, but I only get this working if I specify a zone_id. If I specify an output_id I get a ‘Zone not found’ error:

    -> REQUEST 8 com.roonlabs.browse:1/browse {"hierarchy":"browse","zone_or_output_id":"1701adc01798f27f1d5ede273c52a64db19f","item_key":"17:1"}
    <- COMPLETE 8 Success {"action":"message","is_error":true,"message":"Zone not found"}

How do I have to specify an output_id?

My second question is about the ‘item_key’. The value of this key changes at every refresh. Is this the intended behavior? It makes it more difficult to save a key for later use.

Hi Jan,

I was able to call the browse API using output_id as found in the zone list

{
  "zones": {
    "1601bb8da41024fe80da0656c27e7c387091": {
      "zone_id": "1601bb8da41024fe80da0656c27e7c387091",
      "display_name": "AN Dac 2.1x Sig",
      "outputs": [
        {
          "output_id": "1701bb8da41024fe80da0656c27e7c387091",
          "zone_id": "1601bb8da41024fe80da0656c27e7c387091",
          "can_group_with_output_ids": [
            "1701bb8da41024fe80da0656c27e7c387091",
            "17012b227d3698b7fa1caa37237f27fc6f18"
          ],
          "display_name": "AN Dac 2.1x Sig"
        }
      ],
    }
  }
}

Then calling the browse with the output_id gives me the following:

returns the following:

{ 
  level: 1,
  title: 'Library',
  subtitle: null,
  image_key: null,
  count: 5,
  display_offset: null 
}

Then calling the load api gives me the following:

{
  "list": [
    {
      "title": "Search",
      "subtitle": null,
      "image_key": null,
      "item_key": "115:0",
      "input_prompt": {
        "prompt": "Search",
        "action": "Go"
      },
      "url_link": "http://localhost:3001/roonAPI/listByItemKey?zoneId=1701bb8da41024fe80da0656c27e7c387091&item_key=115:0"
    },
    {
      "title": "Artists",
      "subtitle": null,
      "image_key": null,
      "item_key": "115:1",
      "url_link": "http://localhost:3001/roonAPI/listByItemKey?zoneId=1701bb8da41024fe80da0656c27e7c387091&item_key=115:1"
    },
    {
      "title": "Albums",
      "subtitle": null,
      "image_key": null,
      "item_key": "115:2",
      "url_link": "http://localhost:3001/roonAPI/listByItemKey?zoneId=1701bb8da41024fe80da0656c27e7c387091&item_key=115:2"
    },
    {
      "title": "Tracks",
      "subtitle": null,
      "image_key": null,
      "item_key": "115:3",
      "url_link": "http://localhost:3001/roonAPI/listByItemKey?zoneId=1701bb8da41024fe80da0656c27e7c387091&item_key=115:3"
    },
    {
      "title": "Composers",
      "subtitle": null,
      "image_key": null,
      "item_key": "115:4",
      "url_link": "http://localhost:3001/roonAPI/listByItemKey?zoneId=1701bb8da41024fe80da0656c27e7c387091&item_key=115:4"
    }
  ]
}

I also have a question on the changing the item_keys for every refresh, I created an html api for these APIs and if there are more than one client calling these apis, then it will not work as the item_keys will have been updated.

here’s the result of both browse and load calls after I refresh from the same link

{
  "list": [
    {
      "title": "Search",
      "subtitle": null,
      "image_key": null,
      "item_key": "115:0",
      "input_prompt": {
        "prompt": "Search",
        "action": "Go"
      },
      "url_link": "http://localhost:3001/roonAPI/listByItemKey?zoneId=1701bb8da41024fe80da0656c27e7c387091&item_key=115:0"
    },

Then after i hit refresh

{
  "list": [
    {
      "title": "Search",
      "subtitle": null,
      "image_key": null,
      "item_key": "116:0",
      "input_prompt": {
        "prompt": "Search",
        "action": "Go"
      },
      "url_link": "http://localhost:3001/roonAPI/listByItemKey?zoneId=1701bb8da41024fe80da0656c27e7c387091&item_key=116:0"
    },

The item key changes from 115:0 to 116:0.

Would it it be possible to have the same item_keys after refresh?

I see this item_key changes even after changing the zone_id or output_id from other zone

{
  "list": [
    {
      "title": "Search",
      "subtitle": null,
      "image_key": null,
      "item_key": "118:0",
      "input_prompt": {
        "prompt": "Search",
        "action": "Go"
      },
      "url_link": "http://localhost:3001/roonAPI/listByItemKey?zoneId=1601d53a8ad303a19906c7e10e0f6a0d5174&item_key=118:0"
    },

– bastian

Hi @St0g1e,

How did you specify the output_id in your request? Something like?

{ zone_or_output_id: zone.outputs[0].output_id }

Hi @Jan_Koudijs,

I created the opts variable first before calling the browse API.
I have tested it with both zone_id and output_id and they work.

function refresh_browse(zone_id, opts, page, listPerPage, cb) {
    var items = [];
    opts = Object.assign({
        hierarchy:          "browse",
        zone_or_output_id:  zone_id,
    }, opts);


    core.services.RoonApiBrowse.browse(opts, (err, r) => {
        if (err) { console.log(err, r); return; }

        if (r.action == 'list') {
            core.services.RoonApiBrowse.load({
                hierarchy:          "browse",
                offset:             page,
                set_display_offset: listPerPage,
            }, (err, r) => {
                items = r.items;

                cb(r.items);
            });
        }
    });
}

And this is how i call refresh_browse ( req.query[‘zoneId’] is sent via url and can be zone_id or output_id.

   refresh_browse( req.query['zoneId'], { pop_all: true }, 0, 0, function(myList) {

   res.send({
     "list": myList 
    })
  });

However i’m still figuring out the offset and set_display_offset for the load api for the pagination.

My music library contains albums with genre Klezmer.
It is a subgenre (International => Jewish Music => Klezmer).
In the Roon App I can browse from genre International down to my Klezmer albums.
But using the browser API genre International does not deliver the subgenres.

Can you give me a more specific description of what you did, what happened, and what you expected?

I just tried this with a API client and was able to navigate (International => Jewish Music => Klezmer) without any problems.

To be more precise : my library contains about 1000 Albums. Browsing works fine with the exception of Klezmer genre, I guess because it is a subgenre. My Library does not contain any album with genre International or Jewish Music but a lot of Klezmer. When I browse for example the main genre Classical I get :

  • Play Genre
  • Artists
  • Albums

When I browse International I expected to get :

  • Play Genre
  • Jewish Music

But I only get :

  • Play Genre

So I have no chance to browse down to Klezmer.

Here the options of the browse call :

hierarchy “browse”
input null
itemKey “351:8”
popAll false
refreshList false
zoneOrOutputId “16011eb7d1ee7fdc839a5b82c605bfbbf9c4”

The result of browse is :

action “list”
count 1
displayOffset null
imageKey null
level 2
subTitle “0 Artists, 0 Albums”
title “International”

Then I call load with the result :

“action_list”
null
“365:0”
null
“Play Genre”

Gentlemen, for me the problem is solved. I was able to make Klezmer a main genre.