def query_periods(query_type=None, month_starts=[], month_ends=[]):
    """Generate a dictionary with consecutive monthly intervals to query where
    dates are formatted a little differently depending on the API to query.

    API date formatting:

    - AirNow API: Expects dates in format ``'YYYY-MM-DDTHH'``
        - Example: ``'2019-08-01T00'``
    - AQS API: Expects dates in format ``'YYYYMMDD'``
        - Example: ``'20190801'``

    Args:
        query_type (str):
            The name of the API to query (either 'AirNow' or 'AQS').
        month_starts (pandas datetimeindex):
            An array of monthly start dates generated by Date_Range_Selector
        month_ends (pandas datetimeindex):
            An array of monthly end dates generated by Date_Range_Selector
    Returns:
        monthly_periods (dict):
            Dictionary with monthly beginning and end dates formatted to the
            scheme expected by the API to be queried.

    """
    monthly_periods = {}
    for start, end in zip(month_starts, month_ends):

        month_name = start.month_name()
        year_name = str(start.year)[-2:]

        s_yr = str(start.year)
        s_mo = str(start.month).zfill(2)
        s_day = str(start.day)

        e_yr = str(end.year)
        e_mo = str(end.month).zfill(2)
        e_day = str(end.day)

        if query_type == 'AQS':
            bdate = s_yr + s_mo + '0' + s_day
            edate = e_yr + e_mo + e_day
            monthly_periods.update({month_name + year_name: {'bdate': bdate,
                                                             'edate': edate}})
        elif query_type == 'AirNow':
            bdate = (s_yr + '-' + s_mo + '-' + '0' + s_day + 'T00')
            edate = (e_yr + '-' + e_mo + '-' + e_day + 'T23')
            monthly_periods.update({e_yr + s_mo: {'startDate': bdate,
                                                  'endDate': edate}})
        else:
            raise ValueError(f'Invalid value for query_type: {query_type}.'
                             ' Accepted values include "AQS" and "AirNow"')

    return monthly_periods