Rapidly Develop Spotify-Driven Apps with Active Query Builder

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Leverage the Active Query Builder SQL interface and .NET data access to create data-driven WinForms and ASP.NET apps backed by Spotify.

Write standard .NET to expose Spotify data through an SQL interface: Active Query Builder helps developers write SQL interfaces; the CData ODBC Driver for Spotify enables standards-based access to Spotify. This integration uses the Microsoft ADO.NET Provider for ODBC as a bridge between the ODBC Driver and the Active Query Builder objects to build a visual SQL composer.

Connect to Spotify as an ODBC Data Source

If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs.

Using OAuth Authentication

Spotify uses OAuth 2.0 for authentication. You will need to create an application in the Spotify Developer Dashboard to obtain your client credentials.

Setting Up Your Spotify Application

  1. Visit the Spotify Developer Dashboard.
  2. Log in with your Spotify account and click Create app.
  3. Provide an app name, description, and set a Redirect URI (e.g.,
    http://localhost:33333
    for desktop applications).
  4. Copy your Client ID and Client Secret from the app settings.

Connection Properties

After setting the following connection properties, you are ready to connect:

  • AuthScheme: Set this to OAuth.
  • InitiateOAuth: Set this to GETANDREFRESH. You can use InitiateOAuth to manage the process to obtain the OAuthAccessToken.
  • OAuthClientId: Set this to your Spotify application's Client ID.
  • OAuthClientSecret: Set this to your Spotify application's Client Secret.
  • Scope: Set this to the required OAuth scopes (space-separated). The default includes all read scopes needed for the tables in this profile.
  • CallbackURL: Set this to the Redirect URI configured in your Spotify application (e.g., http://localhost:33333).

Example Connection String

Profile=C:\profiles\Spotify.apip;AuthScheme=OAuth;InitiateOAuth=GETANDREFRESH;OAuthClientId=your_client_id;OAuthClientSecret=your_client_secret;CallbackURL=http://localhost:33333;

Available OAuth Scopes

  • user-read-private: Read access to user's subscription details and explicit content settings.
  • user-read-email: Read access to user's email address.
  • user-library-read: Read access to a user's saved tracks, albums, episodes, shows, and audiobooks.
  • playlist-read-private: Read access to user's private playlists.
  • playlist-read-collaborative: Read access to collaborative playlists the user follows.
  • user-follow-read: Read access to the list of artists the current user follows.
  • user-read-playback-state: Read access to a user's player state (device, current track, progress).
  • user-read-currently-playing: Read access to a user's currently playing content.
  • user-read-playback-history: Read access to a user's recently played tracks.
  • user-top-read: Read access to a user's top artists and tracks.

Use SQL to Interact with Spotify

Follow the steps below to create a WinForms visual query builder.

  1. Open Active Query Builder for .NET WinForms.
  2. In the new Windows Forms project go to the "File" menu and click "Connect..."
  3. Under Database Connections, click "Add..."
  4. Set your desired Connection Name (e.g. CData Spotify), set Connection Type to "ODBC" and locate your previously configured DSN in the "User/System" DSN dropdown.
  5. Click "OK" to save the new connection.
  6. Back in the Database Connection wizard, select the newly created connection and click "OK."
  7. Click "File" > "New Query" to create a QueryBuilder

You can now build queries visually: Double-click a table in the Columns Pane Area and an entity/relationship diagram is displayed in the Query Building Area. Columns that you select in the diagram are added to the query.

Ready to get started?

Connect to live data from Spotify with the API Driver

Connect to Spotify