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

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Dernier (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 

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