SlideShare une entreprise Scribd logo
1  sur  35
> GET /problems/MONEY HTTP/1.1   I	 GOT	 99
                                 PROBLEMS
> Host: localhost
> Accept: */*

< HTTP/1.1 200 OK




> GET /problems/POWER HTTP/1.1
> Host: localhost
                                 BUT	 REST
                                 AINT	 ONE
> Accept: */*

< HTTP/1.1 200 OK



> GET /problems/REST HTTP/1.1
> Host: localhost
> Accept: */*
                                 @adrianfcole
< HTTP/1.1 404 Not Found
PROBLEMS
 ➡Why API
 ➡ReST vs other HTTP APIs?
 ➡Design Patterns vs Real APIs
WHO	 IS	 THIS	 GUY?
๏ @adrianfcole

๏ architect CloudHub at MuleSoft

๏founder jclouds
THANKS
  ★     api-craft
  ★     mattstep
  ★   gtcampbell
  ★       mulies
WHY	 WE	 API

          photo copyright 2005 Sony Pictures
COLLABORATE
GROW	 
ECOSYSTEM
AND	 
INNOVATE
HOW	 
TO	  ReST SOAP
API
HOW	 
TO	  ReST WS-*
API
HOW	 
TO	  ReST ReST   ish

API
HOW	 
TO	  not-soap   HATEOAS
REST
To	 the	 
        Level 0:
        Level 1:
                   Swamp of POX
                   Resources
glory	  Level 2:
        Level 3:
                   Verbs
                   Hypermedia

of	 
REST
> POST /api HTTP/1.1
                         > <SOAP-ENV:Envelope ...>
                           <SOAP-ENV:Body>
                             <m:getAvailableDataSources xmlns:m="




Swamp	 
                               <group xsi:type="xsd:string">ArcWe
                               <service xsi:type="xsd:string">Map
                               <token xsi:type="xsd:string">MyTok
                             </m:getAvailableDataSources>




of	 POX
                           </SOAP-ENV:Body>
                         </SOAP-ENV:Envelope>

                         < HTTP/1.1 200 OK
                         < <?xml version="1.0" encoding="UTF-8"?>
                         <soap:Envelope ...>
                           <soap:Body>
                             <n:getAvailableDataSourcesResponse x
                               <Result href="#id0"/>
                             </n:getAvailableDataSourcesResponse>
All things go over the       <id0 id="id0" soapenc:root="0" xsi:t
                         soapenc:arrayType="ns5:DataSource[21]">
same endpoint as XML           <i href="#id1"/>
                         --snip--
RESOURCES
> GET https://ec2.amazonaws.com/?Action=DeleteVolume&VolumeId=vol-4282672b HTTP/1.1

< HTTP/1.1 200 OK

<DeleteVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2012-08-15/">
  <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
  <return>true</return>
</DeleteVolumeResponse>

   --snip--

                         Many URIs, same HTTP method
                          Side-effects are API-specific
VERBS
    > HEAD https://mybucket.s3.amazonaws.com/ HTTP/1.1

    < HTTP/1.1 200 OK




 HTTP verbs mean more than CRUD
    Status codes are meaningful
HYPERMEDIA
    > GET https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a50f-9dd4e03546
    > Accept: application/vnd.vmware.vcloud.catalogItem+xml

    < HTTP/1.1 200 OK
    < Content-Type: application/vnd.vmware.vcloud.catalogItem+xml;version=1.0

    <CatalogItem xmlns="http://www.vmware.com/vcloud/v1" name="mycatalog" type="
                 href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a5
        <Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml"
              href="https://vcloud/api/v1.0/catalog/7f192dfe-00d1-42f2-9f76-9360
        <Link rel="edit" type="application/vnd.vmware.vcloud.catalogItem+xml"
              href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a50f-
        <Link rel="remove"
             href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a50f-9
    --snip--




Discoverability, Self-documenting
What	 makes	 
it	 HYPER?
      ➡Base Type
      ➡Links
abort

                                                  add

                                                  alternate

                                                  disk:attach




    TRANSITIONS                                   edit

                                                  remove

                                                  task




All	 transitions	 are	 discoverable	 via	 links
CONTENT	 
NEGOTIATION
 ➡   Client supplies representation in
    Accept header
 ➡On change, update mediatype
    name or annotate via ;version=N.N
 ➡On overhaul, bump global version
 Accept: application/vnd.VENDOR.PRODUCT.RESOURCE+xml
Representing	 
HyperMedia
    Extend Atom
    Opaque + Link Headers
    HAL
    ...
EXTEND	 ATOM
      Vendor Type, Link elements
      < HTTP/1.1 200 OK
      < Content-Type: application/vnd.vmware.vcloud.catalogItem+xml;version=1.0

      <CatalogItem xmlns="http://www.vmware.com/vcloud/v1" name="mycatalog" type="
                   href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a5
          <Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml"
                href="https://vcloud/api/v1.0/catalog/7f192dfe-00d1-42f2-9f76-9360
          <Link rel="edit" type="application/vnd.vmware.vcloud.catalogItem+xml"
                href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a50f-
          <Link rel="remove"
               href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a50f-9
      --snip--



domain-specific types
inherits link semantics from Atom
Link	 Headers
      Opaque Type, Link elements
      < HTTP/1.1 200 OK
      < Content-Type: image/jpeg
      Link: </images/foo.png>; rel="alternate"; type=”image/png”

      010101010101010101
      --snip--




supports binary types
facilitates intermediaries
Hypertext	 Application	 Language
     Mix-in hypermedia controls into base type
     embed resources for efficiency
     < HTTP/1.1 200 OK
     < Content-Type: application/hal+json

     {
         _links: {
            self: {
              href: '/example',
            }
         },
         _embedded: {},
         name: 'foo',

     --snip--



domain-specific type agnostic
ELEGENT
clients always
know transitions

self-documenting
                   LETS	 USE
and discoverable

version at
                   HATEOAS
media-type
granularity
Perceived	 
Complexity?
Level	 2	 
optimizes	 
for Coarse Grained Versions
    CRUD++
    Limited Representations
    Today’s Tools
    Simplicity over Elegance
IS	 IT	 ALL	 
JUST	 
PRICKLES	 
&	 GOO?
can	 we	 have	 both?
There	       Domain	 Style
           Base	 Format
is	 no	      State	 Transfer
Level2          App	 Flow
 Design
            plus stuff like errors
REST	 Design	 
tools
       ➡Apiary
       ➡Swagger
       ➡iodocs
GOOD	 API	 DESIGNERS	 
UNDERSTAND
 how it is used, and who will use it

 importance of iterations and feedback

 impacts to design beyond development

 there’s no golden hammer   (not even mongo)
TWITTER	 IS	 NOT	 
HATEOAS
         REST
         SEARCH
         STREAM
AWS	 IS	 NOT	 REST	 
AWS	 IS	 GOOD
api designed to parse quickly

simple extension (add new key)

consistent security model

bulk ops
WebSockets	 	 
ain’t	 even
HTTP! Handshake is HTTPish
      Discoverable like ReST

      Full-Duplex
      Uncode or Binary Messages
      TCP Protocol
GOOD	 REST	 APIs
Are consciously designed

Version at the right scope

Don’t leak implementation details

Use auth models relevant to consumer

Are well documented with examples
What	 now?
 ➡join api-craft
 ➡read The REST API Design Handbook
 ➡read Building Hypermedia APIs...
 ➡socialize your ideas
       Thank	 you!

Contenu connexe

Tendances

Tendances (20)

예외처리가이드
예외처리가이드예외처리가이드
예외처리가이드
 
JUnit5 and TestContainers
JUnit5 and TestContainersJUnit5 and TestContainers
JUnit5 and TestContainers
 
Atomicity In Redis: Thomas Hunter
Atomicity In Redis: Thomas HunterAtomicity In Redis: Thomas Hunter
Atomicity In Redis: Thomas Hunter
 
Jsp presentation
Jsp presentationJsp presentation
Jsp presentation
 
Automated Web Testing Using Selenium
Automated Web Testing Using SeleniumAutomated Web Testing Using Selenium
Automated Web Testing Using Selenium
 
Coroutines in Kotlin
Coroutines in KotlinCoroutines in Kotlin
Coroutines in Kotlin
 
Nouveautés de java 8
Nouveautés de java 8Nouveautés de java 8
Nouveautés de java 8
 
gRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at SquaregRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at Square
 
Nouveautés Java 9-10-11
Nouveautés Java 9-10-11Nouveautés Java 9-10-11
Nouveautés Java 9-10-11
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentation
 
Understanding Java Garbage Collection
Understanding Java Garbage CollectionUnderstanding Java Garbage Collection
Understanding Java Garbage Collection
 
Node.js Event Emitter
Node.js Event EmitterNode.js Event Emitter
Node.js Event Emitter
 
Introduction to webassembly
Introduction to webassemblyIntroduction to webassembly
Introduction to webassembly
 
API Asynchrones en Java 8
API Asynchrones en Java 8API Asynchrones en Java 8
API Asynchrones en Java 8
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutines
 
Implementing a JavaScript Engine
Implementing a JavaScript EngineImplementing a JavaScript Engine
Implementing a JavaScript Engine
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
jQuery
jQueryjQuery
jQuery
 
Discover Quarkus and GraalVM
Discover Quarkus and GraalVMDiscover Quarkus and GraalVM
Discover Quarkus and GraalVM
 

En vedette

En vedette (20)

VMworld 2013: vCloud Hybrid Service: Enterprise Applications on vCloud Hybrid...
VMworld 2013: vCloud Hybrid Service: Enterprise Applications on vCloud Hybrid...VMworld 2013: vCloud Hybrid Service: Enterprise Applications on vCloud Hybrid...
VMworld 2013: vCloud Hybrid Service: Enterprise Applications on vCloud Hybrid...
 
Между молотом и наковальней. Production Quality
Между молотом и наковальней. Production QualityМежду молотом и наковальней. Production Quality
Между молотом и наковальней. Production Quality
 
Что было, что есть, что будет: Current State vs. Common Sense
Что было, что есть, что будет: Current State vs. Common SenseЧто было, что есть, что будет: Current State vs. Common Sense
Что было, что есть, что будет: Current State vs. Common Sense
 
Аудит команды тестирования в сложном проекте
Аудит команды тестирования в сложном проектеАудит команды тестирования в сложном проекте
Аудит команды тестирования в сложном проекте
 
Обратная связь и целеполагание, как маяки надежды тестировщика
Обратная связь и целеполагание, как маяки надежды тестировщикаОбратная связь и целеполагание, как маяки надежды тестировщика
Обратная связь и целеполагание, как маяки надежды тестировщика
 
Ответственность за качество в разных ИТ-проектах
Ответственность за качество в разных ИТ-проектахОтветственность за качество в разных ИТ-проектах
Ответственность за качество в разных ИТ-проектах
 
Три инструмента тест-менеджера для работы с людьми
Три инструмента тест-менеджера для работы с людьмиТри инструмента тест-менеджера для работы с людьми
Три инструмента тест-менеджера для работы с людьми
 
Управление хаосом, или как жить когда число тестов перевалило за десятки тысяч
Управление хаосом, или как жить когда число тестов перевалило за десятки тысячУправление хаосом, или как жить когда число тестов перевалило за десятки тысяч
Управление хаосом, или как жить когда число тестов перевалило за десятки тысяч
 
Определение pass/fail критериев при тестировании и анализе производительности
Определение pass/fail критериев при тестировании и анализе производительностиОпределение pass/fail критериев при тестировании и анализе производительности
Определение pass/fail критериев при тестировании и анализе производительности
 
Пользовательские требования в жизни тестировщика
Пользовательские требования в жизни тестировщикаПользовательские требования в жизни тестировщика
Пользовательские требования в жизни тестировщика
 
Пирамида Тестирования через призму ROI калькулятора и прочая геометрия
Пирамида Тестирования через призму ROI калькулятора и прочая геометрияПирамида Тестирования через призму ROI калькулятора и прочая геометрия
Пирамида Тестирования через призму ROI калькулятора и прочая геометрия
 
Процесс тестирования в условиях неявных требований
Процесс тестирования в условиях неявных требованийПроцесс тестирования в условиях неявных требований
Процесс тестирования в условиях неявных требований
 
A New Model for Testing
A New Model for TestingA New Model for Testing
A New Model for Testing
 
Работа с бизнес-требованиями на стадии выхода продукта
Работа с бизнес-требованиями на стадии выхода продуктаРабота с бизнес-требованиями на стадии выхода продукта
Работа с бизнес-требованиями на стадии выхода продукта
 
Psychology and testing
Psychology and testingPsychology and testing
Psychology and testing
 
Метод No-Test-Cases: избавьтесь от тест-кейсов в тестировании
Метод No-Test-Cases: избавьтесь от тест-кейсов в тестированииМетод No-Test-Cases: избавьтесь от тест-кейсов в тестировании
Метод No-Test-Cases: избавьтесь от тест-кейсов в тестировании
 
How to reduce your test cases... magically!
How to reduce your test cases... magically!How to reduce your test cases... magically!
How to reduce your test cases... magically!
 
Advancing Testing Using Axioms
Advancing Testing Using AxiomsAdvancing Testing Using Axioms
Advancing Testing Using Axioms
 
Отряд тест-аналитиков
Отряд тест-аналитиковОтряд тест-аналитиков
Отряд тест-аналитиков
 
Examples how to move towards Zero Defects
Examples how to move towards Zero DefectsExamples how to move towards Zero Defects
Examples how to move towards Zero Defects
 

Similaire à I got 99 problems, but ReST ain't one

Integrating with SAP FIX and HL7
Integrating with SAP FIX and HL7Integrating with SAP FIX and HL7
Integrating with SAP FIX and HL7
WSO2
 
The Evolving Security Environment For Web Services
The Evolving Security Environment For Web ServicesThe Evolving Security Environment For Web Services
The Evolving Security Environment For Web Services
Qanita Ahmad
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
King Foo
 

Similaire à I got 99 problems, but ReST ain't one (20)

Why Integrate using an API? | MuleSoft
Why Integrate using an API? | MuleSoftWhy Integrate using an API? | MuleSoft
Why Integrate using an API? | MuleSoft
 
Progressive web apps
Progressive web appsProgressive web apps
Progressive web apps
 
ASP.NET WEB API Training
ASP.NET WEB API TrainingASP.NET WEB API Training
ASP.NET WEB API Training
 
Service Discovery Like a Pro
Service Discovery Like a ProService Discovery Like a Pro
Service Discovery Like a Pro
 
Deploy and Destroy: Testing Environments - Michael Arenzon - DevOpsDays Tel A...
Deploy and Destroy: Testing Environments - Michael Arenzon - DevOpsDays Tel A...Deploy and Destroy: Testing Environments - Michael Arenzon - DevOpsDays Tel A...
Deploy and Destroy: Testing Environments - Michael Arenzon - DevOpsDays Tel A...
 
Design Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John HardyDesign Summit - RESTful API Overview - John Hardy
Design Summit - RESTful API Overview - John Hardy
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
11 asp.net web api
11 asp.net web api11 asp.net web api
11 asp.net web api
 
Four Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, AsyncFour Times Microservices - REST, Kubernetes, UI Integration, Async
Four Times Microservices - REST, Kubernetes, UI Integration, Async
 
Adriano Di Luzio - Davvy - PyconSEI Talk
Adriano Di Luzio - Davvy - PyconSEI TalkAdriano Di Luzio - Davvy - PyconSEI Talk
Adriano Di Luzio - Davvy - PyconSEI Talk
 
Building Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in RailsBuilding Mobile Friendly APIs in Rails
Building Mobile Friendly APIs in Rails
 
HTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & socketsHTML5 tutorial: canvas, offfline & sockets
HTML5 tutorial: canvas, offfline & sockets
 
Node.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale WebinarNode.js Build, Deploy and Scale Webinar
Node.js Build, Deploy and Scale Webinar
 
About REST & Symfony
About REST & SymfonyAbout REST & Symfony
About REST & Symfony
 
Unit 02: Web Technologies (2/2)
Unit 02: Web Technologies (2/2)Unit 02: Web Technologies (2/2)
Unit 02: Web Technologies (2/2)
 
Integrating with SAP FIX and HL7
Integrating with SAP FIX and HL7Integrating with SAP FIX and HL7
Integrating with SAP FIX and HL7
 
The Evolving Security Environment For Web Services
The Evolving Security Environment For Web ServicesThe Evolving Security Environment For Web Services
The Evolving Security Environment For Web Services
 
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
Building Web Services with Zend Framework (PHP Benelux meeting 20100713 Vliss...
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2
 
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
 

Plus de Adrian Cole

Plus de Adrian Cole (6)

HTTP/2 What's inside and Why
HTTP/2 What's inside and WhyHTTP/2 What's inside and Why
HTTP/2 What's inside and Why
 
Efficient HTTP Apis
Efficient HTTP ApisEfficient HTTP Apis
Efficient HTTP Apis
 
Using and contributing to the next Guice
Using and contributing to the next GuiceUsing and contributing to the next Guice
Using and contributing to the next Guice
 
jclouds overview
jclouds overviewjclouds overview
jclouds overview
 
Living on the edge
Living on the edgeLiving on the edge
Living on the edge
 
When small problems become big problems
When small problems become big problemsWhen small problems become big problems
When small problems become big problems
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 

I got 99 problems, but ReST ain't one

  • 1. > GET /problems/MONEY HTTP/1.1 I GOT 99 PROBLEMS > Host: localhost > Accept: */* < HTTP/1.1 200 OK > GET /problems/POWER HTTP/1.1 > Host: localhost BUT REST AINT ONE > Accept: */* < HTTP/1.1 200 OK > GET /problems/REST HTTP/1.1 > Host: localhost > Accept: */* @adrianfcole < HTTP/1.1 404 Not Found
  • 2. PROBLEMS ➡Why API ➡ReST vs other HTTP APIs? ➡Design Patterns vs Real APIs
  • 3. WHO IS THIS GUY? ๏ @adrianfcole ๏ architect CloudHub at MuleSoft ๏founder jclouds
  • 4. THANKS ★ api-craft ★ mattstep ★ gtcampbell ★ mulies
  • 5. WHY WE API photo copyright 2005 Sony Pictures
  • 7. HOW TO ReST SOAP API
  • 8. HOW TO ReST WS-* API
  • 9. HOW TO ReST ReST ish API
  • 10. HOW TO not-soap HATEOAS REST
  • 11. To the Level 0: Level 1: Swamp of POX Resources glory Level 2: Level 3: Verbs Hypermedia of REST
  • 12. > POST /api HTTP/1.1 > <SOAP-ENV:Envelope ...> <SOAP-ENV:Body> <m:getAvailableDataSources xmlns:m=" Swamp <group xsi:type="xsd:string">ArcWe <service xsi:type="xsd:string">Map <token xsi:type="xsd:string">MyTok </m:getAvailableDataSources> of POX </SOAP-ENV:Body> </SOAP-ENV:Envelope> < HTTP/1.1 200 OK < <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope ...> <soap:Body> <n:getAvailableDataSourcesResponse x <Result href="#id0"/> </n:getAvailableDataSourcesResponse> All things go over the <id0 id="id0" soapenc:root="0" xsi:t soapenc:arrayType="ns5:DataSource[21]"> same endpoint as XML <i href="#id1"/> --snip--
  • 13. RESOURCES > GET https://ec2.amazonaws.com/?Action=DeleteVolume&VolumeId=vol-4282672b HTTP/1.1 < HTTP/1.1 200 OK <DeleteVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2012-08-15/"> <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> <return>true</return> </DeleteVolumeResponse> --snip-- Many URIs, same HTTP method Side-effects are API-specific
  • 14. VERBS > HEAD https://mybucket.s3.amazonaws.com/ HTTP/1.1 < HTTP/1.1 200 OK HTTP verbs mean more than CRUD Status codes are meaningful
  • 15. HYPERMEDIA > GET https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a50f-9dd4e03546 > Accept: application/vnd.vmware.vcloud.catalogItem+xml < HTTP/1.1 200 OK < Content-Type: application/vnd.vmware.vcloud.catalogItem+xml;version=1.0 <CatalogItem xmlns="http://www.vmware.com/vcloud/v1" name="mycatalog" type=" href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a5 <Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcloud/api/v1.0/catalog/7f192dfe-00d1-42f2-9f76-9360 <Link rel="edit" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a50f- <Link rel="remove" href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a50f-9 --snip-- Discoverability, Self-documenting
  • 16. What makes it HYPER? ➡Base Type ➡Links
  • 17. abort add alternate disk:attach TRANSITIONS edit remove task All transitions are discoverable via links
  • 18. CONTENT NEGOTIATION ➡ Client supplies representation in Accept header ➡On change, update mediatype name or annotate via ;version=N.N ➡On overhaul, bump global version Accept: application/vnd.VENDOR.PRODUCT.RESOURCE+xml
  • 19. Representing HyperMedia Extend Atom Opaque + Link Headers HAL ...
  • 20. EXTEND ATOM Vendor Type, Link elements < HTTP/1.1 200 OK < Content-Type: application/vnd.vmware.vcloud.catalogItem+xml;version=1.0 <CatalogItem xmlns="http://www.vmware.com/vcloud/v1" name="mycatalog" type=" href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a5 <Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcloud/api/v1.0/catalog/7f192dfe-00d1-42f2-9f76-9360 <Link rel="edit" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a50f- <Link rel="remove" href="https://vcloud/api/v1.0/catalogItem/1c01defe-1111-42ac-a50f-9 --snip-- domain-specific types inherits link semantics from Atom
  • 21. Link Headers Opaque Type, Link elements < HTTP/1.1 200 OK < Content-Type: image/jpeg Link: </images/foo.png>; rel="alternate"; type=”image/png” 010101010101010101 --snip-- supports binary types facilitates intermediaries
  • 22. Hypertext Application Language Mix-in hypermedia controls into base type embed resources for efficiency < HTTP/1.1 200 OK < Content-Type: application/hal+json { _links: { self: { href: '/example', } }, _embedded: {}, name: 'foo', --snip-- domain-specific type agnostic
  • 23. ELEGENT clients always know transitions self-documenting LETS USE and discoverable version at HATEOAS media-type granularity
  • 25. Level 2 optimizes for Coarse Grained Versions CRUD++ Limited Representations Today’s Tools Simplicity over Elegance
  • 26. IS IT ALL JUST PRICKLES & GOO?
  • 27. can we have both?
  • 28. There Domain Style Base Format is no State Transfer Level2 App Flow Design plus stuff like errors
  • 29. REST Design tools ➡Apiary ➡Swagger ➡iodocs
  • 30. GOOD API DESIGNERS UNDERSTAND how it is used, and who will use it importance of iterations and feedback impacts to design beyond development there’s no golden hammer (not even mongo)
  • 31. TWITTER IS NOT HATEOAS REST SEARCH STREAM
  • 32. AWS IS NOT REST AWS IS GOOD api designed to parse quickly simple extension (add new key) consistent security model bulk ops
  • 33. WebSockets ain’t even HTTP! Handshake is HTTPish Discoverable like ReST Full-Duplex Uncode or Binary Messages TCP Protocol
  • 34. GOOD REST APIs Are consciously designed Version at the right scope Don’t leak implementation details Use auth models relevant to consumer Are well documented with examples
  • 35. What now? ➡join api-craft ➡read The REST API Design Handbook ➡read Building Hypermedia APIs... ➡socialize your ideas Thank you!

Notes de l'éditeur

  1. \n
  2. we need to define what we are talking about, and then evaluate patterns\n
  3. \n
  4. \n
  5. Now that we are here, we underscore motivations to even bother with.\n
  6. A Web API Study: Hurwitz;\n leads to integration -&gt; stronger ecosystem -&gt; more value\n &gt; devices and applications in the ecosystem\n\n
  7. At first glance, we might think how to present an api is rest vs soap\n
  8. it might really be the aspects of WS-* that would make such a decision, such as WS-Security, AtomicTransaction, ReliableMessaging\n
  9. Say we chose, ReST.. the thing is that ReST means a lot to many people\n
  10. ends up being something between soap and hypertext driven\n
  11. Leonard Richardson circa 2008 Maturity Model\n
  12. Easiest example of POX is tunneling commands over a single http request/response paradigm\n
  13. many uris, but a single invocation method. operations might be encoded in parameters, and resource might be mixed in with them\n
  14. HEAD is metadata; PATCH is for update; PUT is replace; POST -&gt; RPC/create\natomicity underpins idempotence; by spec POST can affect multiple resources, but most others (except notably trace,options) only apply to the resource identified by the href\n
  15. \n
  16. \n
  17. HATEOAS is basically a state machine. Your responsibility is to not attempt any transition undefined in links\n
  18. New resources types can be added without breaking client, as can new fields/links\nabove pattern recommended by: Dan Feist\n\nOther option you can use is link with profile relation.\n
  19. There are other ways, too...\nxlink can decorate in namespace of xml, but doesn&amp;#x2019;t expose representations\ncollection+json is an interesting approach for managing collections (includes its own data format)\n
  20. \n
  21. ex. cache intermediaries http://tools.ietf.org/html/draft-nottingham-linked-cache-inv-03\n
  22. define domain-specific type using type link parameter, or via custom rel or profile link (preferred)\nhttp://tools.ietf.org/id/draft-kelly-json-hal\nalso supports templated urls such as queries\n
  23. \n
  24. sometimes domain models are well defined, so the added value may be lost on the user\n
  25. Leonard Richardson circa 2008 Maturity Model\n
  26. Prickles &amp; Goo: Alan Watts Trey Parker Matt Stone\nIs culture behind adoption of a particular rest approach? Even if the approach is correct, can you persuade devs to adopt something they don&amp;#x2019;t want?\n
  27. we are probably at various intervals on the same plane. more detail == overly complex. not enough == naive.\n
  28. Amundsen, Mike (2011-11-22). Building Hypermedia APIs with HTML5 and Node (p. 20). OReilly Media - A. Kindle Edition. \n
  29. http://apiary.io/ &lt; markdown extension describes behavior, generates mock and tests it\nhttp://swagger.wordnik.com/ &lt;- json describes resource, apis, models, generates many clients\nhttps://github.com/mashery/iodocs &lt;- json describes service, apis, creates javascript client\n
  30. database details such as pagination, etc\n\ntransition to a design that isn&amp;#x2019;t rest (aws)\n
  31. original has been around since 2008, latest update mainly addressed oauth and rate limiting changes; thanks Greg Campbell for insight; api is versioned as 1.1, but includes 3 distinct apis\naside: search can be modeled in HATEOAS, where POST is creation of search results, HEAD returns lifespan, etc\n\n
  32. Many amazon web services do not even follow type 2 classifications, yet they are widely adopted, and successful.. why is that? why do they not use rest?\n\ngurupa is the amazon http server, which is tuned for query parsing. language for extending it is simple (add a key), so parsing it to verify signature is just sort the keys and sign it.\n\nbulk ops like s3 multi-delete help deal with very large problems.\n
  33. Ex. ELB you have to use TCP/SSL as this is not a HTTP compatible protocol\nconsider impact for example lack of origin IP address, sticky session\nnew set of gateway products will emerge to support WebSockets\n
  34. database details such as pagination, etc\n
  35. \n