The Easy Plugin Demo REST API is included with the EPD Premium Pack extension and enables the creation of demo sites via the WordPress REST API system.
With the EPD REST API, it is possible to create demo sites remotely in a couple of ways. You can either incorporate the REST API into your own code/system, or you can use the EPD Remote extension (included with the EPD Premium Pack).
We’ll cover the usage of the REST API with the Remote EPD extension in this article. For more detailed information on the structure of EPD REST API requests and responses, you can review the article Rest API Requests and Responses.
Benefits of Using the REST API
The REST API enables requests for new demo sites to be sent remotely from any source. The request is then processed and a confirmation (or error) response is returned. This enables tools such as EPD Remote to process requests for a demo site without the need for a user to be redirected.
Without the REST API being enabled, when a user clicks on a button to access a demo, EPD Remote simply redirects them to a registration form hosted on the WordPress multisite instance where you have Easy Plugin Demo installed. From there, the user completes the form and their demo request is processed. With the REST API enabled, the entire process is handled on the site where you have EPD Remote installed. No user redirection takes place resulting in a much cleaner and friendly end-user experience.
The REST API also enables automation so that tools and systems, such as Zapier, can automatically generate demo requests.
When utilising the REST API, all of the rules regarding creation of a demo site still apply. For example, required fields must be included within the request, the maximum number of sites a user is allowed to register still applies, and if you have email addresses banned from creating demo sites, their request will fail.
Configuring the EPD REST API
Once the Premium Pack extension is installed, the REST API is disabled by default. To enable it, open the network admin screen of the multisite on which you have Easy Plugin Demo installed and:
- Browse to Settings -> Easy Plugin Demo
- Click the Premium Features tab and if necessary, the REST API section
- Check the box to Enable Remote Registration. Once you click Save Changes the EPD REST API will be available for use
Before you can utilise the REST API, you need to complete some additional configuration items to ensure that requests are authenticated correctly.
Authenticating with the EPD REST API
For REST API requests to be processed, EPD must authenticate. We do this by using secret keys. The EPD Premium Extension will generate a secret key which will need to be entered into any system attempting an API connection. The remote system should also have a unique secret key which needs to be entered into the REST API settings within the EPD Premium Pack:
- Enter the remote systems secret key within the EPD Remote Secret Key setting option. If your remote system is EPD Remote, you can obtain this secret via the EPD Remote settings screen on the site where you have EPD Remote installed. If using any other system, you can generate your own key so long as it is used within the API request and matches the key entered into this field
- Next, click the Reveal Secret button next to the REST API Secret Key setting option to reveal the REST API secret for EPD Premium. This secret key needs to be included in any request being received. If you are using EPD Remote, you should enter this key within the EPD Remote settings against the EPD Premium Secret Key setting option.
- Once you are done, click to Save Changes
The EPD REST API is now ready for use. For details on how to configure EPD Remote to use the REST API, please refer to this support article.