@designcontainer/dc-wpe-js-api
v1.2.2
Published
A javascript wrapper for the WPE Api
Downloads
4
Keywords
Readme
JavaScript wrapper for the WP Engine API
A simple JavaScript wrapper for getting data from your WP Engine installs using their API.
Installing
$ npm install @designcontainer/dc-wpe-js-api
Import
import WpeApi from '@designcontainer/dc-wpe-js-api';
Initialize constructor
Params
user
{String}: The WP Engine API User.pass
{String}: The WP Engine API Password/key.
You should put these variables in a .ENV file!
const wpe = new WpeApi(user, pass);
API
.id
Get WP Engine install ID by name
.
Params
name
{String}: The WP Engine install Name.returns
{String}: Returns the WP Engine install ID.
Example
wpe.id(name);
.name
Get WP Engine install name by id
.
Params
id
{String}: The WP Engine install ID.returns
{String}: Returns the WP Engine install name.
Example
wpe.name(id);
.domains
Get WP Engine install domains by id
.
Params
id
{String}: The WP Engine install ID.returns
{Array}: Returns the WP Engine install domains.
Example
wpe.domains(id);
.phpVersion
Get the PHP version of the WP Engine install by id
.
Params
id
{String}: The WP Engine install ID.returns
{String}: Returns the PHP version of the WP Engine install.
Example
wpe.phpVersion(id);
.status
Get the status of the WP Engine install by id
.
Params
id
{String}: The WP Engine install ID.returns
{String}: Returns the status of the WP Engine install.
Example
wpe.status(id);
.cname
Get the CNAME of the WP Engine install by id
.
Params
id
{String}: The WP Engine install ID.returns
{String}: Returns the CNAME of the WP Engine install.
Example
wpe.cname(id);
.environment
Get the WP Engine install environment by id
.
Params
id
{String}: The WP Engine install ID.returns
{String}: Returns the WP Engine install environment.
Example
wpe.environment(id);
.primaryDomain
Get WP Engine primary install domain by id
.
Params
id
{String}: The WP Engine install ID.returns
{String}: Returns the WP Engine install primary domain.
Example
wpe.primaryDomain(id);
.isMultisite
Check if WP Engine install is a multisite environment by id
.
Params
id
{String}: The WP Engine install ID.returns
{Boolean}: Returns boolean true/false depending on if install is a multisite environment.
Example
wpe.isMultisite(id);
.newBackup
Creates a new WP Engine Backup by id
.
Params
id
{String}: The WP Engine install ID.description
{String}: Backup description.notification_emails
{Array}: Backup notification email addresses.returns
{Boolean}: Returns backup response. Example
wpe.newBackup(id, description, notification_emails);
.getWpeApi
Get custom WP Engine data.
Params
...args
{Any}: Api arguments. Docs: https://wpengineapi.com.returns
{Object}: Returns api data.
Examples
wpe.getWpeApi('installs', { limit: 10 })
.then((res) => {
console.log(res);
})
.catch((err) => console.error(`Error: ${err}`));
wpe.getWpeApi('installs', id, 'domains')
.then((res) => {
console.log(res);
})
.catch((err) => console.error(`Error: ${err}`));
.postWpeApi
Post custom WP Engine data.
Params
...args
{Any}: Api arguments. Docs: https://wpengineapi.com.returns
{Object}: Returns api response.
Examples
wpe.postWpeApi('installs', id, 'backups', {
description,
notification_emails,
})
.then((res) => {
console.log(res);
})
.catch((err) => console.error(`Error: ${err}`));