REST API Questions


I’ m just trying to figure out how the APi responses to the request :

How can I list all artists from a given genre ?
All Albums from a given artist ?-+

I would like to write a frontend in python, which would be easier for me to do than the same thing in javascript or nodejs.The frontend will be Album oriented and suitable for a TV remote and a TV display.

Thanks for your response.

The documentation is at

You may find the API explorer useful for getting a feel for things:

Thank you kingosticks for your reply.
I have already read the documentation and also installed api-explorer.
I have previously worked with numerous online API’s ( 7, including this from TMDB , you can see it here

But this API gives me some headache … I explain:

The search functions gives me a dict. with a result key with is a list.
Is the length of this list always 1 ?

In the result key I got a tracks key wich contains all the tracks.
A track has an album key, and other keys like name, uri,genre, artists.
But the album key has also an artists key ?
Is the artist in albums the AlbumArtist id3 tag and the other the Artist id3 tag ? It seams so.

If I pick from each track the album dict and make a list of it, deleting the duplicates, I offently end with a list where I got more than once the same album name : so isn’t the album dict. unique for each album ?
It is, but a very slight difference in the tags ends up with 2 different albums !
What are the scanned tags wich MUST be identical in each file of an album to have a single Album ?
Album,AlbumArtist, Musicbrainz Album, … what else ?

As an example, the player Quodlibet relies on the MusicBrainz album ID or labelid to have different albums.Here, we have clearly numerous more tags, it seams. A single uncorrect value, and all is messed up …(?)

Here’s a dummy sample code I wrote. Would it be the right way to use the API ? Any remarks ?
As I see, i must do the whole part of the tracks filtering myself (?), because there isnt’ a functions who gives me directly all different albums ?

Many questions, I know …
Thanks for your time.

import requests
import json

def main():
    url = "http://localhost:6680/mopidy/rpc"
    headers = {'content-type': 'application/json'}
    search = {
        "method": "",
        "params": {"query": { "genre":["Jazz"]},"uris" : None, "exact" : False},
        "jsonrpc": "2.0",
        "id": 1,
    response =, data=json.dumps(search), headers=headers).json()
    print json.dumps(response)
    # get all the tracks, is the lengh always 1 ?
    tracks = response["result"][0]["tracks"]
    # get  album dict. out for each track
    albums = [track["album"] for track in tracks ]

    unique_album = []
    # delete duplicated albums ....
    for album in albums:
        if album not in unique_album:
    # I got offen more than 1 dict. with the same name here, because of slight differences in the tags !
    for album in unique_album:
        print album["name"]

if __name__ == "__main__":

And Have a merry chrismas everybody here !

See here:
Return type: list of mopidy.models.SearchResult
You’ll basically get one search result from each backend that supports your query. As for search results, these may not only contain tracks, but also artists and/or albums, depending on the capabilities if the backend. You should get yourself acquainted with Mopidy’s data model, then all this will probably make more sense:

Yes, I have seen the docs.It is very well written.

I appears that when i’m doing a request,only tracks are returned, no albums and no artists.
It’s the same with MusicBox and Moped : when I do a search, the section corresponing to artist and the section album stays empty.
The respons consits only of a bunch of tracks.

I must have a problem in my setup, and I will try to reinstall everything.
But the library is correctly scanned and the images are written in the folder I have specified.

Thanks for your help !

As I said before, whether albums or artists are returned in a search result depends entirely on what backend extensions you have installed. The local-json and local-sqlite backend will only return tracks as for now. The internetarchive backend, for example, will only return albums. The dleyna backend may return artists, albums and/or tracks, depending on your DLNA server. And so on.

Ok !
So for the local-json and local-sqlite I should process things in a similar way that what I have done for now in order to browse per album or artists.
Or wait for some upcoming functionnalities .
I think we can close this.

Thanks for your clarification !