SlideShare ist ein Scribd-Unternehmen logo
1 von 79
Downloaden Sie, um offline zu lesen
Five API Styles
Ronnie Mitra
Director of Design
@mitraman
ronnie.mitra@ca.com
Why API Styles?
▪ Architects of networked/distributed applications have many
decisions to make
▪ Technology changing quickly, new implementations every
year:
– graphQL, gRPC, Kafka, HAL+Forms
▪ Which models of component interaction work best?
The Value of Styles for the Designer
Design a Victorian Style
House
Design a House
Styles, Not Standards
▪ Standards
“Usually a formal document that establishes uniform
engineering or technical criteria, methods, processes and
practices.”
Standards
▪ IETF (HTTP, URI, Basic Auth, etc.)
▪ W3C (SOAP, HTML, RDF, etc.)
▪ OASIS (ebXML, DocBook, WS-Security, etc.)
The Value of Styles for the Designer
▪ Styles describe:
– Characteristics
– Vocabulary
– Constraints
▪ The style is a loose set of rules – the rules become a guide
▪ Styles help designers communicate
Tunnel Style
URI Style
Hypermedia Style
Event Driven Style
Query Style
Style Implementation Considerations
Five properties to consider:
▪ Scalability
▪ Usability
▪ Changeability
▪ Performance
▪ Reliability
Tunnel Style
Tunnel Style: Overview
▪ Application Layer Protocol with a type system and operations
▪ HTTP is not usually required (protocol agnostic)
▪ RPC Interaction
▪ Examples:
– XML-RPC (1998)
– SOAP 1.0 (1999)
– SOAP 1.2 (2003)
– JSON-RPC (2005)
– gRPC (2016)
Tunnel Style: Characteristics
▪ Type and Specification Driven (XML-*, WS-*, Protocol Buffers)
▪ Procedure/Operation based design (“RPC”)
▪ Similar to imperative programming interfaces
Tunnel Style: Primary Constraint
No dependencies on transport layer protocol
Message
HTTP MQ RAW TCP/IP
Client Server
Tunnel Style: Common Implementation Model
Client
Proxy
Service
Proxy
procedure
call
Tooling
Tooling
Interface
Definition
Tunnel Style: Benefits
▪ RPC style is familiar to many developers and architects
▪ Support for heterogeneous networks
▪ Messages can be optimized for point-to-point performance
(reduced size, reduced latency)
Tunnel Style: Limitations
▪ Ignores HTTP features (caching, etc.)
▪ Limited tooling in mobile and web stacks
▪ Change is often costly (highly typed, tightly-coupled)
URI Style
URI Style: Overview
▪ Uses Create, Read, Update, Delete (CRUD) interaction pattern
▪ URI points to a target
▪ Uses HTTP only
URI Style: Characteristics
▪ Use HTTP standard
▪ Object first design
▪ Convention driven
▪ Similar to data object interactions (DAO)
URI Style: Primary Constraint
▪ Interactions must use the CRUD Pattern
CREATE
READ
UPDATE
DELETE
Target Resource
URI Style: Example
▪ GET is used for Retrieval (Read)
▪ http://myapi.com/students points to a collection of student
records
▪ This request means “retrieve a list of student records”
GET http://myapi.com/students
URI Style: Protocol Stack
HTTP (transport)
RFC 7231 et al
URI (for identification)
RFC 3986
MIME (for representation)
XML, JSON, CSV, etc…
URI Style: Common Implementation
Client ServerURIobject
URI Style: Ideal for Data-Centric APIs
DATA-CENTRIC API
Backend
(server)
Frontend
(client)
APPLICATION LOGIC
INPUT HANDLING
LAYOUT IMAGES TEXT
WEATHER DATA
URI Style: Benefits
▪ HTTP path & query is a “well known” – improved usability for
many developers
▪ CRUD pattern is simple and a good fit for “data service”
pattern
▪ Large ecosystem of tools and frameworks today
URI Style: Limitations
▪ CRUD pattern is limited
▪ URI modelling is not standard – every API is a “snowflake”
– Internal domains can benefit from a style guide
– External domains (partner/public) may suffer
▪ Can be “chatty” (esp. when the object passing pattern is used)
▪ API changes usually require client changes, cost is magnified
by scale of client components
Hypermedia Style
Hypermedia Style: Overview
▪ An API with hypermedia features
▪ A browser-like experience for machines
▪ Implemented with links and forms
▪ Example:
– REST (Roy Fielding dissertation)
Hypermedia Style: Characteristics
▪ Focus on transitions
▪ URI is not an object key
▪ Messages are self-documenting
Hypermedia Style: Primary Constraint
▪ Uniform Interface
– Identification of resources
– Manipulation of resources through representations
– Self-descriptive messages
– Hypermedia as the engine of application state
Hypermedia Style: Protocol Stack
Transport Protocol
HTTP, COAP, etc…
Media Type
HTML, ATOM, HAL+JSON, Collection+JSON, etc..
Profiles and Link Relations
hCard, next, prev, etc..
Hypermedia Style: Common Implementation
Client Server
data +
links
templated
input
Hypermedia Style Example: Links
▪ Links tell the client what it can do next
<html>
<body>
<h1>Student Records</h1>
<a href=“/detail?id=3”>Ronnie Mitra</a>
</body>
</html>
Hypermedia Style Example: Links in JSON
{
“name”: “Ronnie”,
“enrollment-year”: “2014”
}
A URI Style JSON Response
Hypermedia Style Example: Links in JSON
{
“name”: “Ronnie”,
“enrollment-year”: “2014”
}
{
“name”: “Ronnie”,
“enrollment-year”: “2014”,
“_address_details”: “/student/ronnie/address”
}
A URI Style JSON Response
A Hypermedia Style JSON Response
Hypermedia Style Example: Generic Data
{
“name”: “Ronnie”,
“enrollment-year”: “2014”,
“_address_details”: “/student/ronnie/address”
}
Hypermedia Style Example: Generic Data
{
“data”: [
{“name”: “student-name”, “value”: “Ronnie”},
{“name”: “enrollment-year”, “value”: “2014”}
],
“_address_details”: “/student/ronnie/address”
}
Hypermedia Style Example: Generic Links
{
“data”: [
{“name”: “student-name”, “value”: “Ronnie”},
{“name”: “enrollment-year”, “value”: “2014”}
],
“_address_details”: “/student/ronnie/address”
}
Hypermedia Style Example: Generic Links
{
“data”: [
{“name”: “student-name”, “value”: “Ronnie”},
{“name”: “enrollment-year”, “value”: “2014”}
],
“_links”: [
{“rel”: “address”, “href”: “/student/ronnie/address”}
]
}
Hypermedia Style: State Machine
▪ Each message represents the current state of the application
▪ Links tell the client what it can do next
▪ The client changes application state by following links
List of Student
Records
You
are
here
Add a new record
See list of schools
Hypermedia Style: Server to Server
Hypermedia ServerMachine Client
LOGIC WEATHER DATA
APPLICATION LOGICSEMANTICS
Hypermedia Style: Mobile Client
INPUT HANDLING
LAYOUT IMAGES TEXT
WEATHER DATA
APPLICATION LOGIC
Hypermedia ServerHuman Facing Client
SEMANTICS
Hypermedia Style: “Browser” Client
INPUT HANDLING
LAYOUT IMAGES TEXT
WEATHER DATA
APPLICATION LOGIC
Hypermedia ServerHuman Facing Client
Hypermedia Style: Benefits
▪ Applications are easier to change (less client code changes
required)
▪ Favours long running and large scale applications
▪ Takes advantage of the WWW architecture
Hypermedia Style: Limitations
▪ Short-term benefits are limited – big up front cost today
▪ Assumed “esoteric”, “too hard”, etc.
▪ Clients are non-trivial to build
▪ Messages are verbose – not optimized for message size
Query Style
Query Style: Overview
▪ Interaction optimized and standardized for querying functions
▪ Learn the location of API and run queries against the data
▪ Suitable for any transport protocol that supports client-server
interactions (usually supports HTTP)
▪ Examples:
– graphQL
– sparQL
– ODBC
– ql.io
Query Style: Characteristics
▪ Treats the API as a data source
▪ A Query Language is defined and standardized (not just
generic support)
▪ Focus is on reading and writing data
Query Style: Primary Constraint
▪ Interactions and data model are constrained by the query
language
Data ModelQuery Language
Query Style Example: GraphQL
POST http://myapi.com/graphql
{
“query”: “
{
student {
name
age
}
}
”
}
Query Style: Protocol Stack
Query Interface Language
X, Y, etc…
Data Model
Relational, CRUD, etc…
Client-Server Transport Protocol
Query Style: Common Implementation
▪ Implement data transformation components on the server to support the
standardized Data Model
▪ Bind a Query Language API to the data transformation
▪ Client implements a client query library
▪ Client uses query client to work with data (in RPC fashion)
Client Server
Data
Transformerqueries Query APIQuery
Client
Query Style: Benefits
▪ All clients and servers that support query standard can
interact easily
▪ Standardizing on language makes tooling possible:
– Data inspection tools
– Frameworks and libraries for clients and servers
▪ Ideal choice for data-centric apps (e.g. mobile apps)
Query Style: Limitations
▪ Features are limited to query language functions
– How do you mutate data?
– What is the performance profile?
– How can you perform non-query operations?
▪ Difficult to use if data model doesn’t match the client’s needs
▪ Changes to data model may require client code changes
Event-Driven Style
Event-Driven Style: Overview
▪ Fire and receive “events”
▪ Asynchronous interactions (one-way)
▪ Sender/Receiver instead of Client/Server
▪ Examples:
– Message Oriented Middleware (e.g. MQ)
– Reactive Programming
– Service Mesh
Event-Driven Style: Protocol Stack
Transport Protocol
HTTP, MQ, TCP/IP, etc…
Event
Custom Design
Event Infrastructure
Event-Driven Style: Constraints and Characteristics
▪ Senders have no knowledge of receivers (e.g. write to queue
or publish to topic)
▪ Event receivers “react” to events
▪ Events represent change to a state
▪ Events can have multiple receivers (subscribers)
EVENT RECEIVER
Event-Driven Style: Primary Constraint
▪ Events occur in the past
▪ You can’t change the past!
TIME
EVENT
Event-Driven Style: Common Implementation
▪ Identify state change events
▪ Register event listener(s)
▪ Sender sends notification when state changes
▪ Event manager transmits notifications
▪ Receiver(s) handle events
Event
Manager
Receiver
Receiver
Sender
Event-Driven Style: Notification Design
▪ Event data may include:
– Target or source of event
– Type of event
– Event details
– Contextual information
{
“event” : {
“name”: “RecordAdded”,
“source”: “StudentRecords”,
“location” : “/students/1883”,
“editing” : “true”
}
}
Event-Driven Style: Internet of Things
▪ Increased use of event driven style in IoT
▪ The real world is based on events
▪ Pervasive technology is primarily event based
LIGHT!
Sensor Event Handler
Event-Driven Style: Microservices
▪ Inter-Service communication (behind firewall)
▪ Cache freshness
▪ Data synchronization / eventual consistency
Data
Changed!
Data Store Lightweight Service
Event-Driven Style: Event Sourcing / Event Store
▪ Persist data state change events
▪ The history of all events is the
“present” state of data
▪ Makes distributed data
architectures easier to implement
Student Created(id=4)
Name Changed(id=4,‘Tin’)
student.id = 4
student.name = Tan
Student.age = 15
student.id = 4
student.name = ‘’
Student.age = ‘’
Age Changed(id=4,15)
Event-Driven Style: Benefits
▪ Components and data can be de-coupled and de-centralized
▪ Ideal for transmitting many changes continuously over time
(e.g. streaming)
▪ De-centralized messaging system offers added reliability
▪ “Reactive” event style offers improved perceived UI
performance
Event-Driven Style: Limitations
▪ Can only record what has already happened (e.g. how do you
perform validation?)
▪ Increases the complexity of the architecture and
infrastructure
▪ Performance, scalability and reliability limited by event
infrastructure
Styles as Metaphors
Style Metaphor
Tunnel Style Procedural programming
URI Style Data Access Objects
Hypermedia Browsing the web
Query Database Query Languages
Event Based Event based programming (e.g. GUI)
A Tunnel Style Example: Microservices Composition
A Tunnel Style Example: Microservices Composition
▪ Publishing new interfaces is cheap and easy for service teams
▪ Service composer team is only client and prepared to rebuild
their component after any service changes (warning:
potential bottleneck)
▪ External component is shielded from change
▪ RPC implementation can be chosen for optimized messaging
speed (e.g. GRPC/Thrift)
URI Style Example: Public Banking API
URI Style Example: Public Banking API
▪ Developers outside the bank will find the URI style familiar
▪ Many of the interactions are well suited for the CRUD pattern
– View transactions
– View balance
– Create payment
▪ Little commercial motivation to make it easy to change API
providers
Hypermedia Style Example: UX Fragmentation
Hypermedia Style Example: UX Fragmentation
▪ Manage and deploy a single client application
▪ Change UI and workflow without re-deploying client
▪ Works best when client development owned by organization
▪ Works best when cheap UX generation is a market
differentiator
Query Style Example: Social Graph Data
Query Style Example: Social Graph Data
▪ Query language optimized for data type
▪ Client development is easier
▪ Backend is optimized for fast reads and complex queries
Event Driven Example: Decentralized Data
Event Driven Example: Decentralized Data
▪ Makes it easier to manage and deploy services independently
▪ Distance between components is small (intranet, not internet)
▪ Data can be “stale”
▪ Libraries/SDK/Sidecars are provided to reduce dev. cost
General Advice for Styles
URI Style
Tunnel Style ▪ Typed interaction, gRPC gaining popularity for
internal use
Hypermedia Style ▪ Most scalable and change-friendly, but least
conventional
▪ The default style for web based APIs
Query Style ▪ Gaining popularity, ideal for internal, data-centric
apps
Event Driven Style ▪ Loose coupled, centralized – good for internal use,
not a good choice for public APIs
Use Your Head
▪ Implementations may borrow from multiple styles
▪ Your system will probably contain more than one API style and
needs will change over time
▪ Start with a style that makes sense for your situation – not
necessarily the one you are “supposed” to use
Five API Styles
Ronnie Mitra
Director of Design
@mitraman
ronnie.mitra@ca.com

Weitere ähnliche Inhalte

Was ist angesagt?

GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...luisw19
 
gRPC Design and Implementation
gRPC Design and ImplementationgRPC Design and Implementation
gRPC Design and ImplementationVarun Talwar
 
RESTful services
RESTful servicesRESTful services
RESTful servicesgouthamrv
 
Drone Data Flowing Through Apache NiFi
Drone Data Flowing Through Apache NiFiDrone Data Flowing Through Apache NiFi
Drone Data Flowing Through Apache NiFiTimothy Spann
 
Introducing Apache Airflow and how we are using it
Introducing Apache Airflow and how we are using itIntroducing Apache Airflow and how we are using it
Introducing Apache Airflow and how we are using itBruno Faria
 
Diferenças entre SOAP e REST
Diferenças entre SOAP e RESTDiferenças entre SOAP e REST
Diferenças entre SOAP e RESTtiagolimas
 
JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The BasicsJeff Fox
 
From Data Science to MLOps
From Data Science to MLOpsFrom Data Science to MLOps
From Data Science to MLOpsCarl W. Handlin
 
Next-level integration with Spring Data Elasticsearch
Next-level integration with Spring Data ElasticsearchNext-level integration with Spring Data Elasticsearch
Next-level integration with Spring Data ElasticsearchElasticsearch
 
Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST APIFabien Vauchelles
 
Building Better Data Pipelines using Apache Airflow
Building Better Data Pipelines using Apache AirflowBuilding Better Data Pipelines using Apache Airflow
Building Better Data Pipelines using Apache AirflowSid Anand
 
MLops workshop AWS
MLops workshop AWSMLops workshop AWS
MLops workshop AWSGili Nachum
 
AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...
AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...
AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...Amazon Web Services
 
Intro to Airflow: Goodbye Cron, Welcome scheduled workflow management
Intro to Airflow: Goodbye Cron, Welcome scheduled workflow managementIntro to Airflow: Goodbye Cron, Welcome scheduled workflow management
Intro to Airflow: Goodbye Cron, Welcome scheduled workflow managementBurasakorn Sabyeying
 
Apache Camel K - Copenhagen
Apache Camel K - CopenhagenApache Camel K - Copenhagen
Apache Camel K - CopenhagenClaus Ibsen
 

Was ist angesagt? (20)

GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
GraphQL as an alternative approach to REST (as presented at Java2Days/CodeMon...
 
gRPC Design and Implementation
gRPC Design and ImplementationgRPC Design and Implementation
gRPC Design and Implementation
 
RESTful services
RESTful servicesRESTful services
RESTful services
 
Drone Data Flowing Through Apache NiFi
Drone Data Flowing Through Apache NiFiDrone Data Flowing Through Apache NiFi
Drone Data Flowing Through Apache NiFi
 
Airflow presentation
Airflow presentationAirflow presentation
Airflow presentation
 
GraphQL
GraphQLGraphQL
GraphQL
 
gRPC
gRPC gRPC
gRPC
 
Introducing Apache Airflow and how we are using it
Introducing Apache Airflow and how we are using itIntroducing Apache Airflow and how we are using it
Introducing Apache Airflow and how we are using it
 
Diferenças entre SOAP e REST
Diferenças entre SOAP e RESTDiferenças entre SOAP e REST
Diferenças entre SOAP e REST
 
JSON: The Basics
JSON: The BasicsJSON: The Basics
JSON: The Basics
 
From Data Science to MLOps
From Data Science to MLOpsFrom Data Science to MLOps
From Data Science to MLOps
 
Apache NiFi in the Hadoop Ecosystem
Apache NiFi in the Hadoop Ecosystem Apache NiFi in the Hadoop Ecosystem
Apache NiFi in the Hadoop Ecosystem
 
Next-level integration with Spring Data Elasticsearch
Next-level integration with Spring Data ElasticsearchNext-level integration with Spring Data Elasticsearch
Next-level integration with Spring Data Elasticsearch
 
Use Node.js to create a REST API
Use Node.js to create a REST APIUse Node.js to create a REST API
Use Node.js to create a REST API
 
Building Better Data Pipelines using Apache Airflow
Building Better Data Pipelines using Apache AirflowBuilding Better Data Pipelines using Apache Airflow
Building Better Data Pipelines using Apache Airflow
 
Rest api with node js and express
Rest api with node js and expressRest api with node js and express
Rest api with node js and express
 
MLops workshop AWS
MLops workshop AWSMLops workshop AWS
MLops workshop AWS
 
AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...
AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...
AWS Public Data Sets: How to Stage Petabytes of Data for Analysis in AWS (WPS...
 
Intro to Airflow: Goodbye Cron, Welcome scheduled workflow management
Intro to Airflow: Goodbye Cron, Welcome scheduled workflow managementIntro to Airflow: Goodbye Cron, Welcome scheduled workflow management
Intro to Airflow: Goodbye Cron, Welcome scheduled workflow management
 
Apache Camel K - Copenhagen
Apache Camel K - CopenhagenApache Camel K - Copenhagen
Apache Camel K - Copenhagen
 

Ähnlich wie Five API Styles

Building Software Backend (Web API)
Building Software Backend (Web API)Building Software Backend (Web API)
Building Software Backend (Web API)Alexander Goida
 
Restful web services with java
Restful web services with javaRestful web services with java
Restful web services with javaVinay Gopinath
 
Hypermedia for Machine APIs
Hypermedia for Machine APIsHypermedia for Machine APIs
Hypermedia for Machine APIsMichael Koster
 
HATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from RESTHATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from RESTelliando dias
 
Restful webservice
Restful webserviceRestful webservice
Restful webserviceDong Ngoc
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web APIBrad Genereaux
 
SOA1-Background.ppt SOFTWARE ORIENTED SERVICES AND ARCHITECTURE
SOA1-Background.ppt SOFTWARE ORIENTED SERVICES AND ARCHITECTURESOA1-Background.ppt SOFTWARE ORIENTED SERVICES AND ARCHITECTURE
SOA1-Background.ppt SOFTWARE ORIENTED SERVICES AND ARCHITECTUREAnyaForger34
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API RecommendationsJeelani Shaik
 
Service Oriented Architecture
Service Oriented Architecture Service Oriented Architecture
Service Oriented Architecture Prabhat gangwar
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Henry S
 
Automating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight SemanticsAutomating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight Semanticsmmaleshkova
 
Rest api webinar(3)
Rest api webinar(3)Rest api webinar(3)
Rest api webinar(3)WSO2
 
REST & API Management with the WSO2 ESB
REST & API Management with the WSO2 ESBREST & API Management with the WSO2 ESB
REST & API Management with the WSO2 ESBWSO2
 

Ähnlich wie Five API Styles (20)

Building Software Backend (Web API)
Building Software Backend (Web API)Building Software Backend (Web API)
Building Software Backend (Web API)
 
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
 
Linked services
Linked servicesLinked services
Linked services
 
Restful web services with java
Restful web services with javaRestful web services with java
Restful web services with java
 
Hypermedia for Machine APIs
Hypermedia for Machine APIsHypermedia for Machine APIs
Hypermedia for Machine APIs
 
HATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from RESTHATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from REST
 
Restful webservice
Restful webserviceRestful webservice
Restful webservice
 
Introduction to the Web API
Introduction to the Web APIIntroduction to the Web API
Introduction to the Web API
 
L19 Application Architecture
L19 Application ArchitectureL19 Application Architecture
L19 Application Architecture
 
SOA1-Background.ppt SOFTWARE ORIENTED SERVICES AND ARCHITECTURE
SOA1-Background.ppt SOFTWARE ORIENTED SERVICES AND ARCHITECTURESOA1-Background.ppt SOFTWARE ORIENTED SERVICES AND ARCHITECTURE
SOA1-Background.ppt SOFTWARE ORIENTED SERVICES AND ARCHITECTURE
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
Api design part 1
Api design part 1Api design part 1
Api design part 1
 
Service Oriented Architecture
Service Oriented Architecture Service Oriented Architecture
Service Oriented Architecture
 
Web Standards in FLOSS development
Web Standards in FLOSS developmentWeb Standards in FLOSS development
Web Standards in FLOSS development
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
 
SOA Testing
SOA TestingSOA Testing
SOA Testing
 
Automating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight SemanticsAutomating the Use of Web APIs through Lightweight Semantics
Automating the Use of Web APIs through Lightweight Semantics
 
Rest api webinar(3)
Rest api webinar(3)Rest api webinar(3)
Rest api webinar(3)
 
REST & API Management with the WSO2 ESB
REST & API Management with the WSO2 ESBREST & API Management with the WSO2 ESB
REST & API Management with the WSO2 ESB
 
Overview of java web services
Overview of java web servicesOverview of java web services
Overview of java web services
 

Mehr von ronniemitra

People Platform Patterns
People Platform PatternsPeople Platform Patterns
People Platform Patternsronniemitra
 
People Platform Patterns
People Platform PatternsPeople Platform Patterns
People Platform Patternsronniemitra
 
Programming the People Platform
Programming the People PlatformProgramming the People Platform
Programming the People Platformronniemitra
 
Banking APIs: A Fine Balance
Banking APIs: A Fine BalanceBanking APIs: A Fine Balance
Banking APIs: A Fine Balanceronniemitra
 
Sketching Web APIs
Sketching Web APIsSketching Web APIs
Sketching Web APIsronniemitra
 
A Simpler Time: A study of complexity in APIs
A Simpler Time: A study of complexity in APIsA Simpler Time: A study of complexity in APIs
A Simpler Time: A study of complexity in APIsronniemitra
 

Mehr von ronniemitra (7)

People Platform Patterns
People Platform PatternsPeople Platform Patterns
People Platform Patterns
 
People Platform Patterns
People Platform PatternsPeople Platform Patterns
People Platform Patterns
 
How We Learn
How We LearnHow We Learn
How We Learn
 
Programming the People Platform
Programming the People PlatformProgramming the People Platform
Programming the People Platform
 
Banking APIs: A Fine Balance
Banking APIs: A Fine BalanceBanking APIs: A Fine Balance
Banking APIs: A Fine Balance
 
Sketching Web APIs
Sketching Web APIsSketching Web APIs
Sketching Web APIs
 
A Simpler Time: A study of complexity in APIs
A Simpler Time: A study of complexity in APIsA Simpler Time: A study of complexity in APIs
A Simpler Time: A study of complexity in APIs
 

Kürzlich hochgeladen

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
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
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Kürzlich hochgeladen (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
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)
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
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
 
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
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
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
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.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
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Five API Styles

  • 1. Five API Styles Ronnie Mitra Director of Design @mitraman ronnie.mitra@ca.com
  • 2. Why API Styles? ▪ Architects of networked/distributed applications have many decisions to make ▪ Technology changing quickly, new implementations every year: – graphQL, gRPC, Kafka, HAL+Forms ▪ Which models of component interaction work best?
  • 3. The Value of Styles for the Designer Design a Victorian Style House Design a House
  • 4. Styles, Not Standards ▪ Standards “Usually a formal document that establishes uniform engineering or technical criteria, methods, processes and practices.”
  • 5. Standards ▪ IETF (HTTP, URI, Basic Auth, etc.) ▪ W3C (SOAP, HTML, RDF, etc.) ▪ OASIS (ebXML, DocBook, WS-Security, etc.)
  • 6. The Value of Styles for the Designer ▪ Styles describe: – Characteristics – Vocabulary – Constraints ▪ The style is a loose set of rules – the rules become a guide ▪ Styles help designers communicate
  • 7. Tunnel Style URI Style Hypermedia Style Event Driven Style Query Style
  • 8. Style Implementation Considerations Five properties to consider: ▪ Scalability ▪ Usability ▪ Changeability ▪ Performance ▪ Reliability
  • 10. Tunnel Style: Overview ▪ Application Layer Protocol with a type system and operations ▪ HTTP is not usually required (protocol agnostic) ▪ RPC Interaction ▪ Examples: – XML-RPC (1998) – SOAP 1.0 (1999) – SOAP 1.2 (2003) – JSON-RPC (2005) – gRPC (2016)
  • 11. Tunnel Style: Characteristics ▪ Type and Specification Driven (XML-*, WS-*, Protocol Buffers) ▪ Procedure/Operation based design (“RPC”) ▪ Similar to imperative programming interfaces
  • 12. Tunnel Style: Primary Constraint No dependencies on transport layer protocol Message HTTP MQ RAW TCP/IP
  • 13. Client Server Tunnel Style: Common Implementation Model Client Proxy Service Proxy procedure call Tooling Tooling Interface Definition
  • 14. Tunnel Style: Benefits ▪ RPC style is familiar to many developers and architects ▪ Support for heterogeneous networks ▪ Messages can be optimized for point-to-point performance (reduced size, reduced latency)
  • 15. Tunnel Style: Limitations ▪ Ignores HTTP features (caching, etc.) ▪ Limited tooling in mobile and web stacks ▪ Change is often costly (highly typed, tightly-coupled)
  • 17. URI Style: Overview ▪ Uses Create, Read, Update, Delete (CRUD) interaction pattern ▪ URI points to a target ▪ Uses HTTP only
  • 18. URI Style: Characteristics ▪ Use HTTP standard ▪ Object first design ▪ Convention driven ▪ Similar to data object interactions (DAO)
  • 19. URI Style: Primary Constraint ▪ Interactions must use the CRUD Pattern CREATE READ UPDATE DELETE Target Resource
  • 20. URI Style: Example ▪ GET is used for Retrieval (Read) ▪ http://myapi.com/students points to a collection of student records ▪ This request means “retrieve a list of student records” GET http://myapi.com/students
  • 21. URI Style: Protocol Stack HTTP (transport) RFC 7231 et al URI (for identification) RFC 3986 MIME (for representation) XML, JSON, CSV, etc…
  • 22. URI Style: Common Implementation Client ServerURIobject
  • 23. URI Style: Ideal for Data-Centric APIs DATA-CENTRIC API Backend (server) Frontend (client) APPLICATION LOGIC INPUT HANDLING LAYOUT IMAGES TEXT WEATHER DATA
  • 24. URI Style: Benefits ▪ HTTP path & query is a “well known” – improved usability for many developers ▪ CRUD pattern is simple and a good fit for “data service” pattern ▪ Large ecosystem of tools and frameworks today
  • 25. URI Style: Limitations ▪ CRUD pattern is limited ▪ URI modelling is not standard – every API is a “snowflake” – Internal domains can benefit from a style guide – External domains (partner/public) may suffer ▪ Can be “chatty” (esp. when the object passing pattern is used) ▪ API changes usually require client changes, cost is magnified by scale of client components
  • 27. Hypermedia Style: Overview ▪ An API with hypermedia features ▪ A browser-like experience for machines ▪ Implemented with links and forms ▪ Example: – REST (Roy Fielding dissertation)
  • 28. Hypermedia Style: Characteristics ▪ Focus on transitions ▪ URI is not an object key ▪ Messages are self-documenting
  • 29. Hypermedia Style: Primary Constraint ▪ Uniform Interface – Identification of resources – Manipulation of resources through representations – Self-descriptive messages – Hypermedia as the engine of application state
  • 30. Hypermedia Style: Protocol Stack Transport Protocol HTTP, COAP, etc… Media Type HTML, ATOM, HAL+JSON, Collection+JSON, etc.. Profiles and Link Relations hCard, next, prev, etc..
  • 31. Hypermedia Style: Common Implementation Client Server data + links templated input
  • 32. Hypermedia Style Example: Links ▪ Links tell the client what it can do next <html> <body> <h1>Student Records</h1> <a href=“/detail?id=3”>Ronnie Mitra</a> </body> </html>
  • 33. Hypermedia Style Example: Links in JSON { “name”: “Ronnie”, “enrollment-year”: “2014” } A URI Style JSON Response
  • 34. Hypermedia Style Example: Links in JSON { “name”: “Ronnie”, “enrollment-year”: “2014” } { “name”: “Ronnie”, “enrollment-year”: “2014”, “_address_details”: “/student/ronnie/address” } A URI Style JSON Response A Hypermedia Style JSON Response
  • 35. Hypermedia Style Example: Generic Data { “name”: “Ronnie”, “enrollment-year”: “2014”, “_address_details”: “/student/ronnie/address” }
  • 36. Hypermedia Style Example: Generic Data { “data”: [ {“name”: “student-name”, “value”: “Ronnie”}, {“name”: “enrollment-year”, “value”: “2014”} ], “_address_details”: “/student/ronnie/address” }
  • 37. Hypermedia Style Example: Generic Links { “data”: [ {“name”: “student-name”, “value”: “Ronnie”}, {“name”: “enrollment-year”, “value”: “2014”} ], “_address_details”: “/student/ronnie/address” }
  • 38. Hypermedia Style Example: Generic Links { “data”: [ {“name”: “student-name”, “value”: “Ronnie”}, {“name”: “enrollment-year”, “value”: “2014”} ], “_links”: [ {“rel”: “address”, “href”: “/student/ronnie/address”} ] }
  • 39. Hypermedia Style: State Machine ▪ Each message represents the current state of the application ▪ Links tell the client what it can do next ▪ The client changes application state by following links List of Student Records You are here Add a new record See list of schools
  • 40. Hypermedia Style: Server to Server Hypermedia ServerMachine Client LOGIC WEATHER DATA APPLICATION LOGICSEMANTICS
  • 41. Hypermedia Style: Mobile Client INPUT HANDLING LAYOUT IMAGES TEXT WEATHER DATA APPLICATION LOGIC Hypermedia ServerHuman Facing Client SEMANTICS
  • 42. Hypermedia Style: “Browser” Client INPUT HANDLING LAYOUT IMAGES TEXT WEATHER DATA APPLICATION LOGIC Hypermedia ServerHuman Facing Client
  • 43. Hypermedia Style: Benefits ▪ Applications are easier to change (less client code changes required) ▪ Favours long running and large scale applications ▪ Takes advantage of the WWW architecture
  • 44. Hypermedia Style: Limitations ▪ Short-term benefits are limited – big up front cost today ▪ Assumed “esoteric”, “too hard”, etc. ▪ Clients are non-trivial to build ▪ Messages are verbose – not optimized for message size
  • 46. Query Style: Overview ▪ Interaction optimized and standardized for querying functions ▪ Learn the location of API and run queries against the data ▪ Suitable for any transport protocol that supports client-server interactions (usually supports HTTP) ▪ Examples: – graphQL – sparQL – ODBC – ql.io
  • 47. Query Style: Characteristics ▪ Treats the API as a data source ▪ A Query Language is defined and standardized (not just generic support) ▪ Focus is on reading and writing data
  • 48. Query Style: Primary Constraint ▪ Interactions and data model are constrained by the query language Data ModelQuery Language
  • 49. Query Style Example: GraphQL POST http://myapi.com/graphql { “query”: “ { student { name age } } ” }
  • 50. Query Style: Protocol Stack Query Interface Language X, Y, etc… Data Model Relational, CRUD, etc… Client-Server Transport Protocol
  • 51. Query Style: Common Implementation ▪ Implement data transformation components on the server to support the standardized Data Model ▪ Bind a Query Language API to the data transformation ▪ Client implements a client query library ▪ Client uses query client to work with data (in RPC fashion) Client Server Data Transformerqueries Query APIQuery Client
  • 52. Query Style: Benefits ▪ All clients and servers that support query standard can interact easily ▪ Standardizing on language makes tooling possible: – Data inspection tools – Frameworks and libraries for clients and servers ▪ Ideal choice for data-centric apps (e.g. mobile apps)
  • 53. Query Style: Limitations ▪ Features are limited to query language functions – How do you mutate data? – What is the performance profile? – How can you perform non-query operations? ▪ Difficult to use if data model doesn’t match the client’s needs ▪ Changes to data model may require client code changes
  • 55. Event-Driven Style: Overview ▪ Fire and receive “events” ▪ Asynchronous interactions (one-way) ▪ Sender/Receiver instead of Client/Server ▪ Examples: – Message Oriented Middleware (e.g. MQ) – Reactive Programming – Service Mesh
  • 56. Event-Driven Style: Protocol Stack Transport Protocol HTTP, MQ, TCP/IP, etc… Event Custom Design Event Infrastructure
  • 57. Event-Driven Style: Constraints and Characteristics ▪ Senders have no knowledge of receivers (e.g. write to queue or publish to topic) ▪ Event receivers “react” to events ▪ Events represent change to a state ▪ Events can have multiple receivers (subscribers)
  • 58. EVENT RECEIVER Event-Driven Style: Primary Constraint ▪ Events occur in the past ▪ You can’t change the past! TIME EVENT
  • 59. Event-Driven Style: Common Implementation ▪ Identify state change events ▪ Register event listener(s) ▪ Sender sends notification when state changes ▪ Event manager transmits notifications ▪ Receiver(s) handle events Event Manager Receiver Receiver Sender
  • 60. Event-Driven Style: Notification Design ▪ Event data may include: – Target or source of event – Type of event – Event details – Contextual information { “event” : { “name”: “RecordAdded”, “source”: “StudentRecords”, “location” : “/students/1883”, “editing” : “true” } }
  • 61. Event-Driven Style: Internet of Things ▪ Increased use of event driven style in IoT ▪ The real world is based on events ▪ Pervasive technology is primarily event based LIGHT! Sensor Event Handler
  • 62. Event-Driven Style: Microservices ▪ Inter-Service communication (behind firewall) ▪ Cache freshness ▪ Data synchronization / eventual consistency Data Changed! Data Store Lightweight Service
  • 63. Event-Driven Style: Event Sourcing / Event Store ▪ Persist data state change events ▪ The history of all events is the “present” state of data ▪ Makes distributed data architectures easier to implement Student Created(id=4) Name Changed(id=4,‘Tin’) student.id = 4 student.name = Tan Student.age = 15 student.id = 4 student.name = ‘’ Student.age = ‘’ Age Changed(id=4,15)
  • 64. Event-Driven Style: Benefits ▪ Components and data can be de-coupled and de-centralized ▪ Ideal for transmitting many changes continuously over time (e.g. streaming) ▪ De-centralized messaging system offers added reliability ▪ “Reactive” event style offers improved perceived UI performance
  • 65. Event-Driven Style: Limitations ▪ Can only record what has already happened (e.g. how do you perform validation?) ▪ Increases the complexity of the architecture and infrastructure ▪ Performance, scalability and reliability limited by event infrastructure
  • 66. Styles as Metaphors Style Metaphor Tunnel Style Procedural programming URI Style Data Access Objects Hypermedia Browsing the web Query Database Query Languages Event Based Event based programming (e.g. GUI)
  • 67. A Tunnel Style Example: Microservices Composition
  • 68. A Tunnel Style Example: Microservices Composition ▪ Publishing new interfaces is cheap and easy for service teams ▪ Service composer team is only client and prepared to rebuild their component after any service changes (warning: potential bottleneck) ▪ External component is shielded from change ▪ RPC implementation can be chosen for optimized messaging speed (e.g. GRPC/Thrift)
  • 69. URI Style Example: Public Banking API
  • 70. URI Style Example: Public Banking API ▪ Developers outside the bank will find the URI style familiar ▪ Many of the interactions are well suited for the CRUD pattern – View transactions – View balance – Create payment ▪ Little commercial motivation to make it easy to change API providers
  • 71. Hypermedia Style Example: UX Fragmentation
  • 72. Hypermedia Style Example: UX Fragmentation ▪ Manage and deploy a single client application ▪ Change UI and workflow without re-deploying client ▪ Works best when client development owned by organization ▪ Works best when cheap UX generation is a market differentiator
  • 73. Query Style Example: Social Graph Data
  • 74. Query Style Example: Social Graph Data ▪ Query language optimized for data type ▪ Client development is easier ▪ Backend is optimized for fast reads and complex queries
  • 75. Event Driven Example: Decentralized Data
  • 76. Event Driven Example: Decentralized Data ▪ Makes it easier to manage and deploy services independently ▪ Distance between components is small (intranet, not internet) ▪ Data can be “stale” ▪ Libraries/SDK/Sidecars are provided to reduce dev. cost
  • 77. General Advice for Styles URI Style Tunnel Style ▪ Typed interaction, gRPC gaining popularity for internal use Hypermedia Style ▪ Most scalable and change-friendly, but least conventional ▪ The default style for web based APIs Query Style ▪ Gaining popularity, ideal for internal, data-centric apps Event Driven Style ▪ Loose coupled, centralized – good for internal use, not a good choice for public APIs
  • 78. Use Your Head ▪ Implementations may borrow from multiple styles ▪ Your system will probably contain more than one API style and needs will change over time ▪ Start with a style that makes sense for your situation – not necessarily the one you are “supposed” to use
  • 79. Five API Styles Ronnie Mitra Director of Design @mitraman ronnie.mitra@ca.com