Skip to main content

Changelog 2024-02-01

· 2 min read
Christopher Darlington

Announcing a new public API query for playlist matching.

Playlist Matching Query

The new cyanite API playlist matching query can be used to get an array of matching playlists for your music. It will return an array of nodes containing playlist information for a reference track.

Example query

This example queries for matching playlist for the library track with the given id.

query PlaylistMatching($trackId: 123) {
playlistMatching(
reference: {library: {trackId: $trackId}}
) {
__typename
... on PlaylistMatchingError {
__typename
code
message
}
... on PlaylistMatchingConnection {
edges {
node {
id
name
description
url
}
cursor
}
}
}
}

Example Result

{
"data": {
"playlistMatching": {
"__typename": "PlaylistMatchingConnection",
"edges": [
{
"node": {
"id": "examplePlaylistId",
"name": "Example Playlist Name",
"description": "Example Playlist Description",
"url": "https://open.spotify.com/playlist/examplePlaylistUrl",
"__typename": "Playlist"
},
"__typename": "PlaylistMatchingEdge"
},
]
}
}
}

Example query with pagination

A cursor based pagination can be used to retrieve a specified amount of tracks and query subsequent pages. The $first variable may be used alone to retrieve a specific amount of playlists. $after specifies the last playlist id in the current page.

query PlaylistMatching($trackId: 123, $first: 10, $after: "examplePlaylistId1") {
playlistMatching(
reference: {library: {trackId: $trackId}}
first: $first
after: $after
) {
__typename
... on PlaylistMatchingError {
__typename
code
message
}
... on PlaylistMatchingConnection {
edges {
node {
id
name
description
url
}
cursor
}
}
}
}

Example Result

{
"data": {
"playlistMatching": {
"__typename": "PlaylistMatchingConnection",
"edges": [
{
"node": {
"id": "examplePlaylistId2",
"name": "Example Playlist Name",
"description": "Example Playlist Description",
"url": "https://open.spotify.com/playlist/examplePlaylistUrl",
"__typename": "Playlist"
},
"cursor": "examplePlaylistId2",
"__typename": "PlaylistMatchingEdge"
},
...
]
}
}
}

Example Error (track not found)

{
"data": {
"playlistMatching": {
"__typename": "PlaylistMatchingError",
"code": "matchingFailed",
"message": "Could not find library track."
}
}
}