Hey everyone! I'm currently diving into a project using the free NHL API (you can find the documentation [here](https://github.com/Zmalski/NHL-API-Reference)). I'm curious about the best approach when it comes to handling the data. The API has both historical data, which rarely changes, and real-time data that gets updated frequently. For instance, stats might be adjusted after games due to secondary assists or other minor changes. The database is pretty extensive, including about 25,000 players and nearly 3,000 games each year. I'm trying to figure out the professional way to work with this API—specifically, would it be better to store the data locally or to make repeated API calls for every request? I want to build this into a website, and while it's a passion for me, I'm considering the possibility of monetizing it down the line. I appreciate any insights you can give!
3 Answers
Storing data locally is likely to give you better performance in the long run. You could probably save historical data and just pull in current stats as needed. Plus, if you start making money from this, there's a chance they'll throttle your calls, so having local data can help.
It might seem like a lot, but downloading all the data could be the way to go if the API allows it. You can gradually download it without stressing their servers, ensuring your site remains functional even if their API goes down. Plus, having your own database means you can optimize queries and run offline analytics.
Thanks for the advice! I'll definitely consider downloading it all.
It's not just about what's 'acceptable'. Most APIs have rate limits, so even if you're not hitting them now, caching data locally will definitely improve performance and user experience. Most APIs also send cache-control headers which can help you decide how long to store data. If you're smart about caching, you can keep frequently changing data fresh without bugging the API all the time.
Thanks for the info! That makes a lot of sense.
That's a good point! I was thinking about how they might have a change log too. I could store the data and just update it based on any changes they announce, making most API calls just for verification.