Fixed API class so that it correctly tracks hits from users with keys and tested it with an example database.