added complete API for querying db