REST API endpoint for Mercator.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 24

Forks: 2

Open Issues: 4


dev-master 2018-12-04 17:13 UTC

This package is auto-updated.

Last update: 2024-05-05 06:06:27 UTC


REST API for working with domain mappings.

Requires WordPress 4.5+ or the WP REST API plugin


You need to include and instantiate the controller:

add_action( 'rest_api_init', function() {
    include 'class-rest-api.php';
    $api = new Mercator\REST_API;
} );

The controller adds two API routes:

/wp-json/mercator/v1/mappings       // accepts GET, POST
/wp-json/mercator/v1/mappings/:id   // accepts PUT, PATCH, DELETE

You can additionally specify a blog ID by passing in a GET parameter:


Data structure

Mappings are very simple. The example JSON object for a mapping is as follows:

    "id": 1                       // integer
    "domain": "",      // string
    "active": true                // boolean

When creating a mapping using POST you only need to send the domain and active values.