Obtain JSON list of all concerts for artist

Obtain JSON list of all concerts for artist

Posted 25 Jan 2021, 16:44:00

HI,

I'm a long time programmer, use JSON, and code in Swift on iOS, tvOS, and macOS.

I would like to query the setlist.fm database for all concerts ever performed by an artist, which includes the venue and GPS coordinates of the venue.

I've looked at the API, and it is not apparent how I might achieve my goal with multiple queries or other. Would appreciate any guidance or an example on how this might be achieved.

Thanks so much,
Brian

Re: Obtain JSON list of all concerts for artist

Posted 26 Jan 2021, 7:23:18

I would like to query the setlist.fm database for all concerts ever performed by an artist,

The /1.0/artist/{mbid}/setlists endpoint is the one that does that (GPS coordinates are not available).

I've looked at the API, and it is not apparent how I might achieve my goal with multiple queries or other.

In order to improve the docs: What wasn't apparent? I'm wondering since it's the second one in the list of endpoints. An answer would be greatly appreciated.

Re: Obtain JSON list of all concerts for artist

Posted 26 Jan 2021, 14:47:28

Let's start with some basics. This will give perspective of a Newby to the API.

- I created my setlist.fm account, and logged in. I have an API Key.
- The mbid for the group Queen is 0383dadf-2a4e-4d10-a46a-e9e041da8eb3
- I go to endpoint /1.0/artist/{mbid} and enter the queen mbid - I click 'try it out' and I receive an error saying “Not Acceptable”
- the URL returned is:

https://api.setlist.fm/rest/1.0/artist/0383dadf-2a4e-4d10-a46a-e9e041da8eb3

Typing this in a browser produces the same error.

Why does this not return proper result?

0383dadf-2a4e-4d10-a46a-e9e041da8eb3

Last edited 26 Jan 2021, 14:48:41

Re: Obtain JSON list of all concerts for artist

Posted 27 Jan 2021, 7:19:10

I click 'try it out' and I receive an error saying “Not Acceptable”

Do you really get a “Not Acceptable” (406) response? It is supposed to be a “Forbidden” (403). I just went over the steps you described and got a 403.

Why does this not return proper result?

Because the API must be included in the request by setting the “x-api-key” header. This is explained in the shorts docs on the API page under “API Keys”. In the Swagger interface the api key can be provided in the top-right corner.

Re: Obtain JSON list of all concerts for artist

Posted 28 Jan 2021, 0:34:32

I first confirmed my key is correct. Then, enter it in the upper right.
When I click the Explore button to the right, the key has small light dots in red under the key. This might leave me to believe the key is incorrect, though again I double checked and it is the key I was given.

Then I enter the same Beatles MBID used in the example shown, and try:

/1.0/artist/b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d/setlists

Once again, this is not accepted. See two images below:

https://appsird.net/setlist.fm/pic1.png
https://appsird.net/setlist.fm/pic2.png

Last edited 28 Jan 2021, 0:34:48

Re: Obtain JSON list of all concerts for artist

Posted 28 Jan 2021, 7:21:03

When I click the Explore button to the right, the key has small light dots in red under the key. This might leave me to believe the key is incorrect

The key is correct. The small red dots are the spell check from your browser.

Once again, this is not accepted.

I could reproduce the issue using Safari on OSX. Please try a different browser and it'll work. Please also see the 406 response code for apple products topic. You could also run the curl command shown in the interactive interface on the command line.

See two images below

Unfortunately the second image has your API key in it. I had to disable your API key and replaced it with a new one, you should see it in your settings. Please be careful never to expose your key to the public.

Last edited 28 Jan 2021, 7:24:28

Re: Obtain JSON list of all concerts for artist

Posted 28 Jan 2021, 15:46:39

>Unfortunately the second image has your API key in it.

Slightly incorrect. The image had a portion of the API key, not the entire API key.

Let me try another browser. Meantime, you should detect safari browser in HTML/Javascript and post a message so others are aware it does not work.

Re: Obtain JSON list of all concerts for artist

Posted 29 Jan 2021, 7:21:30

Slightly incorrect. The image had a portion of the API key, not the entire API key.

This image has the whole API key in it, right in the middle of the image where it says “Curl” (the x-api-key header) that's why we had to block and replace it.

Meantime, you should detect safari browser in HTML/Javascript and post a message so others are aware it does not work.

Thanks for the suggestion.Just to be sure, as explained in the linked topic about the 406 response it actually works as expected, but depends on the settings of the individual (Safari) browser. A 406 is the correct response and it's not a bug, it just can be confusing for users unaware of the Safari behaviour in context with their set Locale.

Last edited 29 Jan 2021, 7:28:45

Re: Obtain JSON list of all concerts for artist

Posted 30 Jan 2021, 18:15:04

Prior you stated:

>The /1.0/artist/{mbid}/setlists endpoint is the one that does that (GPS coordinates are not available).

I look up artist “Pat Metheny” and his MBID is:
7daac7f9-8fcc-485f-a14f-f8091d98cf25

I enter “Pat Metheny” in the setlist.fm search, and there are 100's of shows over many years.

I use this endpoint to list all of his concerts and setlists (per my original question):

/1.0/artist/7daac7f9-8fcc-485f-a14f-f8091d98cf25/setlists

There is an argument p=1 default. I change to 10, and post results in swagger UI.

I receive an error if I use p=100 or greater. Enterring this URL in the firefox browser:

https://api.setlist.fm/rest/1.0/artist/7daac7f9-8fcc-485f-a14f-f8091d98cf25/setlists?p=10

yields a “Forbidden” message once again.

Using the Swagger UI, results are returned, though contrary to your original response the returned venues do display the GPS coordinates.

__

Do I require back to back requests with some form of continuation token or other. can you point me to the place in the docs which describe how this is accomplished. Still unclear for myself. As there are many 100's of concerts for this artist.

thanks again.

Last edited 30 Jan 2021, 18:22:05

Re: Obtain JSON list of all concerts for artist

Posted 30 Jan 2021, 18:26:25

I filed a lengthy reponse, though the site deleted my message. Will try again.

Pat Metheny has 100';s of concerts. His MBID is 7daac7f9-8fcc-485f-a14f-f8091d98cf25
I enter Pat Metheny in setlist.fm search and 100's of shows returned.

I use the suggested endpoint:

/1.0/artist/7daac7f9-8fcc-485f-a14f-f8091d98cf25/setlists

And a few entries are returned. I see there is a p=1 arg changing to p=100 errors out.

Again, what sequence of posts are required to get all concerts for an artist.

Please note, the returned items do show GPS coordicates.

Last edited 30 Jan 2021, 18:26:58

Re: Obtain JSON list of all concerts for artist

Posted 30 Jan 2021, 18:44:38

Also, sending one request produced some results starting in 1989.

Running the request again produced results starting in 1981.

Re: Obtain JSON list of all concerts for artist

Posted 30 Jan 2021, 19:18:53

Disregard, I now understand.

The first request displays the total items per below. One uses this with itemsPerPage to determine how many pages to request.

thanks.

“type”: “setlists”, “itemsPerPage”: 20, “page”: 23, “total”: 460, “setlist”: [
Re: Obtain JSON list of all concerts for artist

Posted 31 Jan 2021, 0:44:24

OK, so I understand how to obtain my request by multiple requests with the Swagger UI. Now I am attempting to implement in my mac Swift code. This should look fairly straightforward below


        let setlist_API_Key = "my real key here"
        let mbid = "66a7f1f8-0ad6-4e3a-9346-a643e2739a8c"
        let setlistURL = "https://api.setlist.fm/rest/1.0/search/setlists?artistMbid=\(mbid)&p=1"
bc.
        guard let url = URL(string: "\(setlistURL)") else
        {
            log.error("invalid url")
            return
        }
bc.
        var request = URLRequest(url: url)
        request.httpMethod = "GET"
        request.addValue("\(setlist_API_Key)", forHTTPHeaderField: "x-api-key")
        request.addValue("application/json", forHTTPHeaderField: "Content-Type")
//      request.httpBody = payload
bc.
        URLSession.shared.dataTask(with: request) { (data, response, error) in
            guard error == nil else { print(error!.localizedDescription); return }
            guard let data = data else { print("Empty data"); return }
bc.
            if let str = String(data: data, encoding: .utf8) {
                print(str)
            }
        }.resume()
    }

The results i receive back and print() are:

?xml version=“1.0″ encoding=”UTF-8″ standalone=“yes”?>
<error>
<code>406</code>
<status>Not Acceptable</status>
<timestamp>2021-01-31T00:36:26.934+0000</timestamp>
</error>


Here I am performing a GET, and use the API key for the request.

Any tips welcome.

Last edited 31 Jan 2021, 0:50:06

Re: Obtain JSON list of all concerts for artist

Posted 1 Feb 2021, 7:49:28

Any tips welcome.

As discussed above, the “406 Not Acceptable” status most likely appears due to a non supported Locale in the “Accept-Language” header. The default, if the header is not set, is to return English results. So please check whether the header gets set by your framework or set the header manually. Also, to get a JSON response you should set the “Accept” header to “application/json”, not the “Content-Type” header. The latter is for POST or PUT requests from the client (or responses from the server). My advice would be that you run the `curl` command shown on the Swagger interface in your console and see if this works for you. If it does, then the error must be somewhere on the client.

Please note, the returned items do show GPS coordicates.

Yes sorry, I wasn't precise enough in my previous answer. You asked for coordinates of the venues, and that's not supported. The returned coordinates are the coords of the city/town.

Last edited 1 Feb 2021, 7:50:35

Post Reply

You're not allowed to do this, please sign in first.