def add_api_config_to_queries(generated_query_strings, search_engines):
    """
        Merges the two parameters and returns a list of dicts that include the
        api config.

        If only 1 API key is provided, it is assumed this is valid for many searches and is used for all queries
        If more than 1 is provided, then the number of keys provided needs to match the number of queries

        Args:
            generated_query_strings: The output from the generate_query_strings
                                     function.
            search_engines: The search engines list that is found in the
                            api_config file. See the documentation for usage
                            guidelines (http://coast_search.readthedocs.io/).
        Returns:
            result_list: Updated list of query data now including search engine/api info
    """

    if len(search_engines) == 1:
        se = search_engines[0]
        for query_object in generated_query_strings:
            query_object["se_name"] = se["name"]
            query_object["api_key"] = se["api_key"]
            query_object["search_engine_id"] = se["search_engine_id"]

    elif len(search_engines) == len(generated_query_strings):
        for i in range(0, len(search_engines)):
            query_object = generated_query_strings[i]
            se = search_engines[i]
            query_object["se_name"] = se["name"]
            query_object["api_key"] = se["api_key"]
            query_object["search_engine_id"] = se["search_engine_id"]
    else:
        raise Exception("Invalid number of API keys.")

    return generated_query_strings