Node-Wufoo is a Wufoo API wrapper for node.js. It simplifies working with the Wufoo API and provides an abstraction layer.
$ npm install wufoo
Each API returns it's own set of objects which is all documented on Wufoo.com for reference.
The required node version is 8.0.0
and above for all releases above v1.2.x
.
var Wufoo = require("wufoo");
var wufoo = new Wufoo("fishbowl", "AOI6-LFKL-VM1Q-IEX9");
wufoo.getForms(function(err, forms) {
// do something with your forms here.
});
// get a specific form given the id.
wufoo.getForm("idofForm", function(err, form){
// do something with your form here.
});
wufoo.getFormEntries("idofForm", function(err, entries) {
// do something with your entries here.
});
// pass in optional query parameters
var optionalQuery = {pretty: true}
wufoo.getForms(optionalQuery, function(err, forms) {
// do something with your forms here.
});
// get a specific form given the id and pass in optional query parameters
wufoo.getForm("idofForm", optionalQuery, function(err, forms) {
// do something with your forms here.
});
wufoo.getFormEntries("idofForm", optionalQuery, function(err, entries) {
// do something with your entries here.
});
Get all the forms for an account. getForms
returns an array of Form
objects. You can also call getForm
to get a specific Form
.
wufoo.getForms(function(err, forms) {
console.log(forms[0].hash);
console.log(forms[0].name);
console.log(forms[0].description);
// do something here.
});
// get a specific form given the id.
wufoo.getForm("idofForm", function(err, form){
// do something here.
});
// pass in optional query parameters
var optionalQuery = {pretty: true}
wufoo.getForms(optionalQuery, function(err, forms) {
console.log(forms[0].hash);
console.log(forms[0].name);
console.log(forms[0].description);
// do something here.
});
// get a specific form given the id and pass in optional query parameters
wufoo.getForm("idofForm", optionalQuery, function(err, forms) {
// do something here.
});
Convenience methods are provided to get entries, fields and entry count for a Form
:
form.getEntries(function(err, entries) {
// do something here.
});
form.getEntriesCount(function(err, count) {
// do something here.
console.log("There are " + count + " number of entries");
});
form.getFields(function(err, fields) {
// do something here.
});
// pass in optional query parameters
var optionalQuery = {pretty: true}
form.getEntries(optionalQuery, function(err, entries) {
// do something here.
});
form.getEntriesCount(optionalQuery, function(err, count) {
// do something here.
console.log("There are " + count + " number of entries");
});
form.getFields(optionalQuery, function(err, fields) {
// do something here.
});
Get all the entries for a form or report. getFormEntries
and getReportEntries
returns an array of Entry
objects.
wufoo.getFormEntries("formid", function(err, entries) {
// do something here.
});
wufoo.getReportEntries("reportid", function(err, entries) {
// do something here.
});
// pass in optional query parameters
var optionalQuery = {pretty: true}
wufoo.getFormEntries("formid", optionalQuery, function(err, entries) {
// do something here.
});
wufoo.getReportEntries("reportid", optionalQuery, function(err, entries) {
// do something here.
});
Get all the reports for an account. getReports
returns an array of Report
objects.
wufoo.getReports(function(err, reports) {
// do something here
});
// get a specific form given the id.
wufoo.getReport("idofReport", function(err, report){
// do something here.
});
// pass in optional query parameters
var optionalQuery = {pretty: true}
wufoo.getReports(optionalQuery, function(err, reports) {
// do something here
});
// get a specific form given the id.
wufoo.getReport("idofReport", optionalQuery, function(err, report){
// do something here.
});
Convenience methods are provided to get entries, fields and entry count for a Report:
report.getEntries(function(err, entries) {
// do something here.
});
report.getEntriesCount(function(err, count) {
// do something here.
console.log("There are " + count + " number of entries");
});
report.getFields(function(err, fields) {
// do something here.
});
// pass in optional query parameters
var optionalQuery = {pretty: true}
report.getEntries(optionalQuery, function(err, entries) {
// do something here.
});
report.getEntriesCount(optionalQuery, function(err, count) {
// do something here.
console.log("There are " + count + " number of entries");
});
report.getFields(optionalQuery, function(err, fields) {
// do something here.
});
Get all the reports for a form. getFields
returns an array of Field
objects.
wufoo.getFields("formid", function(err, fields) {
// do something here.
});
// pass in optional query parameters
var optionalQuery = {pretty: true}
wufoo.getFields("formid", optionalQuery, function(err, fields) {
// do something here.
});
Get all the widgets for a report. getWidgets
returns an array of Widget
objects.
wufoo.getWidgets("reportid", function(err, widgets) {
// do something here.
});
// pass in optional query parameters
var optionalQuery = {pretty: true}
wufoo.getWidgets("reportid", optionalQuery, function(err, widgets) {
// do something here.
});
Get all the comments for a form. getComments
returns an array of Comment
objects.
wufoo.getComments("formid", function(err, comments) {
// do something here.
});
// pass in optional query parameters
var optionalQuery = {pretty: true}
wufoo.getComments("formid", optionalQuery, function(err, comments) {
// do something here.
});
Alternatively if all you need is the amount of comments for a form you can call getCommentCount
:
wufoo.getCommentCount("formid", function(err, count) {
// do something here.
});
// pass in optional query parameters
var optionalQuery = {pretty: true}
wufoo.getCommentCount("formid", optionalQuery, function(err, count) {
// do something here.
});
Add a WebHook for a form:
wufoo.webhook().add("formid", "http://localhost:3000", function(err, hashid) {
// store the webhook hashid somewhere in case we want to delete them later.
})
// pass in optional options
var options = {url: "http://abc.com/webhook", handshakeKey: "hand-shaking", metadata: true}
wufoo.webhook().add("formid", options, function(err, hashid) {
// store the webhook hashid somewhere in case we want to delete them later.
db.put("WebHooks", {formid:form.hash, key:hashid});
})
Delete the WebHook. More info:
wufoo.webhook().delete("formid", "webhookHashId", function(err, success) {
if (!success) {
// do something.
}
})
Helper methods are also provided on the Form
object:
form.addWebhook("http://localhost:3000", function(err, hashid) {
// store the webhook hashid somewhere in case we want to delete them later.
})
form.deleteWebhook("webhookHashId", function(err, success) {
if (!success) {
// do something.
}
})
Every single API documented above have an alternate version that supports promises. For the preferred method of using promises or await/async instead of callbacks append Async
to the end of the function name. For example, the following are all valid:
from.addWebhookAsync
wufoo.getCommentCountAsync
wufoo.getWidgetsAsync
And so on. Calling wufoo.getCommentCountAsync
will be as follows:
wufoo.getCommentCount("formid")
.then ((count) => {
console.log(count);
})
.catch((err) => {
console.log(err);
});
Please fork it. Add new features or fix bugs and do a pull request. Tests should be included:
- Fork it
- Create your feature branch (
git checkout -b feature-new-stuff
). - Commit your changes (
git commit -am 'Added some feature'
). - Push to the branch (
git push origin feature-new-stuff
). - Create new Pull Request.
Be sure to have mocha installed. Run the entire test suite from the root directory of the project by running the command:
$ mocha
or
$ npm test
Node-Wufoo implements all of the Wufoo RESTful API except the following:
Implementation and support of the above will be included in future versions. Contributions welcome!