A look at common API styles available today, a look back at historical API styles, and guidance for selecting the right API styles for your organization. Deep-dive of HTTP, mentioned in the presentation, can be found at: http://bit.ly/power-http
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
GlueCon 2018: Are REST APIs Still Relevant Today?
1. Are REST APIs Still Relevant Today?
16 May 2018 @ GlueCon
James Higginbotham
@launchany
2. 2
Introduction
• API Strategy, Program Execution, Training
– API design
– Microservices
– Containerization
• Recent Projects
– Enterprise IT
– SaaS
– From 100s to 10s of thousands of developers
– Variety of verticals
17. 17
The Basics: URLs, Headers, and HTTP Methods
Method Safe
(Side-
Effect?)
Idempotent
GET Yes Yes
POST No No
PUT No Yes
PATCH No No
DELETE No Yes
HEAD Yes Yes
18. 18
Safe HTTP methods do not modify
resources. e.g. GET, HEAD, OPTIONS
Idempotent HTTP methods can be called
multiple times with the same result.
e.g. GET, HEAD, PUT, DELETE
19. 19
Content Negotiation: Supporting Multiple Content Types
GET https://api.example.com/projects HTTP/1.0
Accept: application/json;q=0.5,application/xml;q=1.0
HTTP/1.0 200 OK
Date: Tue, 16 June 2015 06:57:43 GMT
Content-Type: application/xml
<project>…</project>
19
20. 20
Language Negotiation: Supporting Multiple Languages
GET https://api.example.com/projects HTTP/1.0
Accept-Language: en;q=0.5,de;q=1.0
HTTP/1.0 200 OK
Date: Tue, 16 June 2015 06:57:43 GMT
Content-Language: en
<project>
<status>active</status>
<status-display>active</status-display>
</project> 20
21. 21
Language Negotiation: Supporting Multiple Languages
GET https://api.example.com/projects HTTP/1.0
Accept-Language: en;q=0.5,de;q=1.0
HTTP/1.0 200 OK
Date: Tue, 16 June 2015 06:57:43 GMT
Content-Language: de
<project>
<status>active</status>
<status-display>angenommen</status-display>
</project> 21
26. 26
API Design is an architectural
concern that combines
business, product design, and
software engineering
27. 27
Roy Fielding on Architectural Styles
“An architectural style is a coordinated
set of architectural constraints
that restricts the roles/features of
architectural elements and the allowed
relationships among those elements
within any architecture that
conforms to that style.”
28. 28
Roy Fielding on Architectural Styles
“Some architectural styles are often
portrayed as ‘silver bullet’ solutions for all
forms of software. However, a good
designer should select a style that
matches the needs of the particular
problem being solved.”
29. 29
Roy Fielding on Architectural Styles (con’t)
“Choosing the right architectural style for a
network-based application requires an
understanding of the problem domain
and thereby the communication needs
of the application, an awareness of the
variety of architectural styles and the
particular concerns they address…”
- Roy Fielding
https://www.ics.uci.edu/~fielding/pubs/dissertation/software_arch.htm#sec_1_5
34. 34
Challenges for Some GraphQL Implementors
Limited Endpoint
Security Enforcement
Limited
Ops Tooling
Inconsistencies in
Recommendations
Lack of Flexibility
for Content Types
Lack of
Cacheability
36. 36
gRPC: Example Service Definition, Server, and Client
Source: https://grpc.io/docs/quickstart/node.html
37. 37
Advantages of gRPC
High Performance/
Low Latency
Protobuf
Message Format
Code Generation
(client and server)
Bi-Directional
Communication
Built On
HTTP/2
38. 38
Challenges for Some gRPC Implementors
Limited
Error Handling
Limited
Dev/Ops Tooling
Inconsistent Code Gen
Across Languages
Lack of Flexibility
for Content Types
Lack of
Cacheability
41. 41
Revisiting the REST Constraints
Client-Server Stateless Cache Layered System
Code on Demand
(optional)
Uniform Interface
(resources, representations,
hypermedia)
42. 42
Deep-Dive: REST’s Layered and Cache Constraints
Logging
OAuth
RateLimiting
Caching
Custom
APIImplementation
LoadBalancer
CDN/EdgeCache
Client
Network Infra API Management Layer Your Code
Client
Cache
HTTP HTTP HTTP HTTP
43. 43
HTTP HTTP HTTP
Operationalizing Your API: There is more to your API than code!
Logging
OAuth
RateLimiting
Caching
Custom
APIImplementation
LoadBalancer
CDN/EdgeCache
Client
Network Infra API Management Layer Your Code
Client
Cache
HTTP
54. 54
#2: We all must become better
educated with what HTTP has to
offer, rather than reinventing the
HTTP protocol over-and-over
(then tunneling them via HTTP)
55. 55
#3. Evolve our tools and
frameworks to better take
advantage of HTTP:
caching, concurrency control,
hypermedia
56. 56
#4. Our thinking must move
”beyond code on the laptop”
and into business use cases,
ops, compliance, and support
concerns
57. 57
#5. Stop using ‘vs.’ and start
using ‘and’ when it comes to
selecting API styles
58. 58
Roy Fielding on Uniform Interface Constraint
“The REST interface is designed to be
efficient for large grain hypermedia data
transfer, optimizing for the common
case of the Web, but resulting in an
interface that is not optimal for other
forms of architectural interaction.”