API, how to search all artists in a country

Hi All,

As a noob, I hope to get a push in the right direction. I want to make an api request in a React application to search for all artists in e.g. Germany.

What endpoint and query should I then use?

Hi and welcome to the MusicBrainz community!
If I am not mistaken, the relevant documentation for you should be MusicBrainz API - MusicBrainz for the API and Indexed Search Syntax - MusicBrainz for the search parameters

Something like that should work:

fetch(
  'https://musicbrainz.org/ws/2/artist?query=area:Germany&limit=20&fmt=json'
).then(
  data => data.json()
).then(
  data => data.artists.map(artist => console.log(artist.name, artist.area.name))
);

Don’t forget to read about API use rules and rate limiting: MusicBrainz API / Rate Limiting - MusicBrainz

3 Likes

Thanks so much! This works for me. How can I make this work to search in multiple countries?

Next filter I want to make is for Genre. I read in the documentation that there are 13 entities. Genre is mention, but when I open the page of the entities (MusicBrainz Entity - MusicBrainz), genre is not mention there. Has it been removed?

I cant find genre in the returned json code either. I do see “tags”. Are tags the way to go, instead of genre?

Using this query, are you just matching the string “Germany”, or are you using the country/region/city … hierarchy (as discussed in another post)?

I guess the easiest is to use OR:

https://musicbrainz.org/ws/2/artist?query=area:Siena OR area:Toscana&limit=100&fmt=json

Yes, there are no specific entities for genres, but some tags are recognized automatically as genres, cf Genre - MusicBrainz and Genre list - MusicBrainz for a list.

1 Like

The string (testing on Siena, it seems I get results for both the city and the region). I don’t think you can use area hierarchy in the artist queries, at least I don’t see anything in the source code or the documentation to deal with it.

1 Like

No, we never got around to adding it instead. Whoops! I added it now.

But is genre really such an entity?
It seems rather like ISRC or Disc ID:
It does have an URL but no MBID, no edit history, no merge edits, etc.

But to add to this: The Webservice can return the genres separately, use “genres” as an inc parameter

1 Like

In my opinion, it’s quite important to introduce this hierarchy to get lists of artists by country, otherwise the information on the area is difficult to manage.

Genre does have an mbid :slight_smile: And will hopefully eventually have URL relationships. But we’re getting off topic, we can start a new thread if needed.

3 Likes