This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with Search in Spotify



Overview

The following operations allow you to work with Search in Spotify. Click an operation name to see details on how to use it.

For a sample proxy service that illustrates how to work with Search, see Sample configuration.

OperationDescription
searchForAnItemSearch any resource.

Operation details

This section provides the details on each operation related to all resources in Spotify.

Get information of a single Track

To search any resource in Spotify, use spotify.searchForAnItem operation.

searchForAnItem
<spotify.searchForAnItem>
    <searchQuery>41MnTivkwTO3UUJ8DrqEJJ</searchQuery>
    <typeOfItem>album</typeOfItem>
    <spotifyoffset>30</spotifyoffset>
    <spotifylimit>2</spotifylimit>
</spotify.searchForAnItem>
Properties
  • searchQuery : The search query's keywords (and optional field filters). The search is not case-sensitive.

  •  typeOfItem    : A comma-separated list of item types to search across. Valid types are: album, artist, and track.

  •  spotifylimit     : The maximum number of objects to return. Default: 20. Minimum: 1. Maximum: 50.  
  • spotifyoffset   : The index of the first object to return. Default: 0 (i.e., the first object). Use with limit to get the next set of objects.
Sample request

Following is a sample REST/JSON request that can be handled by the searchForAnItem operation.

Sample Request for searchForAnItem
{
"searchQuery":"41MnTivkwTO3UUJ8DrqEJJ",
"typeOfItem":"album",
"spotifylimit":"30",
"spotifyoffset":"2"
}

Sample configuration

Following is a sample proxy service that illustrates how to connect to Spotify with the init operation to use the searchForAnItem operation. The sample request for this proxy can be found in searchForAnItem sample request.

Sample Proxy
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="spotify_searchForAnItem"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <inSequence>
            <spotify.init/>
            <property name="searchQuery" expression="json-eval($.searchQuery)"/>
            <property name="typeOfItem" expression="json-eval($.typeOfItem)"/>
            <property name="spotifyoffset" expression="json-eval($.spotifyoffset)"/>
            <property name="spotifylimit" expression="json-eval($.spotifylimit)"/>
            <spotify.searchForAnItem>
                <searchQuery>{$ctx:searchQuery}</searchQuery>
                <typeOfItem>{$ctx:typeOfItem}</typeOfItem>
                <spotifyoffset>{$ctx:spotifyoffset}</spotifyoffset>
                <spotifylimit>{$ctx:spotifylimit}</spotifylimit>
            </spotify.searchForAnItem>
            <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <description/>
</proxy>