openwhyd-api-client
v1.0.0
Published
Simple API client for Openwhyd.org
Downloads
6
Readme
Openwhyd API Client
A simple Node.js API client for Openwhyd.org.
Your can use it to:
- initiate a cookie-based Openwhyd user session, given their email address and password;
- make authenticated calls to Openwhyd's API endpoints;
- end the user session.
Usage
- Install the npm dependency to your Node.js project:
$ npm install openwhyd-api-client
- Use it to make API calls:
const OpenwhydAPI = require("openwhyd-api-client");
const creds = {
email: "[email protected]", // email address or user handle of your openwhyd account
md5: "6af652b33ce6a86ecf025b0da8ca8d24" // md5 hash of your openwhyd password
};
const openwhydAPI = new OpenwhydAPI();
openwhydAPI.login(creds.email, creds.md5, function (err, res) {
openwhydAPI.get("/api/user", {}, function (err, user) {
console.log("=> user name:", user.name);
openwhydAPI.logout();
});
});
Methods
The class exported from the package provides the following methods:
login (email, md5, callback)
get (path, params, callback)
logout (callback)
All callback
functions are called with (err, res)
as parameters.
Each instance of the class holds the cookie that identifies the user session initiated with that instance.