Class: imgur.Api
provides access to the imgur api.
this class is available in the server, only!
Table of Contents #
- imgur.Api.DEFAULT_OPTIONS
- new imgur.Api()
- api.delete()
- api.getImageInformation()
- api.uploadFile()
- api.uploadUrl()
imgur.Api.DEFAULT_OPTIONS #
Default options used for imgur api http calls
new imgur.Api(apiKey, [options]) #
apiKey
String - your personal imgur api key.options
Object - a custom options object that will be merged with the default options imgur.Api.DEFAULT_OPTIONS, Optional
api.delete(deletehash, callback, [ctx = null]) #
deletehash
String - the deletehash of the image that should be deleted. This is not the normal image hash / id used for imgur images!callback
Function - callback functionctx
Object - the context of the callback function, Optional
callback
gets two arguments (error, imgur.Response).
api.getImageInformation(hash, callback, [ctx = null]) #
hash
String - the id/hash of the image you want to get the information forcallback
Function - callback functionctx
Object - the context of the callback function, Optional
callback
gets two arguments (error, imgur.Response).
Example
api = new imgur.Api("secretkey"); api.getImageInformation('imagehash', function(err, response){ if (err) { console.log(err); } else { console.log("image has type " + response.get('type')); } });
api.uploadFile(file) #
NOT YET IMPLEMENTED
api.uploadUrl(url, callback, [ctx = null]) #
url
String - image url you want to upload to imgurcallback
Function - callback functionctx
Object - the context of the callback function, Optional
callback
gets two arguments (error, imgur.Response).
Example
api = new imgur.Api("secretkey");
api.uploadUrl("http://foo.bar/funny.gif", function(err, response){
if (err) {
console.log(err);
} else {
console.log("image uploaded. ID " + response.get('id'));
}
});
Documentation generated by mdoc.