humanmade/Mercator-REST-API

Name: Mercator-REST-API

Owner: Human Made

Description: REST API for working with domain mappings

Created: 2016-09-23 16:48:16.0

Updated: 2016-11-30 20:08:12.0

Pushed: 2016-11-23 21:22:50.0

Homepage: null

Size: 28

Language: PHP

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Mercator REST API

REST API for working with domain mappings.

Requires WordPress 4.5+ or the WP REST API plugin

Usage

You need to include and instantiate the controller:

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

The controller adds two API routes:

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

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

json/mercator/v1/mappings?blog=1
Data structure

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


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

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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.