1

I have an active Django project where in a module I am uploading images to the Imgur server and retrieving them as a background image for generating a PDF using the direct link for the images (https://i.imgur.com/<hash>.png)

The issue is that when trying to retrieve any image from the Django server which is running on the local network IP (since the Imgur server blocks localhost) the server responds with a bizzare 429 error code.

The bizzare thing is I can upload images to my application without any problem, and also access the direct image links from postman API / browser, but as soon as I try to read the image direct link from my Django server imgur responds with a status code of 429.

Rate Limit data for my application:

{
 "data": {
 "UserLimit": 500,
 "UserRemaining": 499,
 "UserReset": 1709980963,
 "ClientLimit": 12500,
 "ClientRemaining": 12495
 },
 "success": true,
 "status": 200
}

Request code:

import requests
id = '<hash>'
res = requests.get(f'https://i.imgur.com/{id}.png')
# print(res.json()) #! Throws JSONDecodeError
print({
 "Headers": res.headers,
 "status_code": res.status_code,
 "reason": res.reason,
 "content": res.text,
 "url": res.url,
})

Response Headers and content I have retrieved from debugging because the res.json() method is failing

{
 "Headers": {
 "Connection": "close",
 "Content-Length": "0",
 "Retry-After": "0",
 "Cache-Control": "no-store, no-cache, must-revalidate, post-check=0, pre-check=0",
 "Accept-Ranges": "bytes",
 "Date": "2024年3月09日 10:10:15 GMT",
 "X-Served-By": "cache-ams21065-AMS",
 "X-Cache": "MISS",
 "X-Cache-Hits": "0",
 "X-Timer": "S1709979016.797421,VS0,VE0",
 "Strict-Transport-Security": "max-age=300",
 "Access-Control-Allow-Methods": "GET, OPTIONS",
 "Access-Control-Allow-Origin": "*",
 "Server": "cat factory 1.0"
 }
 "status_code": 429
 "reason": "Unknown Error"
 "content": ""
 "url": "https://i.imgur.com/\<hash\>.png"
 "_content_consumed": true
 "is_permanent_redirect": false
 "is_redirect": false
 }

Any ideas on what might be causing this issue?

Brian Tompsett - 汤莱恩
5,92772 gold badges64 silver badges135 bronze badges
asked Mar 9, 2024 at 10:33
2
  • 1
    No it was just an example I put in the question (sorry if it was confusing) the hash is injected correctly, since copying the generated link and pasting it in the browser loads up the image properly. Commented Mar 10, 2024 at 18:26
  • I'm experiencing the same issue - the code works for me on my computer but returns a basically identical error when it's on my server Commented Dec 1, 2024 at 11:03

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.