Make the api data get stored somewhere in the main folder and call a function called refresh once a day to update the files. This is to prevent over-querying the database, because as it stands currently, everytime a function in api.py is run, it is getting all the data again.