SlideShare une entreprise Scribd logo
1  sur  45
working towards

RESTful Web Services

Friday, November 8, 13
GET /presenter/jessica
{
“name” : “Jessica Zehavi”,
“title” : “Software Engineer”,
“job” : {
“company” : “Clockwork Active Media”,
“href” : “http://www.clockwork.net”
},
“contacts” : {
“email” : “jessica@clockwork.net”,
“twitter” : “@yiska”,
“github” : “github.com/yiska”,
}
}

Friday, November 8, 13
API?

Friday, November 8, 13
standards
Friday, November 8, 13
???
Friday, November 8, 13
working towards

RESTful Web Services

Friday, November 8, 13
turns out, it’s kind of hard

Friday, November 8, 13
“A RESTful web service is an API
implemented using HTTP and
REST design principles.”
- Wikipedia (edited by me)

Friday, November 8, 13
Friday, November 8, 13
• Identification of resources

Friday, November 8, 13
• Identification of resources
• Manipulation of resources through
these representations

Friday, November 8, 13
• Identification of resources
• Manipulation of resources through
these representations

• Self-descriptive messaging

Friday, November 8, 13
• Identification of resources
• Manipulation of resources through
these representations

• Self-descriptive messaging
• Hypermedia as the engine of

application state (HATEOAS)

Friday, November 8, 13
Identification of Resources

Friday, November 8, 13
Identification of Resources
• Resources can be anything!

Friday, November 8, 13
Identification of Resources
• Resources can be anything!
• URLs identify resources
http://www.example.com/projects/
http://www.example.com/projects/1
http://www.example.com/deliverables/42

Friday, November 8, 13
Identification of Resources
• Resources can be anything!
• URLs identify resources
http://www.example.com/projects/
http://www.example.com/projects/1
http://www.example.com/deliverables/42

• The representation describes the
resource’s state

Friday, November 8, 13
Manipulation of Resources through
Representations
Project Represented in JSON
{
	
	
	
	
	
	
	
	
	
}

Friday, November 8, 13

"id" : 1,
"name" : "Focus Media Group Project",
"start_date" : "2013-01-01",
"end_date" : "2014-06-31",
"status" : "complete",
"deliverables" : [ 1, 2, 3 ],
"departments" : [ 3, 8, 14 ],
"created_on" : "2013-09-20"
"modified_on" : "2013-10-01"
Manipulation of Resources through
Representations
Project Represented in XML
<?xml version="1.0" encoding="UTF-8"?>
<project>
	
<id>1</id>
	
<name>Focus Media Group Project</name>
	
<start_date>2013-01-01</start_date>
	
<end_date>2013-01-01</end_date>
	
<status>complete</status>
	
<deliverables>
	
	
<item>1</item>
	
	
<item>2</item>
	
	
<item>3</item>
	
</deliverables>
	
<departments>
	
	
<item>1</item>
	
	
<item>2</item>
	
	
<item>3</item>
	
</departments>
	
<created_on>2013-09-20</created_on>
	
<modified_on>2013-10-01</modified_on>
</project>

Friday, November 8, 13
Self Descriptive Messaging

Operation

HTTP

Create

INSERT

POST

Read

SELECT

GET

Update

UPDATE

PUT

Delete

Friday, November 8, 13

Database

DELETE

DELETE
Create / POST

Create a New Project

Response

POST /projects/ HTTP/1.1

HTTP/1.1 201 Created
Content-Type: application/json

{
	
	
	
	
	
	
}

"name" : "Museum Site Redesign",
"start_date" : "2013-10-01",
"end_date" : "2014-01-31",
"status" : "new",
"deliverables" : [ 4, 5, 6 ],
"departments" : [ 2, 8, 11 ]

Friday, November 8, 13

{
	
	
	
	
	
	
	
	
	
}

"id" : 1,
"name" : "Museum Site Redesign",
"start_date" : "2013-10-01",
"end_date" : "2014-01-31",
"status" : "new",
"deliverables" : [ 4, 5, 6 ],
"departments" : [ 2, 8, 11 ],
"created_on" : "2013-09-20",
"modified_on" : "2013-09-20"
Read / GET

Request a Resource

Response

GET /projects/1 HTTP/1.1

HTTP/1.1 200 OK
Content-Type: application/json
{
	
	
	
	
	
	
	

"id" : 1,
"name" : "Museum Site Redesign",
"start_date" : "2013-10-01",
"end_date" : "2014-01-31",
"status" : "new",
"deliverables" : [ 4, 5, 6 ],
"departments" : [ 2, 8, 11 ],

	
	

"created_on" : "2013-09-20",
"modified_on" : "2013-09-20"

}

Friday, November 8, 13
Update / PUT

Update a Resource
PUT /projects/1 HTTP/1.1
{
	
	
}

Friday, November 8, 13

"start_date" : "2013-11-01",
"end_date" : "2014-02-28",

Response
HTTP/1.1 200 OK
Content-Type: application/json
{
	
	
	
	
	
	
	
}

"id" : 1,
"name" : "Museum Site Redesign",
"start_date" : "2013-10-01",
"end_date" : "2014-02-28",
"status" : "new",
"deliverables" : [ 4, 5, 6 ],
"departments" : [ 2, 8, 11 ]
Delete / DELETE

Delete a Resource

Response

DELETE /projects/1 HTTP/1.1

HTTP/1.1 204 No Content

Friday, November 8, 13
Hypermedia as the Engine of
Application State

?
Friday, November 8, 13
HATEOAS!
Friday, November 8, 13
You Know This
“The principle of connectedness: each web page
tells you how to get to the adjoining pages. The
Web as a whole works on the principle of
connectedness, which is better known as
‘hypermedia as the engine of application state,’
sometimes abbreviated HATEOAS.”
- Leonard Richardson & Mike Amundsen
RESTful Web APIs

Friday, November 8, 13
Hypermedia!
GET /projects/1 HTTP/1.1
Response
HTTP/1.1 200 OK
Content-Type: application/json
{
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}

Friday, November 8, 13

"href" : "http://www.example.com/projects/1",
"id" : 1,
"name" : "Museum Site Redesign",
"start_date" : "2013-10-01",
"end_date" : "2014-01-31",
"status" : "new",
"deliverables" : {
	
"href" : "http://www.example.com/deliverables",
	
"items" : [ 4, 5, 6 ]
},
"departments" : {
	
"href" : "http://www.example.com/departments",
	
"items" : [ 3, 8, 14 ]
},
"created_on" : "2013-09-20",
"modified_on" : "2013-09-20"
Common Mistakes

• Ignore hypermedia
• Using the wrong HTTP method
• Return the wrong response codes

Friday, November 8, 13
Friday, November 8, 13
NO
Friday, November 8, 13
APIs for Public Consumption

• Follow accepted standards/practices
• Consume your own API
• Versioning?

Friday, November 8, 13
Implementation

• Resources
• Relationships
• Endpoints

Friday, November 8, 13
Project Viz Application
• Tracks projects, resources and phases
• Complex and evolving requirements
• Wanted to host it themselves
• Super fast deadline!

Friday, November 8, 13
// Get all projects
Route::get( 'projects', function( )
{
$projects
= Project::all( );
return Response::json( $projects );
});
// Get a project by id
Route::get( 'projects/{id}', function( $id )
{
$project = Project::find( $id );
if ( ! $project ) {
App::abort( 404 );
}
return Response::json( $project );
} )->where( 'id', 'd+' );

Friday, November 8, 13
Response
HTTP/1.1 200 OK
Content-Type: application/json
{
	
	
	
	
	
	
	
	
	
}

Friday, November 8, 13

"id" : 1,
"name" : "Museum Site Redesign",
"start_date" : "2013-10-01",
"end_date" : "2014-01-31",
"status" : "new",
"deliverables" : [ 4, 5, 6 ],
"departments" : [ 2, 8, 11 ],
"created_on" : "2013-09-20",
"modified_on" : "2013-09-20"
// Create new project
Route::post( 'projects', function( )
{
$project = new Project( Input::get( ) );
$project->validate( );
if ( ! $project->save() )
{
App::abort( 500 );
}
return Response::json( $project, 201 );
});

Friday, November 8, 13
Response
HTTP/1.1 201 Created
Content-Type: application/json
{
	
	
	
	
	
	
	
	
	
}

Friday, November 8, 13

"id" : 1,
"name" : "Museum Site Redesign",
"start_date" : "2013-10-01",
"end_date" : "2014-01-31",
"status" : "new",
"deliverables" : [ 4, 5, 6 ],
"departments" : [ 2, 8, 11 ],
"created_on" : "2013-09-20",
"modified_on" : "2013-09-20"
// Update project by id
Route::put('projects/{id}', function( $id )
{
$project = Project::find( $id );
$project->fill( Input::get( ) );
$project->validate( );
if ( ! $project->save( ) )
{
App::abort( 500 );
}
return Response::json( $project );
})->where( 'id', 'd+' );

Friday, November 8, 13
Send
{ "end_date" : "2013-12-31", status : "active" }
Response
HTTP/1.1 200 OK
Content-Type: application/json
{
	
	
	
	
	
	
	
	
	
}

Friday, November 8, 13

"id" : 1,
"name" : "Museum Site Redesign",
"start_date" : "2013-10-01",
"end_date" : "2013-12-31",
"status" : "active",
"deliverables" : [ 4, 5, 6 ],
"departments" : [ 2, 8, 11 ],
"created_on" : "2013-09-20",
"modified_on" : "2013-10-26"
// Delete a project by id
Route::delete( 'projects/{id}', function( $id )
{
$project = Project::find( $id );
$project->delete( );
return Response::json( null, 204 );
})->where( 'id', 'd+' );

Response
HTTP/1.1 204 No Content

Friday, November 8, 13
Do These Things

• Try to be RESTful
• Consume your own APIs if possible
• Write Unit Tests

Friday, November 8, 13
Future!
• Rate limiting
• Authentication
• Hypermedia
• Versioning

Friday, November 8, 13
?

Friday, November 8, 13
kthxbye

Friday, November 8, 13

Contenu connexe

Tendances

Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology updateDoug Domeny
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and ModernizrJussi Pohjolainen
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterpriseDave Artz
 
Getting Started with Combine And SwiftUI
Getting Started with Combine And SwiftUIGetting Started with Combine And SwiftUI
Getting Started with Combine And SwiftUIScott Gardner
 
JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)jeresig
 
Building Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraBuilding Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraMarkus Lanthaler
 
JSON-LD: Linked Data for Web Apps
JSON-LD: Linked Data for Web AppsJSON-LD: Linked Data for Web Apps
JSON-LD: Linked Data for Web AppsGregg Kellogg
 
Unlock the next era of UI design with Polymer
Unlock the next era of UI design with PolymerUnlock the next era of UI design with Polymer
Unlock the next era of UI design with PolymerRob Dodson
 
REST teori og praksis; REST in theory and practice
REST teori og praksis; REST in theory and practiceREST teori og praksis; REST in theory and practice
REST teori og praksis; REST in theory and practicehamnis
 
SwiftUI and Combine All the Things
SwiftUI and Combine All the ThingsSwiftUI and Combine All the Things
SwiftUI and Combine All the ThingsScott Gardner
 
Full-on Hypermedia APIs with Hydra
Full-on Hypermedia APIs with HydraFull-on Hypermedia APIs with Hydra
Full-on Hypermedia APIs with HydraMarkus Lanthaler
 

Tendances (17)

Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
Mobile Oslo 2012 okt
Mobile Oslo 2012 oktMobile Oslo 2012 okt
Mobile Oslo 2012 okt
 
Spout
SpoutSpout
Spout
 
Beyond the page
Beyond the pageBeyond the page
Beyond the page
 
JQuery
JQueryJQuery
JQuery
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and Modernizr
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
 
Etoy proyecto
Etoy proyectoEtoy proyecto
Etoy proyecto
 
Getting Started with Combine And SwiftUI
Getting Started with Combine And SwiftUIGetting Started with Combine And SwiftUI
Getting Started with Combine And SwiftUI
 
JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)JavaScript Libraries (Kings of Code)
JavaScript Libraries (Kings of Code)
 
Building Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and HydraBuilding Next-Generation Web APIs with JSON-LD and Hydra
Building Next-Generation Web APIs with JSON-LD and Hydra
 
JSON-LD: Linked Data for Web Apps
JSON-LD: Linked Data for Web AppsJSON-LD: Linked Data for Web Apps
JSON-LD: Linked Data for Web Apps
 
Unlock the next era of UI design with Polymer
Unlock the next era of UI design with PolymerUnlock the next era of UI design with Polymer
Unlock the next era of UI design with Polymer
 
REST teori og praksis; REST in theory and practice
REST teori og praksis; REST in theory and practiceREST teori og praksis; REST in theory and practice
REST teori og praksis; REST in theory and practice
 
SwiftUI and Combine All the Things
SwiftUI and Combine All the ThingsSwiftUI and Combine All the Things
SwiftUI and Combine All the Things
 
Full-on Hypermedia APIs with Hydra
Full-on Hypermedia APIs with HydraFull-on Hypermedia APIs with Hydra
Full-on Hypermedia APIs with Hydra
 

En vedette

Dollar bersama Perfect APP!
Dollar bersama Perfect APP!Dollar bersama Perfect APP!
Dollar bersama Perfect APP!smsPerfectApp
 
The need to understand variation in healthcare population healthcare online...
The need to understand variation in healthcare   population healthcare online...The need to understand variation in healthcare   population healthcare online...
The need to understand variation in healthcare population healthcare online...rightcare
 
Apimec presentation 03-31-2009
Apimec presentation   03-31-2009Apimec presentation   03-31-2009
Apimec presentation 03-31-2009AES Tietê
 
Section 3 chapter 21 - financial management - teaching aid
Section 3   chapter 21 - financial management - teaching aidSection 3   chapter 21 - financial management - teaching aid
Section 3 chapter 21 - financial management - teaching aidAmit Fogla
 

En vedette (7)

Retail
RetailRetail
Retail
 
Dollar bersama Perfect APP!
Dollar bersama Perfect APP!Dollar bersama Perfect APP!
Dollar bersama Perfect APP!
 
The need to understand variation in healthcare population healthcare online...
The need to understand variation in healthcare   population healthcare online...The need to understand variation in healthcare   population healthcare online...
The need to understand variation in healthcare population healthcare online...
 
Apimec presentation 03-31-2009
Apimec presentation   03-31-2009Apimec presentation   03-31-2009
Apimec presentation 03-31-2009
 
Erp overview
Erp overviewErp overview
Erp overview
 
Section 3 chapter 21 - financial management - teaching aid
Section 3   chapter 21 - financial management - teaching aidSection 3   chapter 21 - financial management - teaching aid
Section 3 chapter 21 - financial management - teaching aid
 
Ppt01
Ppt01Ppt01
Ppt01
 

Similaire à Working Towards RESTful Web Servies

Lone StarPHP 2013 - Building Web Apps from a New Angle
Lone StarPHP 2013 - Building Web Apps from a New AngleLone StarPHP 2013 - Building Web Apps from a New Angle
Lone StarPHP 2013 - Building Web Apps from a New AnglePablo Godel
 
Tek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSTek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSPablo Godel
 
John Arne Sæterås - Search on Mobile
John Arne Sæterås - Search on MobileJohn Arne Sæterås - Search on Mobile
John Arne Sæterås - Search on MobileMobile Oslo
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Startedguest1af57e
 
Hotcode 2013: Javascript in a database (Part 2)
Hotcode 2013: Javascript in a database (Part 2)Hotcode 2013: Javascript in a database (Part 2)
Hotcode 2013: Javascript in a database (Part 2)ArangoDB Database
 
Google App Engine with Gaelyk
Google App Engine with GaelykGoogle App Engine with Gaelyk
Google App Engine with GaelykChoong Ping Teo
 
BACKBONE.JS & UNDERSCORE.JS
BACKBONE.JS & UNDERSCORE.JSBACKBONE.JS & UNDERSCORE.JS
BACKBONE.JS & UNDERSCORE.JSDesignveloper
 
Performance & Responsive Web Design
Performance & Responsive Web DesignPerformance & Responsive Web Design
Performance & Responsive Web DesignZach Leatherman
 
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...Codemotion
 
NoSQL Now 2013 Presentation
NoSQL Now 2013 PresentationNoSQL Now 2013 Presentation
NoSQL Now 2013 PresentationArjen Schoneveld
 
Prototyping applications with heroku and elasticsearch
 Prototyping applications with heroku and elasticsearch Prototyping applications with heroku and elasticsearch
Prototyping applications with heroku and elasticsearchprotofy
 
Angular directive filter and routing
Angular directive filter and routingAngular directive filter and routing
Angular directive filter and routingjagriti srivastava
 
ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!
ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!
ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!Serdar Basegmez
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchAppsBradley Holt
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETJames Johnson
 
SAPS - Semantic AtomPub-based Services
SAPS - Semantic AtomPub-based ServicesSAPS - Semantic AtomPub-based Services
SAPS - Semantic AtomPub-based ServicesMarkus Lanthaler
 
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17GreeceJS
 
Parse Apps with Ember.js
Parse Apps with Ember.jsParse Apps with Ember.js
Parse Apps with Ember.jsMatthew Beale
 

Similaire à Working Towards RESTful Web Servies (20)

Lone StarPHP 2013 - Building Web Apps from a New Angle
Lone StarPHP 2013 - Building Web Apps from a New AngleLone StarPHP 2013 - Building Web Apps from a New Angle
Lone StarPHP 2013 - Building Web Apps from a New Angle
 
Tek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJSTek 2013 - Building Web Apps from a New Angle with AngularJS
Tek 2013 - Building Web Apps from a New Angle with AngularJS
 
John Arne Sæterås - Search on Mobile
John Arne Sæterås - Search on MobileJohn Arne Sæterås - Search on Mobile
John Arne Sæterås - Search on Mobile
 
The Big Picture and How to Get Started
The Big Picture and How to Get StartedThe Big Picture and How to Get Started
The Big Picture and How to Get Started
 
Hotcode 2013: Javascript in a database (Part 2)
Hotcode 2013: Javascript in a database (Part 2)Hotcode 2013: Javascript in a database (Part 2)
Hotcode 2013: Javascript in a database (Part 2)
 
Google App Engine with Gaelyk
Google App Engine with GaelykGoogle App Engine with Gaelyk
Google App Engine with Gaelyk
 
BACKBONE.JS & UNDERSCORE.JS
BACKBONE.JS & UNDERSCORE.JSBACKBONE.JS & UNDERSCORE.JS
BACKBONE.JS & UNDERSCORE.JS
 
Performance & Responsive Web Design
Performance & Responsive Web DesignPerformance & Responsive Web Design
Performance & Responsive Web Design
 
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK -  Nicola Iarocci - Co...
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
 
NoSQL Now 2013 Presentation
NoSQL Now 2013 PresentationNoSQL Now 2013 Presentation
NoSQL Now 2013 Presentation
 
Prototyping applications with heroku and elasticsearch
 Prototyping applications with heroku and elasticsearch Prototyping applications with heroku and elasticsearch
Prototyping applications with heroku and elasticsearch
 
Angular directive filter and routing
Angular directive filter and routingAngular directive filter and routing
Angular directive filter and routing
 
ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!
ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!
ICONUK 2016: REST Assured, Freeing Your Domino Data Has Never Been That Easy!
 
OSCON 2011 CouchApps
OSCON 2011 CouchAppsOSCON 2011 CouchApps
OSCON 2011 CouchApps
 
A Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NETA Rich Web Experience with jQuery, Ajax and .NET
A Rich Web Experience with jQuery, Ajax and .NET
 
Backbone
BackboneBackbone
Backbone
 
SAPS - Semantic AtomPub-based Services
SAPS - Semantic AtomPub-based ServicesSAPS - Semantic AtomPub-based Services
SAPS - Semantic AtomPub-based Services
 
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
 
Google Polymer Framework
Google Polymer FrameworkGoogle Polymer Framework
Google Polymer Framework
 
Parse Apps with Ember.js
Parse Apps with Ember.jsParse Apps with Ember.js
Parse Apps with Ember.js
 

Dernier

Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 

Dernier (20)

Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 

Working Towards RESTful Web Servies

  • 1. working towards RESTful Web Services Friday, November 8, 13
  • 2. GET /presenter/jessica { “name” : “Jessica Zehavi”, “title” : “Software Engineer”, “job” : { “company” : “Clockwork Active Media”, “href” : “http://www.clockwork.net” }, “contacts” : { “email” : “jessica@clockwork.net”, “twitter” : “@yiska”, “github” : “github.com/yiska”, } } Friday, November 8, 13
  • 6. working towards RESTful Web Services Friday, November 8, 13
  • 7. turns out, it’s kind of hard Friday, November 8, 13
  • 8. “A RESTful web service is an API implemented using HTTP and REST design principles.” - Wikipedia (edited by me) Friday, November 8, 13
  • 10. • Identification of resources Friday, November 8, 13
  • 11. • Identification of resources • Manipulation of resources through these representations Friday, November 8, 13
  • 12. • Identification of resources • Manipulation of resources through these representations • Self-descriptive messaging Friday, November 8, 13
  • 13. • Identification of resources • Manipulation of resources through these representations • Self-descriptive messaging • Hypermedia as the engine of application state (HATEOAS) Friday, November 8, 13
  • 15. Identification of Resources • Resources can be anything! Friday, November 8, 13
  • 16. Identification of Resources • Resources can be anything! • URLs identify resources http://www.example.com/projects/ http://www.example.com/projects/1 http://www.example.com/deliverables/42 Friday, November 8, 13
  • 17. Identification of Resources • Resources can be anything! • URLs identify resources http://www.example.com/projects/ http://www.example.com/projects/1 http://www.example.com/deliverables/42 • The representation describes the resource’s state Friday, November 8, 13
  • 18. Manipulation of Resources through Representations Project Represented in JSON { } Friday, November 8, 13 "id" : 1, "name" : "Focus Media Group Project", "start_date" : "2013-01-01", "end_date" : "2014-06-31", "status" : "complete", "deliverables" : [ 1, 2, 3 ], "departments" : [ 3, 8, 14 ], "created_on" : "2013-09-20" "modified_on" : "2013-10-01"
  • 19. Manipulation of Resources through Representations Project Represented in XML <?xml version="1.0" encoding="UTF-8"?> <project> <id>1</id> <name>Focus Media Group Project</name> <start_date>2013-01-01</start_date> <end_date>2013-01-01</end_date> <status>complete</status> <deliverables> <item>1</item> <item>2</item> <item>3</item> </deliverables> <departments> <item>1</item> <item>2</item> <item>3</item> </departments> <created_on>2013-09-20</created_on> <modified_on>2013-10-01</modified_on> </project> Friday, November 8, 13
  • 21. Create / POST Create a New Project Response POST /projects/ HTTP/1.1 HTTP/1.1 201 Created Content-Type: application/json { } "name" : "Museum Site Redesign", "start_date" : "2013-10-01", "end_date" : "2014-01-31", "status" : "new", "deliverables" : [ 4, 5, 6 ], "departments" : [ 2, 8, 11 ] Friday, November 8, 13 { } "id" : 1, "name" : "Museum Site Redesign", "start_date" : "2013-10-01", "end_date" : "2014-01-31", "status" : "new", "deliverables" : [ 4, 5, 6 ], "departments" : [ 2, 8, 11 ], "created_on" : "2013-09-20", "modified_on" : "2013-09-20"
  • 22. Read / GET Request a Resource Response GET /projects/1 HTTP/1.1 HTTP/1.1 200 OK Content-Type: application/json { "id" : 1, "name" : "Museum Site Redesign", "start_date" : "2013-10-01", "end_date" : "2014-01-31", "status" : "new", "deliverables" : [ 4, 5, 6 ], "departments" : [ 2, 8, 11 ], "created_on" : "2013-09-20", "modified_on" : "2013-09-20" } Friday, November 8, 13
  • 23. Update / PUT Update a Resource PUT /projects/1 HTTP/1.1 { } Friday, November 8, 13 "start_date" : "2013-11-01", "end_date" : "2014-02-28", Response HTTP/1.1 200 OK Content-Type: application/json { } "id" : 1, "name" : "Museum Site Redesign", "start_date" : "2013-10-01", "end_date" : "2014-02-28", "status" : "new", "deliverables" : [ 4, 5, 6 ], "departments" : [ 2, 8, 11 ]
  • 24. Delete / DELETE Delete a Resource Response DELETE /projects/1 HTTP/1.1 HTTP/1.1 204 No Content Friday, November 8, 13
  • 25. Hypermedia as the Engine of Application State ? Friday, November 8, 13
  • 27. You Know This “The principle of connectedness: each web page tells you how to get to the adjoining pages. The Web as a whole works on the principle of connectedness, which is better known as ‘hypermedia as the engine of application state,’ sometimes abbreviated HATEOAS.” - Leonard Richardson & Mike Amundsen RESTful Web APIs Friday, November 8, 13
  • 28. Hypermedia! GET /projects/1 HTTP/1.1 Response HTTP/1.1 200 OK Content-Type: application/json { } Friday, November 8, 13 "href" : "http://www.example.com/projects/1", "id" : 1, "name" : "Museum Site Redesign", "start_date" : "2013-10-01", "end_date" : "2014-01-31", "status" : "new", "deliverables" : { "href" : "http://www.example.com/deliverables", "items" : [ 4, 5, 6 ] }, "departments" : { "href" : "http://www.example.com/departments", "items" : [ 3, 8, 14 ] }, "created_on" : "2013-09-20", "modified_on" : "2013-09-20"
  • 29. Common Mistakes • Ignore hypermedia • Using the wrong HTTP method • Return the wrong response codes Friday, November 8, 13
  • 32. APIs for Public Consumption • Follow accepted standards/practices • Consume your own API • Versioning? Friday, November 8, 13
  • 33. Implementation • Resources • Relationships • Endpoints Friday, November 8, 13
  • 34. Project Viz Application • Tracks projects, resources and phases • Complex and evolving requirements • Wanted to host it themselves • Super fast deadline! Friday, November 8, 13
  • 35. // Get all projects Route::get( 'projects', function( ) { $projects = Project::all( ); return Response::json( $projects ); }); // Get a project by id Route::get( 'projects/{id}', function( $id ) { $project = Project::find( $id ); if ( ! $project ) { App::abort( 404 ); } return Response::json( $project ); } )->where( 'id', 'd+' ); Friday, November 8, 13
  • 36. Response HTTP/1.1 200 OK Content-Type: application/json { } Friday, November 8, 13 "id" : 1, "name" : "Museum Site Redesign", "start_date" : "2013-10-01", "end_date" : "2014-01-31", "status" : "new", "deliverables" : [ 4, 5, 6 ], "departments" : [ 2, 8, 11 ], "created_on" : "2013-09-20", "modified_on" : "2013-09-20"
  • 37. // Create new project Route::post( 'projects', function( ) { $project = new Project( Input::get( ) ); $project->validate( ); if ( ! $project->save() ) { App::abort( 500 ); } return Response::json( $project, 201 ); }); Friday, November 8, 13
  • 38. Response HTTP/1.1 201 Created Content-Type: application/json { } Friday, November 8, 13 "id" : 1, "name" : "Museum Site Redesign", "start_date" : "2013-10-01", "end_date" : "2014-01-31", "status" : "new", "deliverables" : [ 4, 5, 6 ], "departments" : [ 2, 8, 11 ], "created_on" : "2013-09-20", "modified_on" : "2013-09-20"
  • 39. // Update project by id Route::put('projects/{id}', function( $id ) { $project = Project::find( $id ); $project->fill( Input::get( ) ); $project->validate( ); if ( ! $project->save( ) ) { App::abort( 500 ); } return Response::json( $project ); })->where( 'id', 'd+' ); Friday, November 8, 13
  • 40. Send { "end_date" : "2013-12-31", status : "active" } Response HTTP/1.1 200 OK Content-Type: application/json { } Friday, November 8, 13 "id" : 1, "name" : "Museum Site Redesign", "start_date" : "2013-10-01", "end_date" : "2013-12-31", "status" : "active", "deliverables" : [ 4, 5, 6 ], "departments" : [ 2, 8, 11 ], "created_on" : "2013-09-20", "modified_on" : "2013-10-26"
  • 41. // Delete a project by id Route::delete( 'projects/{id}', function( $id ) { $project = Project::find( $id ); $project->delete( ); return Response::json( null, 204 ); })->where( 'id', 'd+' ); Response HTTP/1.1 204 No Content Friday, November 8, 13
  • 42. Do These Things • Try to be RESTful • Consume your own APIs if possible • Write Unit Tests Friday, November 8, 13
  • 43. Future! • Rate limiting • Authentication • Hypermedia • Versioning Friday, November 8, 13