Skip to content
DocumentationAPI Reference

Get Recently Played Tracks

me.player.list_recently_played(**kwargs) -> CursorURLPage<PlayerListRecentlyPlayedResponse { context, played_at, published, track } >
GET/me/player/recently-played

Get tracks from the current user's recently played tracks. Note: Currently doesn't support podcast episodes.

ParametersExpand Collapse
after: Integer

A Unix timestamp in milliseconds. Returns all items after (but not including) this cursor position. If after is specified, before must not be specified.

before: Integer

A Unix timestamp in milliseconds. Returns all items before (but not including) this cursor position. If before is specified, after must not be specified.

limit: Integer

The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.

minimum1
maximum50
ReturnsExpand Collapse
class PlayerListRecentlyPlayedResponse { context, played_at, published, track }
context: ContextObject { external_urls, href, published, 2 more }

The context the track was played from.

external_urls: ExternalURLObject { published, spotify }

External URLs for this context.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

spotify: String

The Spotify URL for the object.

href: String

A link to the Web API endpoint providing full details of the track.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

type: String

The object type, e.g. "artist", "playlist", "album", "show".

uri: String

The Spotify URI for the context.

played_at: Time

The date and time the track was played.

formatdate-time
published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

track: TrackObject { id, album, artists, 18 more }

The track the user listened to.

id: String

The Spotify ID for the track.

album: { id, album_type, artists, 12 more}

The album on which the track appears. The album object includes a link in href to full information about the album.

id: String

The Spotify ID for the album.

album_type: :album | :single | :compilation

The type of the album.

Accepts one of the following:
:album
:single
:compilation
artists: Array[SimplifiedArtistObject { id, external_urls, href, 4 more } ]

The artists of the album. Each artist object includes a link in href to more detailed information about the artist.

id: String

The Spotify ID for the artist.

external_urls: ExternalURLObject { published, spotify }

Known external URLs for this artist.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

spotify: String

The Spotify URL for the object.

href: String

A link to the Web API endpoint providing full details of the artist.

name: String

The name of the artist.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

type: :artist

The object type.

uri: String

The Spotify URI for the artist.

available_markets: Array[String]

The markets in which the album is available: ISO 3166-1 alpha-2 country codes. NOTE: an album is considered available in a market when at least 1 of its tracks is available in that market.

external_urls: ExternalURLObject { published, spotify }

Known external URLs for this album.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

spotify: String

The Spotify URL for the object.

href: String

A link to the Web API endpoint providing full details of the album.

images: Array[ImageObject { height, url, width, published } ]

The cover art for the album in various sizes, widest first.

height: Integer

The image height in pixels.

url: String

The source URL of the image.

width: Integer

The image width in pixels.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

name: String

The name of the album. In case of an album takedown, the value may be an empty string.

release_date: String

The date the album was first released.

release_date_precision: :year | :month | :day

The precision with which release_date value is known.

Accepts one of the following:
:year
:month
:day
total_tracks: Integer

The number of tracks in the album.

type: :album

The object type.

uri: String

The Spotify URI for the album.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

restrictions: AlbumRestrictionObject { published, reason }

Included in the response when a content restriction is applied.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

reason: :market | :product | :explicit

The reason for the restriction. Albums may be restricted if the content is not available in a given market, to the user's subscription type, or when the user's account is set to not play explicit content. Additional reasons may be added in the future.

Accepts one of the following:
:market
:product
:explicit
artists: Array[SimplifiedArtistObject { id, external_urls, href, 4 more } ]

The artists who performed the track. Each artist object includes a link in href to more detailed information about the artist.

id: String

The Spotify ID for the artist.

external_urls: ExternalURLObject { published, spotify }

Known external URLs for this artist.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

spotify: String

The Spotify URL for the object.

href: String

A link to the Web API endpoint providing full details of the artist.

name: String

The name of the artist.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

type: :artist

The object type.

uri: String

The Spotify URI for the artist.

available_markets: Array[String]

A list of the countries in which the track can be played, identified by their ISO 3166-1 alpha-2 code.

disc_number: Integer

The disc number (usually 1 unless the album consists of more than one disc).

duration_ms: Integer

The track length in milliseconds.

explicit: bool

Whether or not the track has explicit lyrics ( true = yes it does; false = no it does not OR unknown).

external_ids: ExternalIDObject { ean, isrc, published, upc }

Known external IDs for the track.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

external_urls: ExternalURLObject { published, spotify }

Known external URLs for this track.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

spotify: String

The Spotify URL for the object.

href: String

A link to the Web API endpoint providing full details of the track.

is_local: bool

Whether or not the track is from a local file.

is_playable: bool

Part of the response when Track Relinking is applied. If true, the track is playable in the given market. Otherwise false.

linked_from: LinkedTrackObject { id, external_urls, href, 3 more }

Part of the response when Track Relinking is applied, and the requested track has been replaced with different track. The track in the linked_from object contains information about the originally requested track.

id: String

The Spotify ID for the track.

external_urls: ExternalURLObject { published, spotify }

Known external URLs for this track.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

spotify: String

The Spotify URL for the object.

href: String

A link to the Web API endpoint providing full details of the track.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

type: String

The object type: "track".

uri: String

The Spotify URI for the track.

name: String

The name of the track.

popularity: Integer

The popularity of the track. The value will be between 0 and 100, with 100 being the most popular.
The popularity of a track is a value between 0 and 100, with 100 being the most popular. The popularity is calculated by algorithm and is based, in the most part, on the total number of plays the track has had and how recent those plays are.
Generally speaking, songs that are being played a lot now will have a higher popularity than songs that were played a lot in the past. Duplicate tracks (e.g. the same track from a single and an album) are rated independently. Artist and album popularity is derived mathematically from track popularity. Note: the popularity value may lag actual popularity by a few days: the value is not updated in real time.

Deprecatedpreview_url: String

A link to a 30 second preview (MP3 format) of the track. Can be null

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

restrictions: TrackRestrictionObject { published, reason }

Included in the response when a content restriction is applied.

published: bool

The playlist's public/private status (if it should be added to the user's profile or not): true the playlist will be public, false the playlist will be private, null the playlist status is not relevant. For more about public/private status, see Working with Playlists

reason: String

The reason for the restriction. Supported values:

  • market - The content item is not available in the given market.
  • product - The content item is not available for the user's subscription type.
  • explicit - The content item is explicit and the user's account is set to not play explicit content.

Additional reasons may be added in the future. Note: If you use this field, make sure that your application safely handles unknown values.

track_number: Integer

The number of the track. If an album has several discs, the track number is the number on the specified disc.

type: :track

The object type: "track".

uri: String

The Spotify URI for the track.

Get Recently Played Tracks

require "spotted"

spotted = Spotted::Client.new(access_token: "My Access Token")

page = spotted.me.player.list_recently_played

puts(page)
{
  "cursors": {
    "after": "after",
    "before": "before",
    "published": true
  },
  "href": "href",
  "items": [
    {
      "context": {
        "external_urls": {
          "published": true,
          "spotify": "spotify"
        },
        "href": "href",
        "published": true,
        "type": "type",
        "uri": "uri"
      },
      "played_at": "2019-12-27T18:11:19.117Z",
      "published": true,
      "track": {
        "id": "id",
        "album": {
          "id": "2up3OPMp9Tb4dAKM2erWXQ",
          "album_type": "compilation",
          "artists": [
            {
              "id": "id",
              "external_urls": {
                "published": true,
                "spotify": "spotify"
              },
              "href": "href",
              "name": "name",
              "published": true,
              "type": "artist",
              "uri": "uri"
            }
          ],
          "available_markets": [
            "CA",
            "BR",
            "IT"
          ],
          "external_urls": {
            "published": true,
            "spotify": "spotify"
          },
          "href": "href",
          "images": [
            {
              "height": 300,
              "url": "https://i.scdn.co/image/ab67616d00001e02ff9ca10b55ce82ae553c8228\n",
              "width": 300,
              "published": true
            }
          ],
          "name": "name",
          "release_date": "1981-12",
          "release_date_precision": "year",
          "total_tracks": 9,
          "type": "album",
          "uri": "spotify:album:2up3OPMp9Tb4dAKM2erWXQ",
          "published": true,
          "restrictions": {
            "published": true,
            "reason": "market"
          }
        },
        "artists": [
          {
            "id": "id",
            "external_urls": {
              "published": true,
              "spotify": "spotify"
            },
            "href": "href",
            "name": "name",
            "published": true,
            "type": "artist",
            "uri": "uri"
          }
        ],
        "available_markets": [
          "string"
        ],
        "disc_number": 0,
        "duration_ms": 0,
        "explicit": true,
        "external_ids": {
          "ean": "ean",
          "isrc": "isrc",
          "published": true,
          "upc": "upc"
        },
        "external_urls": {
          "published": true,
          "spotify": "spotify"
        },
        "href": "href",
        "is_local": true,
        "is_playable": true,
        "linked_from": {
          "id": "id",
          "external_urls": {
            "published": true,
            "spotify": "spotify"
          },
          "href": "href",
          "published": true,
          "type": "type",
          "uri": "uri"
        },
        "name": "name",
        "popularity": 0,
        "preview_url": "preview_url",
        "published": true,
        "restrictions": {
          "published": true,
          "reason": "reason"
        },
        "track_number": 0,
        "type": "track",
        "uri": "uri"
      }
    }
  ],
  "limit": 0,
  "next": "next",
  "published": true,
  "total": 0
}
Returns Examples
{
  "cursors": {
    "after": "after",
    "before": "before",
    "published": true
  },
  "href": "href",
  "items": [
    {
      "context": {
        "external_urls": {
          "published": true,
          "spotify": "spotify"
        },
        "href": "href",
        "published": true,
        "type": "type",
        "uri": "uri"
      },
      "played_at": "2019-12-27T18:11:19.117Z",
      "published": true,
      "track": {
        "id": "id",
        "album": {
          "id": "2up3OPMp9Tb4dAKM2erWXQ",
          "album_type": "compilation",
          "artists": [
            {
              "id": "id",
              "external_urls": {
                "published": true,
                "spotify": "spotify"
              },
              "href": "href",
              "name": "name",
              "published": true,
              "type": "artist",
              "uri": "uri"
            }
          ],
          "available_markets": [
            "CA",
            "BR",
            "IT"
          ],
          "external_urls": {
            "published": true,
            "spotify": "spotify"
          },
          "href": "href",
          "images": [
            {
              "height": 300,
              "url": "https://i.scdn.co/image/ab67616d00001e02ff9ca10b55ce82ae553c8228\n",
              "width": 300,
              "published": true
            }
          ],
          "name": "name",
          "release_date": "1981-12",
          "release_date_precision": "year",
          "total_tracks": 9,
          "type": "album",
          "uri": "spotify:album:2up3OPMp9Tb4dAKM2erWXQ",
          "published": true,
          "restrictions": {
            "published": true,
            "reason": "market"
          }
        },
        "artists": [
          {
            "id": "id",
            "external_urls": {
              "published": true,
              "spotify": "spotify"
            },
            "href": "href",
            "name": "name",
            "published": true,
            "type": "artist",
            "uri": "uri"
          }
        ],
        "available_markets": [
          "string"
        ],
        "disc_number": 0,
        "duration_ms": 0,
        "explicit": true,
        "external_ids": {
          "ean": "ean",
          "isrc": "isrc",
          "published": true,
          "upc": "upc"
        },
        "external_urls": {
          "published": true,
          "spotify": "spotify"
        },
        "href": "href",
        "is_local": true,
        "is_playable": true,
        "linked_from": {
          "id": "id",
          "external_urls": {
            "published": true,
            "spotify": "spotify"
          },
          "href": "href",
          "published": true,
          "type": "type",
          "uri": "uri"
        },
        "name": "name",
        "popularity": 0,
        "preview_url": "preview_url",
        "published": true,
        "restrictions": {
          "published": true,
          "reason": "reason"
        },
        "track_number": 0,
        "type": "track",
        "uri": "uri"
      }
    }
  ],
  "limit": 0,
  "next": "next",
  "published": true,
  "total": 0
}