search
Sonos uses the search
request to find content based on a search term within a search category. If you support search on your service, you must also support it on Sonos. See Add search for details.
Request parameters
Name | Type | Description |
---|---|---|
id | string(128) | The ID of the search category. |
term | string | The search term. |
index | int | The zero-based index at which to start retrieving search results. |
count | int | The number of search results requested. |
Response
The response is identical to the getMetadata message. See the samples below for details.
Sample presentation map configuration
<PresentationMap type="Search">
<Match>
<SearchCategories>
<Category mappedId="artist" id="artists"/>
<Category mappedId="album" id="albums"/>
<Category mappedId="track" id="tracks"/>
<Category mappedId="playlist" id="playlists"/>
<Category mappedId="user" id="people"/>
</SearchCategories>
</Match>
</PresentationMap>
Details
- You must implement search in two ways, one for Sonos apps for mobile devices and one for Sonos apps for desktop computers. Implement search for mobile devices by sending a list of searchable categories from the unified search configuration in the presentation map. Implement it for Windows and Mac OS by sending a list of categories in a response to a
getMetadata
request on the search container. See Add search for details. - The list of IDs, whether contained in the presentation map or in the response to a Sonos
getMetadata
request on the "search" ID, should be identical. - Regardless of where Sonos firmware retrieves the list of searchable categories, Sonos uses the ID for a given category as the category (ID) parameter to the search message. For example, your service may expose search categories like “artists”, “tracks”, or “albums” but this list can be expanded to enable other categories of searches.
Sample request from a search for artist "Foo Fighters"
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<search xmlns="http://www.sonos.com/Services/1.1">
<id>artist</id>
<term>Foo Fighters</term>
<index>0</index>
<count>100</count>
</search>
</soap:Body>
</soap:Envelope>
Sample response
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<searchResponse xmlns="http://www.sonos.com/Services/1.1">
<searchResult>
<index>0</index>
<count>3</count>
<total>3</total>
<mediaCollection>
<title></title>
<itemType>artist</itemType>
<id>artist:dir:10462312</id>
<authrequired>0</authrequired>
<genre>Alternative</genre>
</mediaCollection>
<mediaCollection>
<title></title>
<itemType>artist</itemType>
<id>artist:dir:12015032</id>
<authrequired>0</authrequired>
<genre>Unknown</genre>
</mediaCollection>
<mediaCollection>
<title></title>
<itemType>artist</itemType>
<id>artist:dir:12132174</id>
<authrequired>0</authrequired>
<genre>Unknown</genre>
</mediaCollection>
</searchResult>
</searchResponse>
</soap:Body>
</soap:Envelope>
Sample getmetadata "search" request
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getMetadata xmlns="http://www.sonos.com/Services/1.1">
<id>search</id>
<index>0</index>
<count>100</count>
</getMetadata>
</soap:Body>
</soap:Envelope>
Sample getMetadata "search" response
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getMetadataResponse xmlns="http://www.sonos.com/Services/1.1">
<getMetadataResult>
<index>0</index>
<count>3</count>
<total>3</total>
<mediaCollection>
<id>artist</id>
<title>Artist</title>
<itemType>search</itemType>
</mediaCollection>
<mediaCollection>
<id>album</id>
<title>Album</title>
<itemType>search</itemType>
</mediaCollection>
<mediaCollection>
<id>track</id>
<title>Track</title>
<itemType>search</itemType>
</mediaCollection>
<mediaCollection>
<id>user</id>
<title>User</title>
<itemType>search</itemType>
</mediaCollection>
</getMetadataResult>
</getMetadataResponse>
</soap:Body>
</soap:Envelope>
Updated 3 months ago