Imho, just to bring here some design pattern recall, have a single instance of the database connection object is the best practice (I'm broadly refering to the Singleton Pattern FYI). Like this you do not have to instanciate the db object and create the connection for each api call. You will save time and resource usage.