by Enrico Zimuel / @ezimuel
Senior Software Engineer - Zend Technologies
I'm a Software Engineer since 1996. I work in the Apigility and Zend Framework team at Zend Technologies. I did research in computer science at Informatics Institute of the University of Amsterdam. I'm the co-author of the Italian books "PHP best practices" and "Javascript best practices". I'm the co-founder of PUG Torino (Italy).
API stands for "Application Programming Interface" and as a term, specifies how software should interact.
Generally speaking, when we refer to APIs today, we are referring more specifically to web APIs, those delivered over HyperText Transfer Protocol (HTTP).
REpresentational State Transfer (REST) is not a specification, but an architecture designed around the HTTP specification.
REST leverages HTTP's strengths, and builds on:
When talking about REST, the Richardson Maturity Model is often used to describe the concerns necessary when implementing a well-designed REST API
Scalable architecture
Very easy to consume
Reduce client/server coupling
Discoverability
Can be difficult, especially at the beginning
http://domain/api/user[/:user_id]
{
"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York"
},
"emails" : [
'john.smith@gmail.com',
'john@smith.com'
]
}
GET /api/user/ezimuel
{
"_links": {
"self": {
"href": "http://domain/api/user/ezimuel"
}
}
"id": "ezimuel",
"name": "Enrico Zimuel"
}
{
"_links": {
"self": {
"href": "http://domain/api/user/ezimuel"
}
}
"id": "ezimuel",
"name": "Enrico Zimuel",
"_embedded": {
"contacts": [
{
"_links": {
"self": {
"href": "http://domain/api/user/mwop"
}
},
"id": "mwop",
"name": "Matthew Weier O'Phinney"
},
{
"_links": {
"self": {
"href": "http://domain/api/user/ralphschindler"
}
},
"id": "ralphschindler",
"name": "Ralph Schindler"
}
]
}
}
{
"_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": [
{
"_links": {
"self": {
"href": "http://domain/api/user/mwop"
}
},
"id": "mwop",
"name": "Matthew Weier O'Phinney"
},
{
"_links": {
"self": {
"href": "http://domain/api/user/mac_nibblet"
}
},
"id": "mac_nibblet",
"name": "Antoine Hedgecock"
},
{
"_links": {
"self": {
"href": "http://domain/api/user/spiffyjr"
}
},
"id": "spiffyjr",
"name": "Kyle Spraggs"
}
]
}
}
Content-Type: application/problem+json
{
"detail": "The GET method has not been defined for individual",
"status": 405,
"title": "Method Not Allowed",
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html"
}
Accept: application/hal+json, application/json
Agility uses two approaches:
v1
/userv1
+json Apigility supports three different authentication systems: HTTP Basic, HTTP Digest, and OAuth2
Super easy, just one command:
$ curl -sS https://apigility.org/install | php
Or, if you don't have CURL installed:
$ php -r "readfile('https://apigility.org/install');" | php
Open the browser to http://localhost:8888
Apigility in action!
Rank this talk on joind https://joind.in/11313
More information on apigility.org
Contact me: enrico [at] zend.com
Follow me: @ezimuel
This work is licensed under a
Creative Commons Attribution-ShareAlike 3.0 Unported License.
I used reveal.js to make this presentation.