Python client
Posted 22 Jul 2022, 0:29:35
Is there a 20 item threshold? I ran the code on the “Grateful Dead” and it only returned the last 20 concerts instead of the 2,000+ concerts I would expect.
Posted 22 Jul 2022, 0:33:50
Yes, the API implement pagination. You have to query each page.
Posted 26 Jul 2022, 23:02:46
I set up a range() loop to pull X through Y pages but I get error 429. Any tips? I am trying to extract an artist's entire setlist history. Thanks!
Posted 26 Jul 2022, 23:37:19
Gotcha. So would I just need to add some logic to stagger the loop? Sorry, for all the questions— this is a use-case for me to start learning Python in practice.
Posted 26 Jul 2022, 23:44:25
Yea, add a sleep or something. Some APIs return a header that tells you how long until you can make your next request, I don’t recall if this one does or not
Posted 27 Jul 2022, 13:58:47
Managed to parse out the queries. Made it half way through and noticed any page past 116 returns with a 404 error— have you come across this?
Posted 27 Jul 2022, 14:07:03
116 must be the last page. The response should tell you if there is a next page or not.
Posted 27 Jul 2022, 14:39:10
Well that makes sense now! Btw, I noticed a few validation errors regarding City / State requirements. Venues outside of the US (e.g. Giza Pyramids) do not play well.
Posted 27 Jul 2022, 14:47:06
Cool, would you mind making an issue on the repo so I can resolve?
Posted 5 May 2024, 20:51:00
Hello, thanks for creating this! I used your code to create a pandas dataframe by doing the following:
import setlist_fm_client
setlists = setlist_fm_client.get_artist_setlists(
“63aa26c3-d59b-4da4-84ac-716b54f1ef4d”,
api_key=“my_API_key”,
serialize=True
)
tame_impala_dict = setlists.dict()['setlist']
def extract_values(data):
records = []
for record in data:
for thing in record['sets']['set']:
for song in thing['song']:
records.append({
'RecordID' : record['id'],
'Date': record['event_date'],
'City': record['venue']['city']['name'],
'Country': record['venue']['city']['country']['name'],
'SongName': song['name'],
'Cover': song['cover'],
'Encore': thing['encore']
})
return records
records = extract_values(tame_impala_dict)
tame_impala = pd.DataFrame(records)
I'm not getting all of the setlists. It starts with the most recent, but then only goes back to August 2022. How can I edit the get_artist_setlists function to get all of the setlists?