@@ -16,7 +16,7 @@ Upload a single image:
1616imgur cat.png
1717```
1818
19- Upload multiple images ([ globbing] ( http://en.wikipedia.org/wiki/Glob_(programming) ) supported):
19+ Upload multiple images ([ globbing] ( < http://en.wikipedia.org/wiki/Glob_(programming) > ) supported):
2020
2121``` bash
2222imgur cat.png cats.gif cats23.jpg
@@ -103,20 +103,20 @@ imgur.getClientId();
103103
104104// Saving to disk. Returns a promise.
105105// NOTE: path is optional. Defaults to ~/.imgur
106- imgur . saveClientId (path)
107- . then ( function () {
108- console . log ( ' Saved. ' );
109- })
110- . catch ( function ( err ) {
111- console . log ( err . message );
112- } );
113-
106+ imgur
107+ . saveClientId (path)
108+ . then ( function () {
109+ console . log ( ' Saved. ' );
110+ })
111+ . catch ( function ( err ) {
112+ console . log ( err . message );
113+ });
114114
115115// Loading from disk
116116// NOTE: path is optional. Defaults to ~/.imgur
117- imgur .loadClientId (path)
118- .then (imgur .setClientId );
117+ imgur .loadClientId (path).then (imgur .setClientId );
119118```
119+
120120#### Dealing with API URL:
121121
122122In order to change the API Url say Mashape URL, use setAPIUrl(MashapeURL)
@@ -130,9 +130,10 @@ imgur.setAPIUrl('https://api.imgur.com/3/');
130130// Getting
131131imgur .getAPIUrl ();
132132```
133+
133134#### Dealing with Mashape Key
134135
135- Requests to the Mashape URL expects a X-Mashape-Key: MashapeKey header.
136+ Requests to the Mashape URL expects a X-Mashape-Key: MashapeKey header.
136137Set Mashape Key by using setMashapeKey(MashapeKey) method.
137138Note: Defaults to process.env.IMGUR_MASHAPE_KEY
138139
@@ -143,137 +144,144 @@ imgur.setMashapeKey(https://imgur-apiv3.p.mashape.com/);
143144// Getting
144145imgur .getMashapeKey ()
145146` ` `
147+
146148#### Dealing with credentials:
147149
148150For when you want to upload images to an account.
149151
150152` ` ` javascript
151153// Setting
152154imgur .
setCredentials (
' [email protected] ' ,
' password' ,
' aCs53GSs4tga0ikp' );
153-
154155` ` `
155156
156157#### Uploading files; globbing supported:
157158
158159` ` ` javascript
159160// A single image
160- imgur .uploadFile (' /home/kai/kittens.png' )
161- .then (function (json ) {
162- console .log (json .data .link );
163- })
164- .catch (function (err ) {
165- console .error (err .message );
166- });
161+ imgur
162+ .uploadFile (' /home/kai/kittens.png' )
163+ .then (function (json ) {
164+ console .log (json .data .link );
165+ })
166+ .catch (function (err ) {
167+ console .error (err .message );
168+ });
167169
168170// All jpegs in a specific folder
169171// to an album you own
170172var albumId = ' F8KTV' ;
171- imgur .uploadFile (' /home/kai/*.jpg' , albumId)
172- .then (function (json ) {
173- console .log (json .data .link );
174- })
175- .catch (function (err ) {
176- console .error (err .message );
177- });
173+ imgur
174+ .uploadFile (' /home/kai/*.jpg' , albumId)
175+ .then (function (json ) {
176+ console .log (json .data .link );
177+ })
178+ .catch (function (err ) {
179+ console .error (err .message );
180+ });
178181
179182// Multiple image types from home folder
180- imgur .uploadFile (' ~/*.(jpg|png|gif)' )
181- .then (function (json ) {
182- console .log (json .data .link );
183- })
184- .catch (function (err ) {
185- console .error (err .message );
186- });
183+ imgur
184+ .uploadFile (' ~/*.(jpg|png|gif)' )
185+ .then (function (json ) {
186+ console .log (json .data .link );
187+ })
188+ .catch (function (err ) {
189+ console .error (err .message );
190+ });
187191` ` `
192+
188193#### Searching images within the gallery:
189194
190- The first argument should be a query to search and it's the only required option. The second argument is optional params to sort your query by.
195+ The first argument should be a query to search and it's the only required option. The second argument is optional params to sort your query by.
191196
192197- ` sort` - Accepts 'time', 'viral', or 'top' as a value. Defaults to top.
193198- ` dateRange` - Accepts 'day', 'week', 'month', 'year', or 'all' as a value. Defaults to all.
194199- ` page` - Accepts an integer (e.g. 1, 2, 3, 4) as a value. Defaults to 1.
195200
196- Search returns an object with the query response as an array of objects that include an image's ID, title, description, views, etc.. and the params you sent with the request.
201+ Search returns an object with the query response as an array of objects that include an image's ID, title, description, views, etc.. and the params you sent with the request.
197202
198203` ` ` javascript
199204var query = ' cats' ;
200- var optionalParams = {sort: ' top' , dateRange: ' week' , page: 1 }
201- imgur . search (query, optionalParams)
202- . then ( function ( json ) {
203- console . log ( json);
204- })
205- . catch ( function ( err ) {
206- console . error ( err);
207- } );
208-
205+ var optionalParams = { sort: ' top' , dateRange: ' week' , page: 1 };
206+ imgur
207+ . search (query, optionalParams)
208+ . then ( function ( json ) {
209+ console . log (json);
210+ })
211+ . catch ( function ( err ) {
212+ console . error (err );
213+ });
209214` ` `
210215
211216#### Fetching image data:
212217
213218` ` ` javascript
214219var kittenPic = ' mbgq7nd' ;
215- imgur . getInfo (kittenPic)
216- . then ( function ( json ) {
217- console . log ( json);
218- })
219- . catch ( function ( err ) {
220- console . error ( err . message );
221- } );
222-
220+ imgur
221+ . getInfo (kittenPic)
222+ . then ( function ( json ) {
223+ console . log (json);
224+ })
225+ . catch ( function ( err ) {
226+ console . error ( err . message );
227+ });
223228` ` `
224229
225230#### Fetching album data:
226231
227232` ` ` javascript
228233var kittenAlbum = ' mbgq7nd' ;
229- imgur . getAlbumInfo (kittenAlbum)
230- . then ( function ( json ) {
231- console . log ( json);
232- })
233- . catch ( function ( err ) {
234- console . error ( err . message );
235- } );
236-
234+ imgur
235+ . getAlbumInfo (kittenAlbum)
236+ . then ( function ( json ) {
237+ console . log (json);
238+ })
239+ . catch ( function ( err ) {
240+ console . error ( err . message );
241+ });
237242` ` `
238243
239244#### Creating an album:
240245
241246` ` ` javascript
242- imgur . createAlbum ()
243- . then ( function ( json ) {
244- console . log ( json);
245- })
246- . catch ( function ( err ) {
247- console . error ( err . message );
248- } );
249-
247+ imgur
248+ . createAlbum ()
249+ . then ( function ( json ) {
250+ console . log (json);
251+ })
252+ . catch ( function ( err ) {
253+ console . error ( err . message );
254+ });
250255` ` `
251256
252257#### Uploading URLs of images hosted elsewhere:
253258
254259` ` ` javascript
255260// Include http(s) when specifying URLs
256- imgur .uploadUrl (' https://octodex.github.com/images/topguntocat.png' )
257- .then (function (json ) {
258- console .log (json .data .link );
259- })
260- .catch (function (err ) {
261- console .error (err .message );
262- });
261+ imgur
262+ .uploadUrl (' https://octodex.github.com/images/topguntocat.png' )
263+ .then (function (json ) {
264+ console .log (json .data .link );
265+ })
266+ .catch (function (err ) {
267+ console .error (err .message );
268+ });
263269` ` `
264270
265271#### Uploading Base-64 encoded images:
266272
267273` ` ` javascript
268- var imgurFavicon = ' iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAmUlEQVQ4je2TsQ3CMBBFnxMa08WR2IQKJskIUNwMZAcYwWIQMs65JCUpEEIYW4pJy6v+6e6+/hVnnGsAzsCBMi7AsbbW/rIMsAU2xrnmkeruuzW7zgIw+JGbv6fGQpWzfy3HOsJlDQY/AlCv3jpF9oS5ZBOICKoB1YCIlCdQDR9127qyBHP5Gyw3CBXPr/qi709JHXE1S995AsqoJu8x78GsAAAAAElFTkSuQmCC' ;
269-
270- imgur .uploadBase64 (imgurFavicon)
271- .then (function (json ) {
272- console .log (json .data .link );
273- })
274- .catch (function (err ) {
275- console .error (err .message );
276- });
274+ var imgurFavicon =
275+ ' iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAmUlEQVQ4je2TsQ3CMBBFnxMa08WR2IQKJskIUNwMZAcYwWIQMs65JCUpEEIYW4pJy6v+6e6+/hVnnGsAzsCBMi7AsbbW/rIMsAU2xrnmkeruuzW7zgIw+JGbv6fGQpWzfy3HOsJlDQY/AlCv3jpF9oS5ZBOICKoB1YCIlCdQDR9127qyBHP5Gyw3CBXPr/qi709JHXE1S995AsqoJu8x78GsAAAAAElFTkSuQmCC' ;
276+
277+ imgur
278+ .uploadBase64 (imgurFavicon)
279+ .then (function (json ) {
280+ console .log (json .data .link );
281+ })
282+ .catch (function (err ) {
283+ console .error (err .message );
284+ });
277285` ` `
278286
279287#### Uploading multiple images:
@@ -283,14 +291,14 @@ Upload an array of images of the desired upload type ('File', 'Url', 'Base64').
283291Returns an array of images (imgur image data).
284292
285293` ` ` javascript
286- imgur . uploadImages (images, uploadType /* , albumId */ )
287- . then ( function ( images ) {
288- console . log ( images);
289- })
290- . catch ( function ( err ) {
291- console . error ( err . message );
292- } );
293-
294+ imgur
295+ . uploadImages ( images, uploadType /* , albumId */ )
296+ . then ( function ( images ) {
297+ console . log (images);
298+ })
299+ . catch ( function ( err ) {
300+ console . error ( err . message );
301+ });
294302` ` `
295303
296304#### Uploading an album:
@@ -302,30 +310,31 @@ Returns an object with the album data and an array of images { data: {...}, imag
302310The third parameter is an optional fail safe, meaning if the array of images is empty or invalid, it will not fail, but returns an object with empty data and empty images.
303311
304312` ` ` javascript
305- imgur . uploadAlbum (images, uploadType /* , failSafe */ )
306- . then ( function ( album ) {
307- console . log ( album . data , album . images );
308- })
309- . catch ( function ( err ) {
310- console . error ( err . message );
311- } );
312-
313+ imgur
314+ . uploadAlbum (images, uploadType /* , failSafe */ )
315+ . then ( function ( album ) {
316+ console . log ( album . data , album . images );
317+ })
318+ . catch ( function ( err ) {
319+ console . error ( err . message );
320+ });
313321` ` `
314322
315323#### Deleting anonymous uploads
316324
317325Delete an image based on the deletehash(generated during the image upload)
318326
319327` ` ` javascript
320- imgur .deleteImage (deletehash)
321- .then (function (status ) {
322- console .log (status);
323- })
324- .catch (function (err ) {
325- console .error (err .message );
326- });
328+ imgur
329+ .deleteImage (deletehash)
330+ .then (function (status ) {
331+ console .log (status);
332+ })
333+ .catch (function (err ) {
334+ console .error (err .message );
335+ });
327336` ` `
328337
329338## License
330339
331- #### MIT
340+ #### MIT
0 commit comments