Link Spotify with FileMaker Pro

Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Use the MySQL Remoting feature of the JDBC driver to integrate Spotify data in Filemaker Pro for Mac or Windows.

This article shows how to use the CData JDBC Driver for Spotify to integrate with the External SQL Sources (ESS) feature in FileMaker Pro, which allows you to link records in FileMaker Pro with related records in your other operational data stores.

You will use the MySQL Remoting feature to access Spotify as a remote MySQL database. The CData JDBC Driver for Spotify implements both the JDBC and MySQL standards to integrate with applications like FileMaker Pro that support connections to traditional databases like MySQL but not generic JDBC connections.

Selecting a FileMaker Pro Integration

Use the JDBC the JDBC driver to create an external SQL source (ESS). The remote data can be modified in FileMaker Pro and tables can be used in the relationships graph like standard FileMaker Pro tables.

Outlining the ESS Setup

The JDBC driver is part of a data access chain. Compared to a native ODBC integration, FileMaker Pro integrations that use MySQL remoting have several additional components. This article shows how to link each of the following components with FileMaker Pro:

  1. The CData JDBC driver.
  2. The CData MySQL Remoting daemon (included with the driver).
  3. An ODBC driver for MySQL.

    On Windows, FileMaker Pro requires the official MySQL driver, the MySQL Connector\ODBC (currently, the best option is Connector\ODBC 8.0.11).

    On macOS, FileMaker Pro requires the Actual Technologies Open Databases ODBC driver.

  4. An ODBC driver manager.

    On Windows, the driver manager is built in. On macOS, you will need to install a driver manager before installing the ODBC driver; install the iODBC driver manager.

Start the Remoting Daemon

Follow the steps below to enable the MySQL Remoting feature:

  1. Open Terminal and change to the lib subfolder in the installation folder.

    $ cd "/Applications/CData/CData JDBC Driver for Spotify/lib"
    
  2. Edit the configuration file (cdata.jdbc.api.remoting.ini by default):
    • Update the [databases] section with the JDBC Connection URL for Spotify:
      	api = "Profile=C:\profiles\Spotify.apip;AuthScheme=OAuth;InitiateOAuth=GETANDREFRESH;OAuthClientId=your_client_id;OAuthClientSecret=your_client_secret;CallbackURL=http://localhost:33333;"
      	

      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.

      See the help documentation for more information about the available connection properties and other configuration options for remoting.

  3. Start the MySQL daemon by specifying the configuration file or settings on the command line. The example below uses the included sample configuration file.

    $ java -jar cdata.jdbc.api.jar -f "cdata.jdbc.api.remoting.ini"
    

Create the DSN

After connecting successfully to Spotify and starting the MySQL daemon, create a MySQL ODBC data source. When working with ODBC data sources, you specify connection properties in a DSN (data source name).

If you have not already obtained an ODBC driver and driver manager, refer to "Outlining the ESS Setup" to determine the components supported for your platform.

macOS

Follow the steps below to use the iODBC graphical administrator tool:

  1. Open iODBC by searching in the launchpad.
  2. On the System DSN tab, click Add and select Actual Open Source Databases.
  3. Provide the following information to complete the wizard:
    • Name: Enter the DSN.
    • Server: Enter 127.0.0.1 or the address of the machine where the MySQL daemon is running.
    • Port: Enter the port that the daemon is listening on. For example, 3306.
    • Database: Enter the name of a database specified in the config file for the daemon. For example, API.
    • In the Metadata tab, check the boxes for:
      • "Ignore schema in column specifications"
      • "Don't use INFORMATION_SCHEMA for metadata"
  4. Click Test Connection and enter your credentials in the dialog.

Windows

You can use the built-in Microsoft ODBC Data Source Administrator to create the ODBC DSN.

  1. From the Control Panel, select Set Up Data Sources (ODBC). The ODBC Data Source Administrator is displayed.
  2. On the System DSN tab, click Add and select the MySQL ODBC driver.
  3. Provide the following information to complete the wizard:
    • Name: Enter the DSN.
    • Server: Enter 127.0.0.1 or the address of the machine where the MySQL daemon is running.
    • Port: Enter the port that the daemon is listening on. For example, 3306.
    • Database: Enter the name of a database specified in the config file for the daemon. For example, API.
    • In the Metadata tab, check the boxes for:
      • "Ignore schema in column specifications"
      • "Don't use INFORMATION_SCHEMA for metadata"
  4. Click Test Connection and enter your credentials in the dialog.

Create Spotify Shadow Tables

Shadow tables exist in an external SQL source but can be used in much the same way as other tables in your FileMaker database; you can add them in the relationships graph, browse data, and create layouts on them.

  1. Click File -> Manage -> Database.
  2. On the Relationships tab of the resulting dialog, click the Add a Table button in the Table/Relationships section.
  3. In the Data Source menu, select Add ODBC Data Source and then select the DSN you created in the previous section.

After specifying the username and password for the DSN, you can add Spotify tables to the relationships graph. You can now scroll through, sort, and summarize Spotify data by clicking View -> Browse Mode, just as you would a remote MySQL database.

Ready to get started?

Connect to live data from Spotify with the API Driver

Connect to Spotify