# API send Command to play song on mopidy

**URL:** <https://discourse.mopidy.com/t/api-send-command-to-play-song-on-mopidy/192>\
**Category:** Misc\
**Created:** [September 21, 2014, 1:32am UTC](https://discourse.mopidy.com/t/api-send-command-to-play-song-on-mopidy/192 "2014-09-21T01:32:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![loliserver](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/loliserver/32/38_2.png) [@loliserver](https://discourse.mopidy.com/u/loliserver)\
**Post date:** [September 21, 2014, 1:32am UTC](https://discourse.mopidy.com/t/api-send-command-to-play-song-on-mopidy/192/1 "2014-09-21T01:32:48Z")

</div>

Greetings, I’m using mopidy on a vps with ubuntu, well i want to create an app with PHP using mpd.class.php, but I’m beginner with mopidy, how can I send a command for to play a song from soundcloud using API?

Sorry for my bad english.

---

<div class="post-metadata">

**Author:** ![kingosticks](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@kingosticks](https://discourse.mopidy.com/u/kingosticks)\
**Post date:** [September 21, 2014, 2:12am UTC](https://discourse.mopidy.com/t/api-send-command-to-play-song-on-mopidy/192/2 "2014-09-21T02:12:53Z")

</div>

Mopidy supports both mpd and a Web socket interface. Both of which are well documented so please take a look at that.

---

<div class="post-metadata">

**Author:** ![loliserver](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/loliserver/32/38_2.png) [@loliserver](https://discourse.mopidy.com/u/loliserver)\
**Post date:** [September 21, 2014, 6:47am UTC](https://discourse.mopidy.com/t/api-send-command-to-play-song-on-mopidy/192/3 "2014-09-21T06:47:59Z")

</div>

Oh I see, hmm I don’t understand this Tracklist controller: mopidy.tracklist.add

I want add a song from Soundcloud in the Queue with that command on Javascript.

I have this:

mopidy.tracklist.add({“tracks”:null,“at\_position”:null,“uri”:null}).then(function(data){  
console.log(data);  
});

but doesn’t work

for add a video from Youtube I have this:

mopidy.tracklist.add(null,0,‘youtube:video/test.1qMPcCXYKU0’).then(function(data){  
console.log(data);  
});

---

<div class="post-metadata">

**Author:** ![dz0ny](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/dz0ny/32/21_2.png) [@dz0ny](https://discourse.mopidy.com/u/dz0ny)\
**Post date:** [September 21, 2014, 9:35pm UTC](https://discourse.mopidy.com/t/api-send-command-to-play-song-on-mopidy/192/4 "2014-09-21T21:35:33Z")

</div>

Raw JSON using curl:

```
curl -X POST -H Content-Type:application/json -d '{
  "method": "core.tracklist.add",
  "jsonrpc": "2.0",
  "params": {
    "uri": "yt:https://www.youtube.com/watch?v=1qMPcCXYKU0"
  },
  "id": 1
}' http://localhost:6680/mopidy/rpc

```

or using js

```
mopidy.tracklist.add({"uri":"yt:https://www.youtube.com/watch?v=1qMPcCXYKU0"}).then(function(data){
  console.log(data);
});

```

See [https://github.com/dz0ny/mopidy-api-explorer](https://github.com/dz0ny/mopidy-api-explorer) for more examples.
