Talk from the Auckland API and microservices meetup 10/20/15
http://www.meetup.com/Auckland-API-and-Microservices-Meetup/events/225828804/
Beyond specific anti-patterns, we also covered API design-first development process, and how to utilize spec formats and feedback loops to produce higher quality APIs.
2. JASON
HARMON
• From Austin, TX
• Head of API Design at PayPal
• Moving into Braintree
• Blogger at apiux.com,
pragmaticapi.com
• Organizer austinapi.com
meetup
• Youtube: API Workshop
• https://www.youtube.com/ch
annel/UCKK2ir0jqCvfB-
kzBGka_Lg
8. JSON JUNK DRAWER
TL;DR
Useful for client-defined fields/values
Not a good way to extend your API
Just add fields to resposne
Don’t add new required fields to request
s
17. DESIGN THINKING:
RULESAPIs are for humans and machines
Innovate
The human rule
• All design activity is ultimately social in nature
The ambiguity rule
• Design thinkers must preserve ambiguity
The re-design rule
• All design is re-design
The tangibility rule
• Making ideas tangible always facilitates
communication
18. DESIGN THINKING:
TOOLS
• Understanding your audiences
thoughts, desires, beliefs and actions
• Co-creating outcomes with that
audience
• Creating early versions or prototypes
and testing for fit / relevance /
acceptability
• Root cause analysis, five whys,
mindmapping
23. STANDARDS
Some of the primary concerns
• Authentication/Authorizat
ion
• Versioning
• Naming conventions for
URLs, parameters,
headers
• Interaction patterns with
verbs
• Paging/sorting
• Hypermedia semantics
24. SHARE STANDARDS!
If we all share, broad consistency can exist
PayPal API Style Guide
https://devblog.paypal.com/paypals-api-style-guide/
26. VISUALIZE SPECS
Many open source options
• Swagger-UI
• RAML API Portal
• Apiary
• Numerous options on
Github
• Host it and make it known
Hosted services
• Example: http://gelato.io
27. MOCK
Use mock APIs from specs to get feedback
Samples are a great starting point
Image credit: https://www.flickr.com/photos/timthetrumpetguy/160813983
70
28. MOCK
Fake it ‘til you make it
Again, many open source
options
• Swagger, RAML, Blueprint
all have Github projects
Custom-build
• Define controllers
• Link responses to samples
Host
• Make URLs available to
clients for feedback
30. DEVELOP/VALIDATE
Validate request/response
against spec in acceptance
tests
• Emerging area in open
source
Validate request in API against
spec
• Also, emerging area in
some languages
• Potentially processable in
proxy/facade layer
32. ACCEPTANCE TESTING
API acceptance testing means HTTP
clients
• Not to say you shouldn’t do unit
testing
Define english-readable acceptance
criteria
• BDD approaches work remarkably
well
• Chakram JS is a great way to start
Ensure visibility
• Integrate into CI
• Test failures should indicate what’s
wrong to anyone
• Product should only accept stories
when tests are green
YAML & Markdown-based editing have moved this forward a lot from early JSON days
This is an emerging field. Side project coming together to look at this problem with Swagger
Swagger/RAML/Blueprint give you a free UI to view the spec
Tangible.
Curl it or it didn’t happen.
Swagger/RAML/Blueprint all have free projects to make this happen, some integrated into the UI
Validating request/response is not an easy drop-in for most languages. A bit of an emerging area.
Also not a well-developed area. However, as JSON Schema tends to underly the discussion it’s really not any more complicated than typical JSON Schema validation.
Make sure the design first pipeline is CI automated
This process ensures confident change, as well as quality design