Enlighten your software
REST API design & dev
Domingo Suárez Torres
Una propuesta de: “Como construir APIs REST
para sistemas distribuidos con alta
escalabilidad y resilencia"
• Programming model
• This talk and its contents are based in my own
• I’m not trying to say all the following IS the way to
do the right thing. Just my opinion. :)
• All I want is to share my experience with the
• This talk is huge. Hope I can ﬁnish on time.
• I’m not covering Hypermedia REST APIs
• I’m a JVM guy, so you will see lots of JVM
• Functional requirements is THE challenge.
• API Documentation is always a PITA, keep sync
with the maintenance, new features, ﬁxes, etc.
• Build any API (REST, SOAP, RPC) is hard.
• Development tools choice (programming
language, libraries, frameworks, runtime, etc).
• Non functional requirements, quality attributes.
• Always is over there. Implicit/Explicit
• You should have one.
• You should know it.
• No matter if you build it or you consume the API.
• You should give it so much love.
• Learn to love it.
API contract approaches
• Contract last
• Code driven contract
• Contract ﬁrst
• Upfront design
• Sadly is the commonest.
• Server-side developers dictate the contract.
• Most of the time with only one perspective.
• Implementator perspective VS consumer perpective
• Flaky. If missing test cases. Fragile.
• The documentation is done at the end.
raml + raml-mockup
We can deliver an API in days or hours
RAML & code generation
• Server side
• Square Retroﬁt
• OpenSource project from Grupo Expansión
• Generates Plain Old Java/Groovy Objects
• Generates JAX-RS interfases
• Generates an API client with Retroﬁt
• Can run in Android also in any JVM application.
Nice, now I know how to
create a contract. What’s next?
• Build, deploy, and monitor any kind of services in
agile, efﬁcient way with open standards.
• Deployment on-premise, in the cloud, mix of both.
• Deploy services independently from each other.
• Decoupled & scale linearly across commodity
–Spring Boot reference documentation
“Spring Boot makes it easy to create stand-
alone, production-grade Spring based
Applications that you can “just run”. We take an
opinionated view of the Spring platform and
third-party libraries so you can get started with
minimum fuss. Most Spring Boot applications
need very little Spring conﬁguration.”
• Embedded Servlet container
• Executable jar ﬁle. Key feature for microservices!
• Monitoring capabilities thanks to actuator
• Metrics (Dropwizard aka Coda Hale Metrics)
Spring Boot & JAX-RS
• Jersey 2.x support out of the box
• Just use the Jersey Starter
• raml2code generates JAX-RS artifacts, remember?
• Distributed/versioned conﬁguration
• Service registration and discovery
• Service-to-service calls
• Load balancing
• Circuit Breakers
• Global locks
• Leadership election and cluster state
• Distributed messaging
• Netﬂix is released tons of good stuff.
• Reactive Extensions for Java
• Hystrix (Circuit breaker)
• Eureka (Service registry)
• Archaius (Conﬁguration management)
• Zuul (Dynamic routing, monitoring, resilience, security)
• And many more…