verida/data-connector-server

[New Connection] Spotify

Opened this issue · 5 comments

Key information:

  • Profile
  • Playlists
  • Listening history
  • Friends / connections

@chime3 What other data is available?

Overview

Spotify supports SSO, including OAuth 2.0 authentication.
It exposes a wide range of generic data APIs, but we will focus on user-specific APIs.
Ref: Spotify Web API Documentation

Available Data Models

Track represents Spotify items like music, episode, podcast, audiobook etc

  1. Profile
  2. User's top Artists and Items
    It is something like user's favorite.
    Example:
{
  "items": [
    {
      "name": "Track Name",
      "id": "track_id",
      "album": {
        "name": "Album Name",
        "images": [{ "url": "album-image-url.com" }]
      },
      "artists": [
        {
          "name": "Artist Name",
          "id": "artist_id"
        }
      ],
      "popularity": 80,
      "duration_ms": 210000,
      "explicit": false
    }
  ],
  "type": "track"
}
  1. Playlists
    We can get playlists info, but I am not sure if it is worth to sync for Verida
    Example:
{
  "items": [
    {
      "id": "playlist_id",
      "name": "Playlist Name",
      "description": "A cool playlist",
      "owner": {
        "display_name": "Owner Name",
        "id": "owner_id"
      },
      "tracks": {
        "total": 25
      },
      "images": [
        {
          "url": "playlist-image-url.com"
        }
      ],
      "public": true,
      "snapshot_id": "snapshot_id_string"
    }
  ]
}
  1. Recently played Items
    It represents listening history, but has limitations: 50 items and past 24hours
    Example:
{
  "items": [
    {
      "track": {
        "name": "Recently Played Track Name",
        "id": "track_id",
        "artists": [
          {
            "name": "Artist Name",
            "id": "artist_id"
          }
        ],
        "album": {
          "name": "Album Name",
          "images": [{ "url": "album-image-url.com" }]
        }
      },
      "played_at": "2023-05-01T10:30:00.000Z"
    }
  ]
}
  1. Followed artists
    Artist's name and followers number, avatar, Spotify profile link are available.
{
  "artists": {
    "items": [
      {
        "external_urls": {
          "spotify": "https://open.spotify.com/artist/{artist_id}"
        },
        "followers": {
          "href": null,
          "total": 1000000
        },
        "genres": [
          "pop",
          "rock"
        ],
        "href": "https://api.spotify.com/v1/artists/{artist_id}",
        "id": "{artist_id}",
        "images": [
          {
            "height": 640,
            "url": "https://i.scdn.co/image/{image_id}",
            "width": 640
          }
        ],
        "name": "Artist Name",
        "popularity": 80,
        "type": "artist",
        "uri": "spotify:artist:{artist_id}"
      }
    ]
  }
}

We can use the original following schema.

Issues

  • Are any additional data schemas required for Verida?
  • If we want to track listening (or watch history for YouTube), is there a specific schema for that? @tahpot

We should extract the following information and place into our schemas

  • profile
  • playlist
  • history (new schema) -- Recently played items
  • following -- Followed artists
  • favorite -- User's top Artists and Items

Can you please do the following as next steps:

  1. Create a draft schema for history in schemas-common. This should be designed in such a way it can also be used for web browsing history
  2. Create a draft schema for playlist in schemas-common. This should be designed in such a way it can also be used for other playlists in the future (ie: youtube)
  3. In this issue, map our schema fields to the spotify fields for profile, playlist, following, favorite.
chime3 commented

https://github.com/spotify/spotify-web-api-ts-sdk

Reverted to use original spotify-api-sdk package as I noticed that the above SDK has not been updated in over a year and doesn't support the features we are looking to implement now.

Ref: https://www.npmjs.com/package/spotify-api-sdk/v/1.0.0, https://spotify-poc.pages.dev/