The Gravity Form REST API v2 for JavaScript, available for Node.js backends
The preferred way to install the Gravity Form REST API v2 for Node.js is to use the npm package manager for Node.js. Simply type the following into a terminal window:
npm install gravity-form-rest-api
Then within your application, you can reference to the SDK with the following:
require('gravity-form-rest-api');
const GFormAPI = require('gravity-form-rest-api');
const GForm = new GFormAPI(API_BASE_URL, API_KEY, API_SECRET_KEY);
function callback(err, res, body) {
if (err) throw new Error(err);
console.log(body);
}
GForm.getEntries(YOUR_FORM_ID, null, callback);
GForm.getEntries(YOUR_FORM_ID, YOUR_ENTRY_ID, callback);
const example_entry_fields = {
form_id: YOUR_FORM_ID,
date_created: '2020-04-30 12:08:23',
source_url: 'https://domain.local',
'1': '',
'2': 'Foo',
'3': 'Bar',
'4': '1234567890',
'5': '[email protected]',
};
GForm.addEntry(example_entry_fields, callback);
const example_entry_fields = {
form_id: YOUR_FORM_ID,
date_created: '2020-04-30 12:08:23',
source_url: 'https://domain.local',
'1': '',
'2': 'Foo',
'3': 'Bar',
'4': '1234567890',
'5': '[email protected]',
};
GForm.updateEntry(YOUR_ENTRY_ID, example_entry_fields, callback);
GForm.deleteEntry(YOUR_ENTRY_ID, callback);
GForm.sendNotifications(YOUR_ENTRY_ID, callback);