Boto3 giving empty responses for 'Hourly' Cost Explorer queries



I'm trying to use the recently added Hourly billing queries but I can't get it to work with boto3. I have had success using the very latest awscli (1.16.292), but version 1.10.28 of boto3 at least does not appear to work for me.

The query I'm using:

import boto3
from datetime import datetime, timedelta

CURRENT_HOUR =,second=0,microsecond=0)
PREVIOUS_HOUR = CURRENT_HOUR - timedelta(hours=1)

aws_client = boto3.client(

response = aws_client.get_cost_and_usage(
            'Start': PREVIOUS_HOUR.isoformat() + 'Z',
            'End': CURRENT_HOUR.isoformat() + 'Z',
                'Type': 'DIMENSION',
                'Key': 'SERVICE'
                'Type': 'DIMENSION',
                'Key': 'LINKED_ACCOUNT'

Can anyone replicate this?

Edited by: ElliottIwoca on Nov 29, 2019 3:44 AM

Edited by: ElliottIwoca on Nov 29, 2019 3:48 AM

Edited by: ElliottIwoca on Nov 29, 2019 3:48 AM

asked 5 years ago598 views
1 Answer

OK, I worked out that the "HOURLY" responses will respond empty if they are too recent. The most recent response I got was around 31 hours ago, so I will query 2 days in the past to make sure I get a valid response.

answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions