def date_format(date, api):
    """
    Convert datetime.datetime object to string
    compatible with a given API.
    """
    if api == 'ipea':
        return date.strftime('%Y-%m-%dT00:00:00') + '-00:00'
    if api == 'bcb':
        return date.strftime('%d/%m/%Y')
    if api == 'ibge':
        return date.strftime('%Y%m')
