Login and get coding
This is the endpoint you will use: https://api.nytimes.com/svc/books/v3/lists/current/hardcover-nonfiction.json?api-key=yourkey (the tests also use hardcover-fiction.json).
Feel free to create an account and obtain an API key to try this out locally. To work with static data we've mocked out the response in the tests.
get_best_seller_titlesbelow, for the non-fiction best seller list, the function should return the following
tuples:[ ('BETWEEN THE WORLD AND ME', 86), ('EDUCATED', 79), ('BECOMING', 41), ('THE SECOND MOUNTAIN', 18), ('THE PIONEERS', 16), ('MAYBE YOU SHOULD TALK TO SOMEONE', 14), ('UNFREEDOM OF THE PRESS', 14), ('RANGE', 9), ('THREE WOMEN', 7), ('TRICK MIRROR', 3), ('HOW TO BE AN ANTIRACIST', 2), ('KOCHLAND', 2), ('THANK YOU FOR MY SERVICE', 1), ('THE OUTLAW OCEAN', 1), ('GODS OF THE UPPER AIR', 1) ]
Keep this script at hand, maybe you can run it in a few months and compare the results. Or collect it weekly or monthly and start plotting the data?
Have fun and learn more Python and APIs!