SmugMug hAPIness
The hAPIness function wraps the complexities of creating valid and usable URLs for requests to the Smugmug API by requiring only the necessary information and allows for dependancy injection if desired for easier use.
AN API is great for providing access to data but interacting with one is not something that is fun for us humans.
Dependancies
NONE! Well, JavaScript.
The library doesn't have any external dependancies; this does also mean that it doesn't actually do any ajax requests for you or parameter string creation, you'll need to provide that based on your library of choice.
Usage
First, you will need to include the hAPIness.js
file in you project somehow."
Browser Environments
<script src="hAPIness.js"></script>
Using jQuery for AJAX and parameterization.
var smugmug = hAPIness("myAPIkey", "1.3.0");
hAPIness.setParamFn($.param);
smugmug.service.ping();
$.ajax({
dataType: "jsonp"
,success: function (data) {
})
,url: smugmug.albums.get({NickName: "SmugMug_username"})
});
NodeJS Environments
First include the package in the project from npm.
$ npm install hapiness
Then use the library in your project
var hAPIness = require("hAPIness")
, qs = require("qs");
var smugmug = hAPIness("myAPIkey", "1.3.0");
hAPIness.setParamFn(qs.stringify);
smugmug.service.ping();