Pregunta

I want to develop an app that pulls the singers of any song that we query for. So if someone types in Carry On from the Some Nights album, the app is supposed to pull out who all sang that song. Thanks.

¿Fue útil?

Solución

You can search for this using the Freebase Search API and Search Metaschema like this:

https://www.googleapis.com/freebase/v1/search?query=Carry+On&filter=(all+/music/release_track/release:"Some+Nights")&output=(/music/release_track/release+/music/release_track/recording./music/recording/artist)

There are three parts to this API request: the query, the filter and the output parameter. The query is simply the name of the track that you're looking for:

query=Carry+On

The filter parameter constrains the results to only tracks which are part of an album release named "Some Nights"

filter=(all+/music/release_track/release:"Some+Nights")

The output parameter tells the API which properties to return in the response. In this case we want to know which release the track is part of and which artist recorded the track.

output=(/music/release_track/release+/music/release_track/recording./music/recording/artist)

You'll notice that this query actually returns 8 matching tracks right now. This is because there were many different releases of the album which all contained recordings of that track (and not necessarily the exact same recording).

For what you're building it sounds like you should be able to just take the first result. You can constrain the search API to only return the first result by adding a limit parameter to the request:

limit=1
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top