The error#
On HTTP 429, _raise_for_status raises TooManyRequestsException. The message is built by _response_error:
{status_code} {reason} - "{status}" status, message "{message}" when accessing {url}The JSON suffix is omitted when the body is not that JSON. TooManyRequestsException is a subclass of ConnectionException.
Before the retry, handle_429 logs this text:
Instagram responded with HTTP error "429 - Too Many Requests". Please do not run multiple instances of Instaloader in parallel or within short sequence. Also, do not use any Instagram App while Instaloader is running.When the wait is over 1.5 seconds it also logs The request will be retried in {time}, at {clock}.
If the retries run out, get_json raises ConnectionException with:
JSON Query to {path}: {the TooManyRequestsException}max_connection_attempts defaults to 3.
What triggers it#
resp.status_code == 429 inside _raise_for_status. The next loop sees a pending TooManyRequestsException and calls handle_429 before trying again. A separate log, Too many queries in the last time. Need to wait {time}, until {clock}., is printed by wait_before_query when the rate controller wants a wait over 15 seconds. That one is not a 429 yet.
How to confirm#
The logged sentence about HTTP error 429 - Too Many Requests is this case. The final exception may be ConnectionException rather than TooManyRequestsException, with JSON Query to at the start and the 429 text inside it.
Fixes#
The library's own instruction is in that log: do not run multiple instances in parallel or in a short sequence, and do not use an Instagram app on the same account while it runs. sleep defaults to true on Instaloader(), which sleeps a short random time before each request. That does not raise the ceiling once Instagram has already returned 429.
A cloud IP can hit 429 on the first bursts. Changing the sleep does not give you a different IP.
SocialScrape#
Instagram profile is GET /v1/instagram/profile. A private account comes back with is_private true. Posts are GET /v1/instagram/profile/posts, and one post is GET /v1/instagram/post.
Failed requests cost 0 credits. New accounts get 100 credits on signup, no card. Codes are on errors.