Generalized query to API

Added function to generalize the request to the API. Arguments are the
bearer_token, query name, response format and parameters of the request.