# HTTP API support for playlists

**URL:** <https://forums.plex.tv/t/http-api-support-for-playlists/88633>\
**Category:** Dev/API Corner\
**Tags:** other-dev\
**Created:** [January 3, 2015, 2:21am UTC](https://forums.plex.tv/t/http-api-support-for-playlists/88633 "2015-01-03T02:21:24Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mscottco](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mscottco](https://forums.plex.tv/u/mscottco)\
**Post date:** [January 3, 2015, 2:21am UTC](https://forums.plex.tv/t/http-api-support-for-playlists/88633/1 "2015-01-03T02:21:24Z")

</div>

Is anyone aware if/when/how the HTTP API will allow you to start playing a playlist on a Plex Home Theater client?

&nbsp;

Currently I get a&nbsp;\<Response&nbsp;code="500"&nbsp;status="Could not find that item"/\>&nbsp;when I use the playlist key from /playlists however playing a single file works ok.

&nbsp;

**Detailed info:**

The HTTP command I am using is:

> http://:/player/playback/playMedia?key=&machineIdentifier=&address=&port=

&nbsp;

The playlist key looks like:

> /playlists/14857/items

---

<div class="post-metadata">

**Author:** ![mscottco](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mscottco](https://forums.plex.tv/u/mscottco)\
**Post date:** [January 24, 2015, 4:44am UTC](https://forums.plex.tv/t/http-api-support-for-playlists/88633/2 "2015-01-24T04:44:29Z")

</div>

Having done some digging with Wireshark, I've found that the playlists actually leverage playqueues when playing. The general process looks to be that a playqueue be created with the playlist key via

> /playQueues?playlistID=14857&shuffle=0&type=audio&uri=library%3A%2F%2F%2Fitem%2F%252Fplaylists%252F14857%252Fitems&continuous=0

This returns a playqueue ID which is then sent to the client telling it to play.

When I replicate the above command in chrome I only get&nbsp; (where as the output in Wireshark has much more information)

Does anyone have any documentation on the playQueue API so I can see what I'm missing?&nbsp;

---

<div class="post-metadata">

**Author:** ![jooray](https://avatars.discourse-cdn.com/v4/letter/j/f07891/32.png) [@jooray](https://forums.plex.tv/u/jooray)\
**Post date:** [March 23, 2015, 10:36pm UTC](https://forums.plex.tv/t/http-api-support-for-playlists/88633/3 "2015-03-23T22:36:52Z")

</div>

I'm looking at the same thing right now. Documentation about HTTP API would be very welcome.

I'll let you know when I find something, just wanted to write out there that I am really interested in this.

---

<div class="post-metadata">

**Author:** ![jooray](https://avatars.discourse-cdn.com/v4/letter/j/f07891/32.png) [@jooray](https://forums.plex.tv/u/jooray)\
**Post date:** [April 4, 2015, 2:05am UTC](https://forums.plex.tv/t/http-api-support-for-playlists/88633/4 "2015-04-04T02:05:11Z")

</div>

OK, I figured it out. The problem is that you need X-Plex-Client-Identifier header. See these curl commands:

```
# get list of clients
curl -i -s -k -X 'GET' \
    -H 'X-Plex-Client-Identifier: 12345678-abab-4bc3-86a6-809c4901fb87' \
        'http://192.168.1.1:32400/clients'
# get list of playlists

curl -i -s -k -X ‘GET’   
-H ‘X-Plex-Client-Identifier: 12345678-abab-4bc3-86a6-809c4901fb87’   
‘[http://192.168.1.1:32400/playlists/all?type=15&X-Plex-Container-Start=0&X-Plex-Container-Size=50](http://192.168.1.1:32400/playlists/all?type=15&X-Plex-Container-Start=0&X-Plex-Container-Size=50)’

# create playqueue playlist

curl -i -s -k -X ‘POST’   
-H ‘X-Plex-Client-Identifier: 12345678-abab-4bc3-86a6-809c4901fb87’   
‘[http://192.168.1.1:32400/playQueues?playlistID=181334&shuffle=0&type=audio&uri=library%3A%2F%2F%2Fitem%2F%2Fplaylists%2F181334%2Fitems&continuous=0](http://192.168.1.1:32400/playQueues?playlistID=181334&shuffle=0&type=audio&uri=library%3A%2F%2F%2Fitem%2F%252Fplaylists%252F181334%252Fitems&continuous=0)’

curl -i -s -k -X ‘GET’   
-H ‘X-Plex-Client-Identifier: 12345678-abab-4bc3-86a6-809c4901fb87’ -H ‘X-Plex-Target-Client-Identifier: 99999993-ba46-40ff-80ff-999999999999’   
‘[http://192.168.1.1:3005/player/playback/playMedia?protocol=http&address=192.168.1.109&key=%2Flibrary%2Fmetadata%2F170872&offset=0&commandID=1&port=32400&containerKey=%2FplayQueues%2F2045%3Fown%3D1%26window%3D200&type=music&machineIdentifier=1231231231231231231231231231231231231232](http://192.168.1.1:3005/player/playback/playMedia?protocol=http&address=192.168.1.109&key=%2Flibrary%2Fmetadata%2F170872&offset=0&commandID=1&port=32400&containerKey=%2FplayQueues%2F2045%3Fown%3D1%26window%3D200&type=music&machineIdentifier=1231231231231231231231231231231231231232)’
```

Actually the funny thing is to get things like machineIdentifier and things like double-url-encoded parameters. I made a [simple Ruby code to play a playlist by name](https://github.com/jooray/plex-playlistplay).

---

<div class="post-metadata">

**Author:** ![rverstappen](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@rverstappen](https://forums.plex.tv/u/rverstappen)\
**Post date:** [July 22, 2015, 8:22pm UTC](https://forums.plex.tv/t/http-api-support-for-playlists/88633/5 "2015-07-22T20:22:42Z")

</div>

@jooray, thanks very much for researching this. Your Ruby script works for me up until the last step: actually starting playback on the client (a Roku device). It finds the correct host and the playlist fine. What client are you using with your script?

I’m guessing that casting to Roku works differently. When casting to Roku from the Plex app, the PMS log file shows some sort of “delegation” request that transfers control to the Roku client, which then issues its own playQueues request. Any further insight would be very welcome.

---

<div class="post-metadata">

**Author:** ![rverstappen](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@rverstappen](https://forums.plex.tv/u/rverstappen)\
**Post date:** [July 22, 2015, 8:34pm UTC](https://forums.plex.tv/t/http-api-support-for-playlists/88633/6 "2015-07-22T20:34:20Z")

</div>

…and I confirmed that your script does work with the Plex Home Theater application. Thanks again for that.

---

<div class="post-metadata">

**Author:** ![adam.will](https://avatars.discourse-cdn.com/v4/letter/a/0ea827/32.png) [@adam.will](https://forums.plex.tv/u/adam.will)\
**Post date:** [November 5, 2017, 11:53am UTC](https://forums.plex.tv/t/http-api-support-for-playlists/88633/7 "2017-11-05T11:53:38Z")

</div>

@jooray

thanks for the examples above however im having some trouble getting these to work  
can you confirm where / how you are adding an item to the play queue that you created?

i was able to create the play queue using your curl command above but everytime i do get /playQueue? it lists my newly created play queue but it has an item count of -1

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 21, 2019, 4:04am UTC](https://forums.plex.tv/t/http-api-support-for-playlists/88633/8 "2019-12-21T04:04:02Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
