All the examples I find online are of earlier versions of the Imgur API or non JS code all of which uses an API key which doesn't exist in the newer API. Instead you get a client_id
and secret
. Anyone have example code that shows how an image can be uploaded to Imgur through JavaScript (or jQuery) using version 3 of their API?
Asked
Active
Viewed 1.0k times
16
2 Answers
21
$.ajax({
url: 'https://api.imgur.com/3/image',
headers: {
'Authorization': 'Client-ID YOUR_CLIENT_ID'
},
type: 'POST',
data: {
'image': 'helloworld.jpg'
},
success: function() { console.log('cool'); }
});

vin
- 823
- 1
- 10
- 15
-
I get this message: " POST https://api.imgur.com/3/image 403 (Permission Denied) " – achudars Aug 07 '13 at 14:35
-
@vin awesome thanks so much. Been confused about this for weeks. – Aug 07 '13 at 15:20
-
5@acudars did you change this part: "YOUR_CLIENT_ID" with the client id you recieved after registering your app here https://api.imgur.com/oauth2/addclient ? – Aug 07 '13 at 15:49
-
why the response I get is 1203 image over capacity? even after I used a very small image? – Junchao Gu Jun 24 '15 at 15:05
-
@vin Why i have error? `$.ajax({ url: 'https://api.imgur.com/3/image', headers: { 'Authorization': '6b72b886602****' }, type: 'POST', data: { 'image': '111.PNG' }, success: function() { console.log('cool'); } });` – Юрий Светлов May 15 '16 at 13:03
-
I sill get permission denied after putting my own client id as well. – Mahin Khan Feb 20 '17 at 23:42
-
Im getting error 429, SO link: https://stackoverflow.com/questions/66873683/unable-to-post-image-to-imgur-api-with-axios-post?noredirect=1 – Nithin Sai Mar 30 '21 at 17:46
0
Building on @vin's example here is one:
$(document).ready(function() {
$.ajax({
url: 'https://api.imgur.com/3/image',
headers: {
'Authorization': 'Client-ID a1b2c3d4e5'
},
type: 'POST',
data: {
'image': image
},
success: function(data, status) {
console.log("Data: " + data.data.link + "\nStatus: " status);
console.log(data.data.link)
}
});
});
This lets you save the url to the file.

benjm
- 57
- 1
- 14