Documentation

Tutorial: Authenticate App User with Pandora

3. Query a Pandora Resource

Using your access token you can now query Pandora resources via the GraphQL API. Use this command to test it out (replacing the bearer token with your own):



curl 'https://ce.pandora.com/api/v1/graphql/graphql' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer ' \
  -d '{"query":"{topArtists{items{...on Artist{sortableName}}}}"}'

A successful response will look like the below structure. Take note that the content will be different depending on the Pandora listener account that you used to create the access token with.



{
  "data": {
    "topArtists": {
      "items": [
        {
          "sortableName": "Of Monsters and Men"
        },
        {
          "sortableName": "Mumford & Sons"
        },
        {
          "sortableName": "Smith & Thell"
        },
        {
          "sortableName": "Harry Connick, Jr."
        },
        {
          "sortableName": "Kanye West"
        },
        {
          "sortableName": "Florence + The Machine"
        },
        {
          "sortableName": "Lumineers, The"
        }
      ]
    }
  }
}

If no content is available the items array will be empty.  An invalid access token will return the following error:



{
 "errors": [
   {
     "message": "Context creation failed: User authentication failed with error.",
     "extensions": {
       "code": "UNAUTHENTICATED"
     }
   }
 ]
}