SlideShare a Scribd company logo
1 of 49
An Introduction into
the Web API

Brad Genereaux | @integratorbrad | about.me/integratorbrad | hcintegrations.ca
Web Developers P2P : February 2014
Housekeeping
• About Me - Brad Genereaux
– Healthcare and API developer
– Integration Architect at Agfa Healthcare
– Blogger about all the API things

• Discussion and questions
– Ask anytime, or at the end
Topics
•
•
•
•
•

API
REST
Security
Web
Examples
The API

Application Programming Interface
What is an API?
• Methods to access data and workflow
from an application without using the
application itself
API Example

vs
Why an API?
• Not all users are the same
– Some want:

– Some want / need:

– And their needs and wants are ever shifting
An API Stack
GUI
(front-end)

API
(middle tier)

Data Sources
(back-end)
… sounds like a good framework
for Web …
The REST

REpresentational State Transfer
What is REST?
• Architectural style (not a standard!)
• Client server model
• Stateless
– Idempotency

• Cacheable
• Layered System
• Uniform interface
Source: https://www.ics.uci.edu/~fielding/pubs/dissertation/fielding_dissertation.pdf
Who RESTs?
•
•
•
•
•
•
•

Facebook
Twitter
Google
LinkedIn
Netflix
Evernote
Etc etc
Why REST?
•
•
•
•
•

Scalable
Fault-tolerant
Recoverable
Secure
Loosely coupled
What do I need to REST?
Clients
• Browsers
• Mobile Apps
• Desktop Apps

Servers
• “Capable of HTTP”
–
–
–
–
–
–

Java-based
.Net-based
PHP
Ruby
Perl
Etc.
Three levels of REST
• Level 1 : Resources
• Level 2 : Verbs
• Level 3 : HATEOAS
Resources, Level 1 REST
•
•
•
•

/users
/users/bob
/users/bob/tweets
/users/bob/tweets/1
Verbs, Level 2 REST
• CRUD
What is CRUD?
• Standard database operations:
C reate
R ead
U pdate
D elete
Verbs, Level 2 REST
• CRUD
• GET /tweets
(as opposed to /givemethetweets)

• POST /tweets
(as opposed to /createnewtweet)

• PUT /tweets/1
(as opposed to /updatetweet/1)

• DELETE /tweets/1
(as opposed to /removetweet/1)
RESTful Methods
GET
Collection URI
(such as
http://a.com/items/)

Element URI
(such as
http://a.com/items/17)

PUT

POST

DELETE

List the items in
the collection and
some metadata
about the items

Replace the entire
collection with
another collection

Create a new entry in
the collection, and
return the reference

Delete all the
items in the
collection

Retrieve a
specific item in
the collection

Replace a specific
item in the
collection; if it
doesn't
exist, create it

Not generally used

Delete the
specific item
in the
collection

• There are other methods less used (HEAD, OPTIONS, PATCH) for other purposes
• Representations of an item are specified by the media type (MIME type)

Source: http://en.wikipedia.org/wiki/Representational_state_transfer
HATEOAS, Level 3 REST
• Hypermedia as the engine of
application state

"ids" : [
12345678,
87654321,
11223344
]

"links": [
{
"rel": "UserInfo",
"href": "https://.../user/12345678"
},
{
"rel": "Tweets",
"href": "https://.../tweet/87654321"
},
{
"rel": "Messages",
"href": "https://.../msgs/11223344"
}
]
Data Formats (XML and JSON)
 XML (135 characters):
<tweets>
<tweet type="text" id="1">
<text>REST is great!</text>
</tweet>
<tweet type="text" id="2">
<text>APIs forever!</text>
</tweet>
</tweets>

 JSON (109 characters):
{
"tweets": [
{"type": "text", "id": "1",
"text": "REST is great!"},
{"type": "text", "id": "2",
"text": "APIs forever!"}
]
}

 XML can be validated (XML Schema), stylized (XSL), traversed

(XPath), queried (XQuery), transformed (XSLT), and
namespaced
 JSON is easier
What makes for good REST?
• Self-documenting
• Nouns in path, verbs by HTTP
• Complexity under the “?”
– i.e., /tweets/?contains=API

• Errors use HTTP error code mechanism
• As simple as possible, but no simpler
REST Alternatives
• SOAP (simple object access protocol)
• Javascript
• XML-RPC

• See discussion at
http://www.slideshare.net/jmusser/j-musser-ap
Important : Know your TTFHW
(Time to First Hello World) !
API Worst Practices
Source: http://www.slideshare.net/jmusser/j-musser-apishotnotgluecon2012

10. Poor error handling
9. Ignoring HTTP rules
8. Exposing your underlying data model
7. Security complexity
6. Unexpected release cycles
5. Poor developer experience
4. Expecting an MVC to give you a great API
3. Assuming if you build it, they will come
2. Inadequate support
1. Poor documentation
The Security
Authentication and Authorization
• Authentication : Who
• Authorization : What they are allowed to
do
• Not your job, but your responsibility
Security Frameworks
• OAuth
– Authorizing services

• OpenID
– Facebook, Google

• LDAP
– Enterprise authentication
Application Security Threats
Input Validation
Authentication

Session Management
Cryptography

Authorization

Exception Management

Configuration
Management

Parameter Manipulation

Sensitive Information

Auditing and Logging

Source: http://en.wikipedia.org/wiki/Application_security
SQL Injection

Consider the following pseudo-code:
String topic = request.getParameter(“topic");
SQLCommand sql = new SQLCommand("select * from
tweets where topic like ‘" + topic + "%’")

So what happens if the parameter is:
– API
– REST
– h3ck0rz’; drop table tweets; -Source: http://xkcd.com/327/
The Web

Client-side Access to REST
HTML5 + CSS
• “HyperText Markup Language”
– Characterized by the DOM (document object model) Completely
ubiquitous across the Internet
<html>
<body>
<h1>Hello World</h1>
</body>
</html>

• “Cascading Style Sheets”
– Allows for advanced stylization of content
– Example:

.giant {
font-size: 72px;
color: blue;
}
JavaScript
•
•
•
•

Multi-paradigm weakly-typed scripting language
Used most often hand-in-hand with HTML
Not Java, at all (syntax based on C)
Example:
alert (“Hello World!”);

• Able to manipulate the DOM and interact with the
browser environment
AJAX
• “Asynchronous JavaScript and XML”
• Group of technologies that allow for robust client
interactions without reloading web pages
– HTML and CSS for presentation
– DOM for display and interaction of data
– XML for data interchange
– XMLHttpRequest for asynchronous communication
– JavaScript to bring these technologies together
• AJAX is the key to consuming REST
jQuery
• “jQuery is a fast and concise JavaScript Library that
simplifies HTML document traversing, event handling,
animating, and Ajax interactions for rapid web
development.”
• Example:
$(“#h1”).html(“Hello World!”);

• jQuery tests against many browser platforms and solves
a lot of the problems that supporting many platforms
introduces
Calling REST with jQuery
Verb

• Use an AJAX Call
Resource
$.ajax({
type : "GET",
url : "http://a.com/tweets",
data : {"contains" : "API"},
dataType : "json",
success : function(data){
alert ("Results: " + data);
}
});

Query
parameters
Media type
Tips
• Use “curl” to simulate calls from your
command line
• Use Chrome debug tools or Firebug to
watch traffic and test your Javascript
• Use libraries – no need to reinvent the
wheel
Other Frameworks
•
•
•
•

UI Frameworks (Bootstrap, Foundation)
MVC Frameworks (Angular, Backbone)
Tooling (Yeoman, Lineman)
Documentation (Apiary, Swagger)

• No shortage of options
The Examples
Some REST API Examples
•
•
•
•
•

Facebook
Twitter
If This, Than That
Twilio
Demo
Facebook Graph API
• Every object has an ID:

• Objects can be searched:

• Objects can be updated:
Twitter REST API
If This, Then That

•

API Integration Website - http://ifttt.com/
Twilio
Demo
Need more REST?
• Programmable Web
http://programmableweb.com
John Musser’s presentations: http://www.slideshare.net/jmusser

• Crafting Interfaces that Developers Love
http://offers.apigee.com/api-design-ebook-rr/

• API Craft Google Group https://
groups.google.com/forum/#!forum/api-craft
Discussion - Questions

More Related Content

What's hot (20)

An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Api types
Api typesApi types
Api types
 
Understanding REST
Understanding RESTUnderstanding REST
Understanding REST
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
 
API for Beginners
API for BeginnersAPI for Beginners
API for Beginners
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
Api presentation
Api presentationApi presentation
Api presentation
 
Learn REST in 18 Slides
Learn REST in 18 SlidesLearn REST in 18 Slides
Learn REST in 18 Slides
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
RESTful API - Best Practices
RESTful API - Best PracticesRESTful API - Best Practices
RESTful API - Best Practices
 
Rest api standards and best practices
Rest api standards and best practicesRest api standards and best practices
Rest api standards and best practices
 
HTTP Request and Response Structure
HTTP Request and Response StructureHTTP Request and Response Structure
HTTP Request and Response Structure
 
Rest API
Rest APIRest API
Rest API
 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
Express js
Express jsExpress js
Express js
 
API for Beginners
API for BeginnersAPI for Beginners
API for Beginners
 
.Net Core
.Net Core.Net Core
.Net Core
 
Web Development
Web DevelopmentWeb Development
Web Development
 
API
APIAPI
API
 

Viewers also liked

Web data from R
Web data from RWeb data from R
Web data from Rschamber
 
R by example: mining Twitter for consumer attitudes towards airlines
R by example: mining Twitter for consumer attitudes towards airlinesR by example: mining Twitter for consumer attitudes towards airlines
R by example: mining Twitter for consumer attitudes towards airlinesJeffrey Breen
 
Keeping it safe: Securing DICOM
Keeping it safe: Securing DICOMKeeping it safe: Securing DICOM
Keeping it safe: Securing DICOMBrad Genereaux
 
Integrating Google APIs into Your Applications
Integrating Google APIs into Your ApplicationsIntegrating Google APIs into Your Applications
Integrating Google APIs into Your ApplicationsChris Schalk
 
BlueVia overview
BlueVia overviewBlueVia overview
BlueVia overviewBlueVia
 
Mobile Internet Fulfillment Exchange [MIFE] Keynote by Amos Manasseh, Axiata ...
Mobile Internet Fulfillment Exchange [MIFE] Keynote by Amos Manasseh, Axiata ...Mobile Internet Fulfillment Exchange [MIFE] Keynote by Amos Manasseh, Axiata ...
Mobile Internet Fulfillment Exchange [MIFE] Keynote by Amos Manasseh, Axiata ...Alan Quayle
 
SQE - Semantic Query Expansion
SQE - Semantic Query ExpansionSQE - Semantic Query Expansion
SQE - Semantic Query Expansionkciuk
 
Cec2010 araujo pereziglesias
Cec2010 araujo pereziglesiasCec2010 araujo pereziglesias
Cec2010 araujo pereziglesiasLourdes Araujo
 
Introduction to API Design: REST and Java
Introduction to API Design: REST and JavaIntroduction to API Design: REST and Java
Introduction to API Design: REST and JavaPhilip Johnson
 
Mobile operators: working together to adopt a standardized API platform, WSO2...
Mobile operators: working together to adopt a standardized API platform, WSO2...Mobile operators: working together to adopt a standardized API platform, WSO2...
Mobile operators: working together to adopt a standardized API platform, WSO2...Alan Quayle
 
Enhancing Information Retrieval by Personalization Techniques
Enhancing Information Retrieval by Personalization TechniquesEnhancing Information Retrieval by Personalization Techniques
Enhancing Information Retrieval by Personalization Techniquesveningstonk
 
Tech Meetup: How to build a Rest API in Java
Tech Meetup: How to build a Rest API in JavaTech Meetup: How to build a Rest API in Java
Tech Meetup: How to build a Rest API in JavaSantex Group
 
Conquest for dummies: how to setup a pacs server
Conquest for dummies: how to setup a pacs serverConquest for dummies: how to setup a pacs server
Conquest for dummies: how to setup a pacs serverBogazici University
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsIdo Flatow
 

Viewers also liked (20)

Web data from R
Web data from RWeb data from R
Web data from R
 
R by example: mining Twitter for consumer attitudes towards airlines
R by example: mining Twitter for consumer attitudes towards airlinesR by example: mining Twitter for consumer attitudes towards airlines
R by example: mining Twitter for consumer attitudes towards airlines
 
DICOMweb
DICOMwebDICOMweb
DICOMweb
 
Keeping it safe: Securing DICOM
Keeping it safe: Securing DICOMKeeping it safe: Securing DICOM
Keeping it safe: Securing DICOM
 
Integrating Google APIs into Your Applications
Integrating Google APIs into Your ApplicationsIntegrating Google APIs into Your Applications
Integrating Google APIs into Your Applications
 
ASP.NET WEB API
ASP.NET WEB APIASP.NET WEB API
ASP.NET WEB API
 
BlueVia overview
BlueVia overviewBlueVia overview
BlueVia overview
 
Mobile Internet Fulfillment Exchange [MIFE] Keynote by Amos Manasseh, Axiata ...
Mobile Internet Fulfillment Exchange [MIFE] Keynote by Amos Manasseh, Axiata ...Mobile Internet Fulfillment Exchange [MIFE] Keynote by Amos Manasseh, Axiata ...
Mobile Internet Fulfillment Exchange [MIFE] Keynote by Amos Manasseh, Axiata ...
 
SQE - Semantic Query Expansion
SQE - Semantic Query ExpansionSQE - Semantic Query Expansion
SQE - Semantic Query Expansion
 
Cec2010 araujo pereziglesias
Cec2010 araujo pereziglesiasCec2010 araujo pereziglesias
Cec2010 araujo pereziglesias
 
Introduction to API Design: REST and Java
Introduction to API Design: REST and JavaIntroduction to API Design: REST and Java
Introduction to API Design: REST and Java
 
Mobile operators: working together to adopt a standardized API platform, WSO2...
Mobile operators: working together to adopt a standardized API platform, WSO2...Mobile operators: working together to adopt a standardized API platform, WSO2...
Mobile operators: working together to adopt a standardized API platform, WSO2...
 
Enhancing Information Retrieval by Personalization Techniques
Enhancing Information Retrieval by Personalization TechniquesEnhancing Information Retrieval by Personalization Techniques
Enhancing Information Retrieval by Personalization Techniques
 
Tech Meetup: How to build a Rest API in Java
Tech Meetup: How to build a Rest API in JavaTech Meetup: How to build a Rest API in Java
Tech Meetup: How to build a Rest API in Java
 
FHIR and DICOM by Marten Smits
FHIR and DICOM by Marten SmitsFHIR and DICOM by Marten Smits
FHIR and DICOM by Marten Smits
 
Nunit
NunitNunit
Nunit
 
N Unit Presentation
N Unit PresentationN Unit Presentation
N Unit Presentation
 
Conquest for dummies: how to setup a pacs server
Conquest for dummies: how to setup a pacs serverConquest for dummies: how to setup a pacs server
Conquest for dummies: how to setup a pacs server
 
Excellent rest using asp.net web api
Excellent rest using asp.net web apiExcellent rest using asp.net web api
Excellent rest using asp.net web api
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP Fundamentals
 

Similar to Introduction to the Web API

Les Basiques - Web Développement HTML5, CSS3, JS et PHP
Les Basiques - Web  Développement HTML5, CSS3, JS et PHPLes Basiques - Web  Développement HTML5, CSS3, JS et PHP
Les Basiques - Web Développement HTML5, CSS3, JS et PHPHamdi Hmidi
 
Netflix OSS and HATEOAS deployed on production - JavaLand
Netflix OSS and HATEOAS deployed on production - JavaLandNetflix OSS and HATEOAS deployed on production - JavaLand
Netflix OSS and HATEOAS deployed on production - JavaLandJWORKS powered by Ordina
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by GoogleASG
 
Introduction web tech
Introduction web techIntroduction web tech
Introduction web techLiaquat Rahoo
 
HTML5: An Overview
HTML5: An OverviewHTML5: An Overview
HTML5: An OverviewNagendra Um
 
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital.AI
 
State of modern web technologies: an introduction
State of modern web technologies: an introductionState of modern web technologies: an introduction
State of modern web technologies: an introductionMichael Ahearn
 

Similar to Introduction to the Web API (20)

Les Basiques - Web Développement HTML5, CSS3, JS et PHP
Les Basiques - Web  Développement HTML5, CSS3, JS et PHPLes Basiques - Web  Développement HTML5, CSS3, JS et PHP
Les Basiques - Web Développement HTML5, CSS3, JS et PHP
 
Ntg web services
Ntg   web servicesNtg   web services
Ntg web services
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Api crash
Api crashApi crash
Api crash
 
Netflix OSS and HATEOAS deployed on production - JavaLand
Netflix OSS and HATEOAS deployed on production - JavaLandNetflix OSS and HATEOAS deployed on production - JavaLand
Netflix OSS and HATEOAS deployed on production - JavaLand
 
Angular jS Introduction by Google
Angular jS Introduction by GoogleAngular jS Introduction by Google
Angular jS Introduction by Google
 
Introduction web tech
Introduction web techIntroduction web tech
Introduction web tech
 
Php reports sumit
Php reports sumitPhp reports sumit
Php reports sumit
 
web devs ppt.ppsx
web devs ppt.ppsxweb devs ppt.ppsx
web devs ppt.ppsx
 
HTML5: An Overview
HTML5: An OverviewHTML5: An Overview
HTML5: An Overview
 
25444215.pptx
25444215.pptx25444215.pptx
25444215.pptx
 
web development
web developmentweb development
web development
 
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and SparkVital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
Vital AI MetaQL: Queries Across NoSQL, SQL, Sparql, and Spark
 
State of modern web technologies: an introduction
State of modern web technologies: an introductionState of modern web technologies: an introduction
State of modern web technologies: an introduction
 
Mini-Training: Let's have a rest
Mini-Training: Let's have a restMini-Training: Let's have a rest
Mini-Training: Let's have a rest
 

Recently uploaded

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
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
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
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
 
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
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Recently uploaded (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
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
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
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
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
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
 
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
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

Introduction to the Web API

  • 1. An Introduction into the Web API Brad Genereaux | @integratorbrad | about.me/integratorbrad | hcintegrations.ca Web Developers P2P : February 2014
  • 2. Housekeeping • About Me - Brad Genereaux – Healthcare and API developer – Integration Architect at Agfa Healthcare – Blogger about all the API things • Discussion and questions – Ask anytime, or at the end
  • 5. What is an API? • Methods to access data and workflow from an application without using the application itself
  • 7. Why an API? • Not all users are the same – Some want: – Some want / need: – And their needs and wants are ever shifting
  • 8. An API Stack GUI (front-end) API (middle tier) Data Sources (back-end)
  • 9. … sounds like a good framework for Web …
  • 11. What is REST? • Architectural style (not a standard!) • Client server model • Stateless – Idempotency • Cacheable • Layered System • Uniform interface
  • 15. What do I need to REST? Clients • Browsers • Mobile Apps • Desktop Apps Servers • “Capable of HTTP” – – – – – – Java-based .Net-based PHP Ruby Perl Etc.
  • 16. Three levels of REST • Level 1 : Resources • Level 2 : Verbs • Level 3 : HATEOAS
  • 17. Resources, Level 1 REST • • • • /users /users/bob /users/bob/tweets /users/bob/tweets/1
  • 18. Verbs, Level 2 REST • CRUD
  • 19. What is CRUD? • Standard database operations: C reate R ead U pdate D elete
  • 20. Verbs, Level 2 REST • CRUD • GET /tweets (as opposed to /givemethetweets) • POST /tweets (as opposed to /createnewtweet) • PUT /tweets/1 (as opposed to /updatetweet/1) • DELETE /tweets/1 (as opposed to /removetweet/1)
  • 21. RESTful Methods GET Collection URI (such as http://a.com/items/) Element URI (such as http://a.com/items/17) PUT POST DELETE List the items in the collection and some metadata about the items Replace the entire collection with another collection Create a new entry in the collection, and return the reference Delete all the items in the collection Retrieve a specific item in the collection Replace a specific item in the collection; if it doesn't exist, create it Not generally used Delete the specific item in the collection • There are other methods less used (HEAD, OPTIONS, PATCH) for other purposes • Representations of an item are specified by the media type (MIME type) Source: http://en.wikipedia.org/wiki/Representational_state_transfer
  • 22. HATEOAS, Level 3 REST • Hypermedia as the engine of application state "ids" : [ 12345678, 87654321, 11223344 ] "links": [ { "rel": "UserInfo", "href": "https://.../user/12345678" }, { "rel": "Tweets", "href": "https://.../tweet/87654321" }, { "rel": "Messages", "href": "https://.../msgs/11223344" } ]
  • 23. Data Formats (XML and JSON)  XML (135 characters): <tweets> <tweet type="text" id="1"> <text>REST is great!</text> </tweet> <tweet type="text" id="2"> <text>APIs forever!</text> </tweet> </tweets>  JSON (109 characters): { "tweets": [ {"type": "text", "id": "1", "text": "REST is great!"}, {"type": "text", "id": "2", "text": "APIs forever!"} ] }  XML can be validated (XML Schema), stylized (XSL), traversed (XPath), queried (XQuery), transformed (XSLT), and namespaced  JSON is easier
  • 24. What makes for good REST? • Self-documenting • Nouns in path, verbs by HTTP • Complexity under the “?” – i.e., /tweets/?contains=API • Errors use HTTP error code mechanism • As simple as possible, but no simpler
  • 25. REST Alternatives • SOAP (simple object access protocol) • Javascript • XML-RPC • See discussion at http://www.slideshare.net/jmusser/j-musser-ap
  • 26. Important : Know your TTFHW (Time to First Hello World) !
  • 27. API Worst Practices Source: http://www.slideshare.net/jmusser/j-musser-apishotnotgluecon2012 10. Poor error handling 9. Ignoring HTTP rules 8. Exposing your underlying data model 7. Security complexity 6. Unexpected release cycles 5. Poor developer experience 4. Expecting an MVC to give you a great API 3. Assuming if you build it, they will come 2. Inadequate support 1. Poor documentation
  • 29. Authentication and Authorization • Authentication : Who • Authorization : What they are allowed to do • Not your job, but your responsibility
  • 30. Security Frameworks • OAuth – Authorizing services • OpenID – Facebook, Google • LDAP – Enterprise authentication
  • 31. Application Security Threats Input Validation Authentication Session Management Cryptography Authorization Exception Management Configuration Management Parameter Manipulation Sensitive Information Auditing and Logging Source: http://en.wikipedia.org/wiki/Application_security
  • 32. SQL Injection Consider the following pseudo-code: String topic = request.getParameter(“topic"); SQLCommand sql = new SQLCommand("select * from tweets where topic like ‘" + topic + "%’") So what happens if the parameter is: – API – REST – h3ck0rz’; drop table tweets; -Source: http://xkcd.com/327/
  • 34. HTML5 + CSS • “HyperText Markup Language” – Characterized by the DOM (document object model) Completely ubiquitous across the Internet <html> <body> <h1>Hello World</h1> </body> </html> • “Cascading Style Sheets” – Allows for advanced stylization of content – Example: .giant { font-size: 72px; color: blue; }
  • 35. JavaScript • • • • Multi-paradigm weakly-typed scripting language Used most often hand-in-hand with HTML Not Java, at all (syntax based on C) Example: alert (“Hello World!”); • Able to manipulate the DOM and interact with the browser environment
  • 36. AJAX • “Asynchronous JavaScript and XML” • Group of technologies that allow for robust client interactions without reloading web pages – HTML and CSS for presentation – DOM for display and interaction of data – XML for data interchange – XMLHttpRequest for asynchronous communication – JavaScript to bring these technologies together • AJAX is the key to consuming REST
  • 37. jQuery • “jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.” • Example: $(“#h1”).html(“Hello World!”); • jQuery tests against many browser platforms and solves a lot of the problems that supporting many platforms introduces
  • 38. Calling REST with jQuery Verb • Use an AJAX Call Resource $.ajax({ type : "GET", url : "http://a.com/tweets", data : {"contains" : "API"}, dataType : "json", success : function(data){ alert ("Results: " + data); } }); Query parameters Media type
  • 39. Tips • Use “curl” to simulate calls from your command line • Use Chrome debug tools or Firebug to watch traffic and test your Javascript • Use libraries – no need to reinvent the wheel
  • 40. Other Frameworks • • • • UI Frameworks (Bootstrap, Foundation) MVC Frameworks (Angular, Backbone) Tooling (Yeoman, Lineman) Documentation (Apiary, Swagger) • No shortage of options
  • 42. Some REST API Examples • • • • • Facebook Twitter If This, Than That Twilio Demo
  • 43. Facebook Graph API • Every object has an ID: • Objects can be searched: • Objects can be updated:
  • 45. If This, Then That • API Integration Website - http://ifttt.com/
  • 47. Demo
  • 48. Need more REST? • Programmable Web http://programmableweb.com John Musser’s presentations: http://www.slideshare.net/jmusser • Crafting Interfaces that Developers Love http://offers.apigee.com/api-design-ebook-rr/ • API Craft Google Group https:// groups.google.com/forum/#!forum/api-craft

Editor's Notes

  1. Describes a method for a client to communicate with a server If you ever access a website, you are already using REST When you access a page, you are GETting it.
  2. Easy to consume by many platforms Lightweight, payload is almost strictly content Self-documenting Flexible for many environments, including firewalls and load-balancers Just “works” for security and identity frameworks Server and consumer agnostic
  3. Both represent the same data, albeit in different ways JSON is smaller, but with compression, they are ~equivalent XML can be validated (XML Schema), stylized (XSL), traversed (XPath), queried (XQuery), transformed (XSLT), and namespaced JSON has no formally recognized equivalents, which isn’t necessarily a bad thing
  4. I can reasonably guess functionality without needing documentation TTFHW – Time to first hello world