16

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?

1 Answers1

22
$.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
  • 725
  • 1
  • 9
  • 15
  • I get this message: " POST https://api.imgur.com/3/image 403 (Permission Denied) " – acudars 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