Thats a start
I tried looking for an nba api but i couldnt find one- but i found nba api projects like https://pypi.org/project/nba-api/
I dont know espn gets their historical data but scraping it wouldnt be problematic. I would think the pro sports orgs would have an api for it
Looks like espn has pretty good historical data records and their api has some documentation. Using the espn api might be your best bet here