Added queries and helper functions for first hit and latest api endpoints

Tests pass.