{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/Co-Authors-Plus/issues/334","repository_url":"https://api.github.com/repos/Automattic/Co-Authors-Plus","labels_url":"https://api.github.com/repos/Automattic/Co-Authors-Plus/issues/334/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/Co-Authors-Plus/issues/334/comments","events_url":"https://api.github.com/repos/Automattic/Co-Authors-Plus/issues/334/events","html_url":"https://github.com/Automattic/Co-Authors-Plus/pull/334","id":134086663,"number":334,"title":"REST API Support","user":{"login":"hbarroso","id":473072,"avatar_url":"https://avatars.githubusercontent.com/u/473072?v=3","gravatar_id":"","url":"https://api.github.com/users/hbarroso","html_url":"https://github.com/hbarroso","followers_url":"https://api.github.com/users/hbarroso/followers","following_url":"https://api.github.com/users/hbarroso/following{/other_user}","gists_url":"https://api.github.com/users/hbarroso/gists{/gist_id}","starred_url":"https://api.github.com/users/hbarroso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hbarroso/subscriptions","organizations_url":"https://api.github.com/users/hbarroso/orgs","repos_url":"https://api.github.com/users/hbarroso/repos","events_url":"https://api.github.com/users/hbarroso/events{/privacy}","received_events_url":"https://api.github.com/users/hbarroso/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-16T20:18:41Z","updated_at":"2016-02-25T23:46:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Automattic/Co-Authors-Plus/pulls/334","html_url":"https://github.com/Automattic/Co-Authors-Plus/pull/334","diff_url":"https://github.com/Automattic/Co-Authors-Plus/pull/334.diff","patch_url":"https://github.com/Automattic/Co-Authors-Plus/pull/334.patch"},"body":"This PR will allows the Co-Authors-Plus plugin to serve REST services through the new WordPress 4.4 API feature.\r\n\r\nI currently found a few routes that I think will be great to make available.\r\n## Search \r\nThis routes allows searching for authors.\r\n\r\n### `POST`\r\n\r\n**URL** : `http://<domain>/wp-json/coauthors/v1/search`\r\n\r\n**Requires Authentication**: :lock:\r\n\r\n#### Parameters\r\n\r\nName | Type | Required | Description\r\n------------ | ------------- | ------------- | -------------\r\n`q` | String | :white_check_mark:  | Query parameter\r\n`existing_authors` | Array |  | Filters out existing authors by their username from the returned set.\r\n\r\n#### Request \r\n```\r\n{\r\n  \"q\": \"dummy\",\r\n  \"existing_authors\": [\"dummy\"]\r\n}\r\n```\r\n\r\n#### Response\r\n```\r\n{\r\n  \"authors\": [\r\n    {\r\n      \"id\": 3,\r\n      \"user_login\": \"dummy1\",\r\n      \"display_name\": \"Dummy\",\r\n      \"user_email\": \"dummy@gmail.com\",\r\n      \"user_nicename\": \"dummy1\"\r\n    },\r\n    {\r\n      \"id\": 4,\r\n      \"user_login\": \"dummy2\",\r\n      \"display_name\": \"dummy2\",\r\n      \"user_email\": \"dummy2@gmail.com\",\r\n      \"user_nicename\": \"dummy2\"\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\n\r\n## Post\r\n\r\nAdd, appends or remove a group of authors to an existing post.\r\n\r\n### `POST`\r\n\r\n**URL** : `http://<domain>/wp-json/coauthors/v1/post/<post_id>`\r\n\r\n**Requires Authentication**: :lock: \r\n\r\n#### Parameters\r\n\r\nName | Type | Required | Description\r\n------------ | ------------- | ------------- | -------------\r\n`coauthors` | Array | :white_check_mark:  | An array of authors usernames.\r\n`append` | Bool|  | If true appends the `coauthors` array to Post, if false overwrites existing coauthors.\r\n\r\n#### Request\r\n```\r\n{\r\n  \"coauthors\": [\"author1\", \"dummy\", \"johndoe\"],\r\n  \"append\": true\r\n}\r\n```\r\n\r\n#### Response\r\n```\r\n[\r\n  \"Post authors updated.\"\r\n]\r\n```\r\n\r\n### `DELETE`\r\n\r\n**URL** : `http://<domain>/wp-json/coauthors/v1/post/<post_id>`\r\n\r\n**Requires Authentication**: :lock: \r\n\r\n#### Parameters\r\n\r\nName | Type | Required | Description\r\n------------ | ------------- | ------------- | -------------\r\n`coauthors` | Array | :white_check_mark:  | An array of authors usernames.\r\n\r\n#### Request\r\n```\r\n{\r\n  \"coauthors\": [\"author1\", \"dummy\", \"johndoe\"]\r\n}\r\n```\r\n\r\n#### Response\r\n```\r\n[\r\n  \"Post authors deleted.\"\r\n]\r\n```\r\n\r\n\r\n### `GET`\r\n\r\n**URL** : `http://<domain>/wp-json/coauthors/v1/post/<post_id>`\r\n\r\n**Requires Authentication**: :lock: \r\n\r\n#### Response\r\n```\r\n{\r\n  \"authors\": [\r\n    {\r\n      \"id\": 3,\r\n      \"user_login\": \"dummy1\",\r\n      \"display_name\": \"Dummy\",\r\n      \"user_email\": \"dummy@gmail.com\",\r\n      \"user_nicename\": \"dummy1\"\r\n    },\r\n    {\r\n      \"id\": 4,\r\n      \"user_login\": \"dummy2\",\r\n      \"display_name\": \"dummy2\",\r\n      \"user_email\": \"dummy2@gmail.com\",\r\n      \"user_nicename\": \"dummy2\"\r\n    }\r\n  ]\r\n}\r\n```\r\n## Guest\r\n\r\nCreates, updates or removes a guest author.\r\n\r\n### `POST`\r\n\r\n**URL** : `http://<domain>/wp-json/coauthors/v1/guest`\r\n\r\n**Requires Authentication**: :lock: \r\n\r\n#### Parameters\r\n\r\nName | Type | Required | Description\r\n------------ | ------------- | ------------- | -------------\r\n`display_name` | String | :white_check_mark:  | Display name\r\n`user_login` | String  | :white_check_mark:  | User login, must be unique to guests.\r\n`user_email` | String  | :white_check_mark:  | User email\r\n`first_name` | String  | | First name\r\n`last_name` | String  | | Last name\r\n`linked_account` | String  | | Links the guest account to an existing account\r\n`website` | String  | | User website\r\n`aim` | String  | | AIM\r\n`yahooim` | String  | | Yahoo IM\r\n`jabber` | String  | | Jabber\r\n`Description` | String  | | A text Description\r\n\r\n#### Request\r\n```\r\n{\r\n    \"display_name\": \"foo\",\r\n    \"user_login\": \"foobar\",\r\n    \"user_email\": \"foobar@gmail.com\",\r\n    \"first_name\": \"Foo\",\r\n    \"last_name\": \"Bar\",\r\n    \"website\" : \"http://www.foobar.org/\",\r\n    \"aim\": \"testaim\",\r\n    \"yahooim\": \"testyaho2\",\r\n    \"jabber\": \"testjabber\",\r\n    \"description\": \"Some simple description.\"\r\n}\r\n```\r\n\r\n#### Response\r\n```\r\n[\r\n  {\r\n    \"ID\": \"172\",\r\n    \"display_name\": \"foo\",\r\n    \"first_name\": \"Foo\",\r\n    \"last_name\": \"Bar\",\r\n    \"user_login\": \"foobar\",\r\n    \"user_email\": \"foobar@gmail.com\",\r\n    \"linked_account\": \"\",\r\n    \"website\": \"http://www.foobar.org/\",\r\n    \"aim\": \"testaim\",\r\n    \"yahooim\": \"testyaho2\",\r\n    \"jabber\": \"testjabber\",\r\n    \"description\": \"Some simple description.\",\r\n    \"user_nicename\": \"foobar\",\r\n    \"type\": \"guest-author\"\r\n  }\r\n]\r\n```\r\n\r\n### `PUT`\r\n\r\n**URL** : `http://<domain>/wp-json/coauthors/v1/guest/<guest_id>`\r\n\r\n**Requires Authentication**: :lock: \r\n\r\n#### Parameters\r\n\r\nName | Type | Required | Description\r\n------------ | ------------- | ------------- | -------------\r\n`display_name` | String |   | Display name\r\n`user_email` | String  | | User email\r\n`first_name` | String  | | First name\r\n`last_name` | String  | | Last name\r\n`linked_account` | String  | | Links the guest account to an existing account\r\n`website` | String  | | User website\r\n`aim` | String  | | AIM\r\n`yahooim` | String  | | Yahoo IM\r\n`jabber` | String  | | Jabber\r\n`Description` | String  | | A text Description\r\n\r\n#### Request\r\n```\r\n{\r\n    \"first_name\": \"John\",\r\n    \"description\": \"New description.\"\r\n}\r\n```\r\n\r\n#### Response\r\n```\r\n[\r\n  {\r\n    \"ID\": \"172\",\r\n    \"display_name\": \"foo\",\r\n    \"first_name\": \"John\",\r\n    \"last_name\": \"Bar\",\r\n    \"user_login\": \"foobar\",\r\n    \"user_email\": \"foobar@gmail.com\",\r\n    \"linked_account\": \"\",\r\n    \"website\": \"http://www.foobar.org/\",\r\n    \"aim\": \"testaim\",\r\n    \"yahooim\": \"testyaho2\",\r\n    \"jabber\": \"testjabber\",\r\n    \"description\": \"New description.\",\r\n    \"user_nicename\": \"foobar\",\r\n    \"type\": \"guest-author\"\r\n  }\r\n]\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Automattic/Co-Authors-Plus/issues/comments/189037733","html_url":"https://github.com/Automattic/Co-Authors-Plus/pull/334#issuecomment-189037733","issue_url":"https://api.github.com/repos/Automattic/Co-Authors-Plus/issues/334","id":189037733,"user":{"login":"mdawaffe","id":125994,"avatar_url":"https://avatars.githubusercontent.com/u/125994?v=3","gravatar_id":"","url":"https://api.github.com/users/mdawaffe","html_url":"https://github.com/mdawaffe","followers_url":"https://api.github.com/users/mdawaffe/followers","following_url":"https://api.github.com/users/mdawaffe/following{/other_user}","gists_url":"https://api.github.com/users/mdawaffe/gists{/gist_id}","starred_url":"https://api.github.com/users/mdawaffe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdawaffe/subscriptions","organizations_url":"https://api.github.com/users/mdawaffe/orgs","repos_url":"https://api.github.com/users/mdawaffe/repos","events_url":"https://api.github.com/users/mdawaffe/events{/privacy}","received_events_url":"https://api.github.com/users/mdawaffe/received_events","type":"User","site_admin":false},"created_at":"2016-02-25T23:46:31Z","updated_at":"2016-02-25T23:46:31Z","body":"Search Endpoint:\r\n\r\nWhy is this a POST request? A sort of similar WP-API request (listing posts by an author) is a GET:\r\n`GET /wp-json/wp/v2/posts?author={author_id}`\r\n\r\nWhat does `existing_authors` mean? Don't I want to search for existing authors?"}}