Skip to content

Instantly share code, notes, and snippets.

View morisy's full-sized avatar

Michael Morisy morisy

View GitHub Profile
@dannguyen
dannguyen / nhtsa-5-star-api-scrape-csv.bash
Last active June 13, 2022 20:04
A Bash script, using the jq JSON-parser, to scrape all the NHTSA 5 star vehcile ratings from its API http://www.nhtsa.gov/webapi/Default.aspx?SafetyRatings/API/5
## Note: this is deprecated. jq is still awesome, so now we just get JSON all the way
# jq JSON parser is awesome:
# http://stedolan.github.io/jq/
# The NHTSA API is pretty clunky, requiring you to get a list of all the years, then all the models in that year, then all the makes per model, and then
# finally, you get the vehicle IDs needed to query the endpoint for one vehicle at a time.
#
# I query for JSON for most of the loop, and in the end, I get the Vehicle data in CSV format