How to: Query different Entity
types to explore their properties and behaviour
Most of these types will be seen when you run a search or view your collection for example, unless specified otherwise. An example of a search for Album
:
query {
search(query: "1989", types: [AL]) {
items {
... on Album {
id
name
trackCount
}
}
}
}
-
Album
query { entity(id: "AL:4346886") { __typename id ... on Album { name trackCount artist { name } } } }
{ "data": { "entity": { "__typename": "Album", "id": "AL:4346886", "name": "Every Bad", "trackCount": 11, "artist": { "name": "Porridge Radio" } } } }
-
Artist
query { entity(id: "AR:188587") { __typename id ... on Artist { name similarArtists { name } } } }
{ "data": { "entity": { "__typename": "Artist", "id": "AR:188587", "name": "Taylor Swift", "similarArtists": [ { "name": "Carrie Underwood" }, { "name": "Colbie Caillat" }, { "name": "Ed Sheeran" }, { "name": "Rascal Flatts" }, { "name": "Rachel Platten" }, { "name": "Lady Antebellum" } ] } } }
-
Track
query { entity(id: "TR:21092020") { __typename id ... on Track { name duration artist { name } album { name } } } }
{ "data": { "entity": { "__typename": "Track", "id": "TR:21092020", "name": "You Need To Calm Down", "duration": 171, "artist": { "name": "Taylor Swift" }, "album": { "name": "Lover" } } } }
-
StationFactory
query { entity(id: "SF:16722:777") { __typename id ... on StationFactory { name art { url } } } }
{ "data": { "entity": { "__typename": "StationFactory", "id": "SF:16722:777", "name": "The Cranberries", "art": { "url": "http://content-images.p-cdn.com/images/b4/02/bc/b8/a9724f5f993ade89e6105a5c/_500W_500H.jpg" } } } }
-
Playlist
query { entity(id: "PL:844424989666179:1756780791") { __typename id ... on Playlist { name totalTracks description } } }
{ "data": { "entity": { "__typename": "Playlist", "id": "PL:844424989666179:1756780791", "name": "Pandora Stories: Adding It Up With Sum 41", "totalTracks": 18, "description": "Canadian rockers Sum 41 are pros at penning singalong-worthy rock hits, from their breakout single “Fat Lip,” to their recently released banger “Out for Blood,” the first single off their new album ‘Order in Decline.’ What’s their secret? Here, Deryck Whibley tells us the stories behind some of their biggest songs, from how “In Too Deep” almost went to another artist to the year-and-a-half long writing process for “Fat Lip.”" } } }
-
Podcast
query { entity(id: "PC:28832") { __typename id ... on Podcast { name publisherName totalEpisodeCount summary } } }
{ "data": { "entity": { "__typename": "Podcast", "id": "PC:28832", "name": "Podcast Brunch Club", "publisherName": "Podcast Brunch Club", "totalEpisodeCount": 76, "summary": "Podcast Brunch Club: like book club, but for podcasts." } } }
-
PodcastEpisode
query { entity(id: "PE:2211581") { __typename id ... on PodcastEpisode { name summary duration podcast { name } } } }
{ "data": { "entity": { "__typename": "PodcastEpisode", "id": "PE:2211581", "name": "Attachment Theory with Alie Ward (Ologies Podcast)", "summary": "Stevie Nelson and Dave Horwitz chat with Alie Ward (Ologies podcast host/CBS Science correspondent) about her hate for cake & donuts, her biggest heartbreak and attachment theory.", "duration": 3200, "podcast": { "name": "I Burn Everything: Food & Relationships" } } } }
-
Profile
You can retrieve your own listener account ID using this query:
query { profile { id } }
{ "data": { "profile": { "id": "LI:1248449687" } } }
You can now use this ID to query your profile:
query { entity(id: "LI:1248449687") { __typename id ... on Profile { displayName } } }
{ "data": { "entity": { "__typename": "Profile", "id": "LI:1248449687", "displayName": "Edvinas" } } }
-
Station
Station IDs are unique to each user. For this reason, you need to query your collection to get a station ID that you own.
query { collection(types: [ST], pagination: {limit: 3}) { items { id ... on Station { name } } } }
{ "data": { "collection": { "items": [ { "id": "ST:0:4218581286709220503", "name": "90s Alternative Radio" }, { "id": "ST:0:4264122044719420567", "name": "90s Radio" }, { "id": "ST:0:4247710575249446039", "name": "90s Rock Radio" } ] } } }
You can now use one of these IDs to query the entity:
{ entity(id: "ST:0:4264122044719420567") { __typename id ... on Station { name art { url } } } }
{ "data": { "entity": { "__typename": "Station", "id": "ST:0:4264122044719420567", "name": "90s Radio", "art": { "url": "https://cont-5.p-cdn.us/images/public/int/9/5/9/8/5055834148959_500W_500H.jpg" } } } }
-
AudioMessage
{ entity(id: "PL:51751960:1137644256") { id ... on Playlist { items(pagination: { limit: 2 }) { playlistItems { itemId entity { id type } } } } } }
{ "data": { "entity": { "id": "PL:51751960:1137644256", "items": { "playlistItems": [ { "itemId": "138", "entity": { "id": "AM:20266198323183913", "type": "AM" } }, { "itemId": "139", "entity": { "id": "TR:19914180", "type": "TR" } } ] } } } }
{ entity(id: "AM:20266198323183913") { id ... on AudioMessage { name duration id } } }
{ "data": { "entity": { "id": "AM:20266198323183913", "name": "Episode 2 Intro", "duration": 35 } } }