Access HTTP Header Details Through Python Instagram API
Question: I'm using the Instagram API to retrieve all photos from a list of hashtags.
Starting today, I've been hitting the API rate limits (429 error,
specifically). To debug this, I've been trying to see how to get the number of
calls I have left per hour and incorporate that into my script.

The Instagram API says that you can access the number of calls left in the
hour through the HTTP header, but I'm not sure how to access that in Python.

> The following fields are provided in the header of each response and their
> values are related to the type of call that was made (authenticated or
> unauthenticated):
>
> X-Ratelimit-Remaining: the remaining number of calls available to your app
> within the 1-hour window
>
> X-Ratelimit-Limit: the total number of calls allowed within the 1-hour
> window

<http://instagram.com/developer/limits>

How would I access this data in Python?


Answer: I assumed it was much a much fancier solution based on a few other answers on
SO, but after some researching, I found a really simple solution!

    
    
    import requests
    
    r = requests.get('URL of the API response here')
    
    r.headers
    

