Matthew Weier O'Phinney@mwop 21 October 2015
How software should interact.
APIs delivered over HyperText Transfer Protocol (HTTP)
An architecture designed around the HTTP specification.
Defined in terms of the Richardson Maturity Model:
Linking between resources to indicate relationships (hypermedia controls)
GET /api/user/mwop
{
	"_links": {
		"self": {
			"href": "http://domain/api/user/mwop"
		},
		"contacts": [
			{ "href": "http://domain/api/user/andi" },
			{ "href": "http://domain/api/user/zeevs" }
		]
	},
	"id": "mwop",
	"name": "Matthew Weier O'Phinney"
}
            JSON-HAL format
REST is characterized by:
Hypermedia As The Engine Of Application State
header('Content-Type: application/json');
echo json_encode([
	'id'   => 'mwop',
	'name' => 'Matthew Weier O\'Phinney'
]);
            Quite simple, right?
What about:
GET /api/user/mwop
{
  "_links": {
    "self": {
      "href": "http://domain/api/user/mwop"
    }
  }
  "id": "mwop",
  "name": "Matthew Weier O'Phinney"
}
            {
  "_embedded": {
    "contacts": [
      {
        "_links": {
          "self": {
            "href": "http://domain/api/user/zeevs"
          }
        },
        "id": "zeevs",
        "name": "Zeev Suraski"
      }
    ]
  }
}
				{
    "_links": {
        "self": {
            "href": "http://domain/api/user?page=3"
        },
        "first": {
            "href": "http://domain/api/user"
        },
        "prev": {
            "href": "http://domain/api/user?page=2"
        },
        "next": {
            "href": "http://domain/api/user?page=4"
        },
        "last": {
            "href": "http://domain/api/user?page=133"
        }
    }
    "count": 3,
    "total": 498,
    "_embedded": {
        "users": [ /* ... */ ]
    }
}
				AKA API Problem
HTTP/1.1 405 Method Not Allowed
Content-Type: application/problem+json
{
    "detail": "The GET method has not been defined for entities",
    "status": 405,
    "title": "Method Not Allowed",
    "type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}
            Accept: application/hal+json, application/json
Content-Type: application/vnd.conference+json
Content-Type: application/hal+json(hopefully one the client accepts!)
Agility uses three approaches:
/v1/api/user
Accept: application/vnd.example.v1+json
namespace Conference\V1\Rest\Speaker
Apigility officially supports three authentication systems:
Web-based installer:
$ curl -sS https://apigility.org/install | php
Or, if you don't have CURL installed:
$ php -r "readfile('https://apigility.org/install');" | php
          Or just use Composer!
$ composer create-project zfcampus/zf-apigility-skeleton apigility
Open the browser to http://localhost:8888
Rate this talk: https://joind.in/15564
More information on apigility.org