APIs are at the heart of the modern software development world. Whether we author a distributed system, a microservices-based application, or a simple client-server n-tier application - our system will most probably expose an API at its core. APIs are a means to expose the functionality of a particular component to its users. Unsurprisingly, many formats for APIs have existed over the years, with the industry setting around RESTful APIs as the de-facto standard, with gRPC growing in popularity.
Join me in this session, as I review today's most popular API formats and their relative strengths and weaknesses. From REST, through OpenAPI, via gRPC and to the rising star of AsyncAPI - we'll explain how these API formats work and the tools they employ and offer some guidance as towards when we should use each. At the end of this session, you'll have a good familiarity with these formats, and you'll be in a much better position to choose between them.
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Eran Stiller: API design in the modern era - architecture next 2020
1. API Design in the Modern Era
Eran Stiller
Chief Technology Officer, CodeValue
erans@codevalue.net
@eranstiller
https://stiller.blog
https://codevalue.net
5. About Eran
Eran Stiller
▪ @eranstiller
▪ CTO & Founder at CodeValue
▪ Software architect, consultant and instructor
▪ Microsoft Regional Director & Azure MVP
▪ Founder of Azure Israel Meetup
5
8. REST
▪ Representational State Transfer (REST)
▪ Largely based on the HTTP protocol
▪ Web APIs that conform the REST are called RESTful APIs
▪ An architecture style, not standard
▪ Various interpretations and guidelines exist
▪ No absolute right and wrong
▪ Only good and not-so-good practices ☺
12
11. Hypermedia Control (HATEOAS)
▪ Implementing HATEOAS is hard
▪ Some implementations available
▪ JSON API
▪ ODATA
▪ HAL
▪ Siren
▪ JSON Hyper-Schema
15
17. 21
parameters:
- name: bookId
in: path
required: true
style: simple
explode: false
schema:
type: integer
format: int32
x-position: 1
responses:
"200":
description: The requested book
content:
application/json:
schema:
$ref: '#/components/schemas/Book'
"404":
description: The requested book was not found
x-swagger-router-controller: Books
18. Expected Client Usage
1. Decide which OpenAPI URL path template to use
2. Calculate the parameter values to use (if any)
3. Plug the parameter values into the URL path template
4. Send an HTTP request
22
25. gRPC – an Interface Definition Language
▪ Similar, but different, to OpenAPI
▪ A modern alternative to RPC frameworks of the past
▪ DCOM
▪ WCF
▪ XML-RPC
▪ JSON-RPC
▪ …
▪ Quickly becoming the de-facto standard in RPC
30
29. gRPC Considerations
▪ Contract-first
▪ Lots of code/test/document generation support
▪ API Gateway support
▪ Not at the level of OpenAPI (yet)
▪ Typically modeled with a procedural orientation
▪ Can be used in a constrained entity driven model
▪ Allow mapping to REST with “grpc-gateway”
36
30. Mapping to REST with Annotations
37
syntax = "proto3";
import "google/api/annotations.proto";
message StringMessage {
string value = 1;
}
service YourService {
rpc Echo(StringMessage) returns (StringMessage) {
option (google.api.http) = {
post: "/v1/example/echo"
body: "*"
};
}
}
33. Traditionally – Do It Yourself
▪ Model the messages (how?)
▪ Publish the model (how?)
▪ Convey protocol decisions (how?)
▪ Manage versions (how?)
40
34. AsyncAPI to the Rescue
▪ An attempt to standardize out-of-band conveying of data
▪ Like OpenAPI for asynchronous communication
▪ Does not assume any tech stack
▪ Bring your own protocol
▪ Bring your own schema
▪ Bring your own security mechanism
▪ The more standard it is, the more likely tools will support it
▪ Defines two operation types a service can support
▪ Publish
▪ Subscribe
▪ Code-First & Contract-First
41
37. Takeaways
▪ REST is more than HTTP APIs
▪ OpenAPI allows simplifying work with HTTP APIs
▪ OpenAPI assumes HTTP & JSON
▪ Does not coerce REST semantics
▪ GraphQL is an interesting alternative
▪ gRPC is a modern RPC-style framework
▪ AsyncAPI attempts to close the gap on asynchronous programming
▪ Still in pre-alpha state for most technologies/platforms
45