SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
REST API DESIGN
END TO END
ANDREW JORDAN
PRODUCT MANAGER
@andrewkirk
andrew@akjordan.com
BIT.LY/2TSLMHD
DOWNLOAD PDF OF SLIDES HERE
ON TODAY’S AGENDA
END TO END REST API DESIGN
▸ API as a Business Model
▸ API Flavors
▸ Resource Design
▸ Testing and Feedback
▸ Resources for Further Reading
▸ Questions
API FIRST AS A BUSINESS MODEL
CLEAN AND SIMPLE
MESSY AND HARD
YOUR CLIENTS
YOUR API
YOUR SERVICES
API FIRST AS A BUSINESS MODEL
API FIRST AS A BUSINESS MODEL
▸ “Solve hard problems for which customers will pay”
▸ Founded in 2007, IPO in 2016 for 2.8 Billion
▸ Twilio Voice API
▸ 100+ million API requests a day
▸ $100+ million ARR business
▸ 99.999% Uptime
▸ 99.999% Request Success Rate
FLAVOR
DEFINE YOUR API
API FLAVOR
DEFINE YOUR API FLAVOR
▸ Choose HTTP methods that will be supported
▸ Choose the data interchange formats that will be accepted and returned
▸ Choose the format for dates, times that will be used
▸ Define what fields must always be returned for every response
API FLAVOR
DEFINE YOUR API FLAVOR
▸ The sum of these decisions dictate the flavor of your API, having a flavor makes
your API predictable to use across endpoints.
▸ At minimum these decisions need to be codified in a style guide and enforced
by people, at scale these need to be enforced with tests.
▸ In the absence of the time to do the above, copy the design decisions of a
good API.
ACCEPTS URLENCODED PARAMS RETURNS JSON FLAVORED API - “TWILIO FLAVOR”
REQUEST
curl -X POST https://api.thefamily.co/v1/talks 

-d ‘speaker_name=Andrew%20Jordan

-d ‘topic=End%20to%20End%20REST%20API%20Design’

-u ‘[Username]:[Password]’ 

-H 'content-type: application/x-www-form-urlencoded'
ACCEPTS URLENCODED PARAMS RETURNS JSON FLAVORED API - “TWILIO FLAVOR”
RESPONSE
201 Created

{

"guid": "7abb4f67-84dc-4ddb-9f33-8d0410e8bacd",

"date_created": "2017-06-17T11:17:32Z",

"date_updated": “2017-06-17T11:17:32Z",

“speaker_name": “Andrew Jordan”,

"topic": "End to End REST API Design",

"uri": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json",

"subresource_uris": {

“slides": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides.json",

“videos": “api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/
videos.json”

}
PREDICTABILITY
APIS ARE CONTRACTS, CONTRACTS PROVIDE
Written Spec Tech Spec Internal Testing External Testing GA
Written Spec Tech Spec Internal Testing External Testing GA
COSTS OF CHANGES INCREASE EXPONENTIALLY
RATE OF CHANGE SHOULD DROP OVER TIME
Written Spec Tech Spec Internal Testing External Testing GA
DESIGNING FOR PREDICTABILITY
UNDERSTAND YOUR CUSTOMER AND THEIRS
▸ API Design is “Meta” Product Management
▸ Your customer is the developer, but they have a customer too.
▸ What is the developer trying to build?
▸ What do the developer’s customers care about?
DESIGNING FOR PREDICTABILITY
WRITE A NARRATIVE FOR YOUR API
▸ Generate a document that details the problem, your customer interviews and
preliminary API design.
▸ This doc is for you as a PM and your engineering team to work out the rough details
of the API.
▸ This doc is the seed of your documentation
▸ Engineering should sign off this doc to flag any security or scaleability issues early
▸ A cleaned up version of this doc should be shared with customer as early as
possible for feedback
DESIGNING FOR PREDICTABILITY
DEFINE YOUR RESOURCES
▸ Every resource should be a noun, not a verb
▸ Choosing the correct level of abstraction is the art of API design
▸ Expose a minimal number of resource properties to start
▸ 80% or more of the time spent designing an API is spent taking the underlying
system and translating it into an object model that makes sense
▸ This underlying structure is most disruptive to change so spend the most time
getting it right
Written Spec Tech Spec Internal Testing External Testing GA
DESIGNING FOR PREDICTABILITY
TECHNICAL SPECIFICATION
▸ Document laying out object model, request flow, sequence diagrams
▸ If you are using Swagger or similar, this is where you start generating those
specifications
▸ Once technical specification is finalized feed any changes back into your
written narrative and validate changes with your customers.
Written Spec Tech Spec Internal Testing External Testing GA
DESIGNING FOR PREDICTABILITY
INTERNAL TESTING
▸ As a Product Manager building an API, you are your first customer, code
against your API early and often.
▸ Evaluate the usability of your API
▸ Generate code samples to use in your documentation
DESIGNING FOR PREDICTABILITY
INTERNAL TESTING
▸ Plan an internal hackathon to build against your API, treat your team like your
customers.
▸ Detail out several use cases that they should be able to build.
▸ Customer facing docs should be completed by this point, do not allow use of
internal docs.
▸ Improve customer facing docs as hackathon progresses.
▸ Keep shared google sheet for team to compile issues
Written Spec Tech Spec Internal Testing External Testing GA
DESIGNING FOR PREDICTABILITY
EXTERNAL TESTING
▸ Define release stages for your API and clearly communicate them, for instance
Preview, Beta, GA
▸ Preview APIs could have significant breaking changes, and may not be
totally operationalized
▸ Beta APIs may have small breaking changes should be production ready
▸ GA APIs had no breaking changes allowed without a version change, fully
operationalized with SLAs
DESIGNING FOR PREDICTABILITY
EXTERNAL TESTING
▸ Getting good customer feedback for an API is incredibly difficult
▸ Customers don't want to do throw away development work integrating an API
that will significantly change. Customers want to engage once API is nearly
final, without customer feedback API will never be final, goto 1.
▸ Hackathons + Amazon cards work pretty well, paid user testing, cultivate a few
customers that you take very good care of in exchange for their API feedback.
▸ The Beta stage is where you need to start selling your API, lag time to integrate
can be months, need to get your API on dev schedules in advance.
Written Spec Tech Spec Internal Testing External Testing GA
DESIGNING FOR PREDICTABILITY
GENERAL AVAILABILITY
▸ In the best case, having an API in GA should be very low overhead, predicable
▸ Documentation is a never-ending maintenance task, it can always be better
▸ Fix bugs (some of them), improve API performance
▸ Gather feedback for future enhancements
DESIGNING FOR PREDICTABILITY
IF YOU HAVE TO CHANGE, DO SO CAREFULLY
▸ Plan for and document your change policy, clearly communicate it to your
customers.
▸ Additive changes are usually safe
▸ Add new resources or new parameters to resources
▸ Add new subdomains for new products
DESIGNING FOR PREDICTABILITY
IF YOU HAVE TO CHANGE, DO SO CAREFULLY
▸ Versioning is a massive undertaking and has very large indirect costs.
▸ Will need to maintain parallel, docs, support FAQ everything, may double
your overhead to maintain API.
▸ Version with a non date identifier, https://api.thefamily.co/v1/talks to https://
api.thefamily.co/v2/talks
▸ “We’ll just migrate the last few customers off the old endpoint and shut it
down”
DESIGNING FOR PREDICTABILITY
▸ Predictability, consistency, and stability above all else.
▸ APIs are a contract, define a clear contact and honor it.
▸ Use GUIDs or UUIDs as resource identifiers
▸ All time in ISO 8601, in UTC, always
▸ Version APIs using version numbers, not dates
▸ Separate APIs should live on Subdomains
▸ Implement HATEOS
▸ Start small and make additive non-breaking changes
▸ Basic auth is probably fine, a scoped token scheme is better, think about how auth impacts developer experience.
▸ HTTPS only and always
▸ Customer feedback on APIs is hard to come by, plan on doing most of the lifting internally.
TAKEAWAYS
WRITING AND TALKS
▸ Amanda Folson, Your API is Bad and
you should Feel Bad
▸ Vinay Sahni: API Best Practices
▸ Gordon Wintrob's GET PUT POST
newsletter
▸ Kevin Burke on API Docs
▸ Kevin Burke on Client Libs
▸ And the other talks from API Mixtape
conference
API EXAMPLES
▸ Classic Flavor Twilio API
▸ Modern Flavor Twilio API
▸ Shippo API
▸ Stripe API
▸ 18F API Standards
▸ Microsoft API Guidelines
FURTHER CONTENT
TOOLING
▸ Swagger
▸ POSTman
QUESTIONS?
CUT SLIDES
REST
Request:
curl -G http://api.thefamily.co/v1/talks 

-u ‘23679019-81dd-4c24-83c5-2b625c71186c:e592b87e-3c5f-4fed-8d8f-a1edbc88c880' 
Response:
200 OK
{
   "uri": "api.thefamily.co/v1/talks.json",
   "first_page_uri": "api.thefamily.co/v1/talks?Page=0",
   "previous_page_uri": null,
   "next_page_uri": "api.thefamily.co/v1/talks?Page=1",
   "talks": [{
       "guid": "7abb4f67-84dc-4ddb-9f33-8d0410e8bacd",
       "date_created": "Friday, 30-Jun-17 11:17:32 UTC",
       "date_updated": "Friday, 30-Jun-17 11:17:32 UTC",
       "speaker_name": “Andrew Jordan”,
       "topic": "End to End REST API Design",
       "uri": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json",
       "subresource_uris": {
           "slides": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides.json",
           "recordings": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides/recordings.json"}},
{
       "guid": "a680011a-5286-4d10-96b8-a9cbcfbd1d08",
REST
Request:
curl -G http://api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json

-u ‘23679019-81dd-4c24-83c5-2b625c71186c:e592b87e-3c5f-4fed-8d8f-a1edbc88c880' 
Response:
200 OK
{
“guid": "7abb4f67-84dc-4ddb-9f33-8d0410e8bacd",

"date_created": "Friday, 30-Jun-17 11:17:32 UTC",

"date_updated": "Friday, 30-Jun-17 11:17:32 UTC",

“speaker_name": “Andrew Jordan”,

"topic": "End to End REST API Design",

"uri": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json",

"subresource_uris": {

"slides": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides.json",

“recordings": “api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides/recordings.json”
}
REST
Request:
curl -X POST http://api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json 

-d ‘topic=Front%20to%20Back%20REST%20API%20Design’

-u ‘23679019-81dd-4c24-83c5-2b625c71186c:e592b87e-3c5f-4fed-8d8f-a1edbc88c880' 

-H 'content-type: application/x-www-form-urlencoded'
Response:
201 Created
{
"guid": "7abb4f67-84dc-4ddb-9f33-8d0410e8bacd",

"date_created": "Friday, 30-Jun-17 11:17:32 UTC",

"date_updated": "Friday, 30-Jun-17 13:42:32 UTC",

“speaker_name": “Andrew Jordan”,

"topic": "Front to Back REST API Design",

"uri": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json",

"subresource_uris": {

"slides": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides.json",

“recordings": “api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides/recordings.json”
}
REST
Request:
curl -X DELETE http://api.thefamily.co/v1/talks/
7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json 

-u ‘23679019-81dd-4c24-83c5-2b625c71186c:e592b87e-3c5f-4fed-8d8f-
a1edbc88c880' 
Response:
204 No Content
API FLAVOR
WHAT IS REST
▸ REST (Representational State Transfer) is an architectural style which advocates
that web applications should use HTTP as it was originally envisioned. Lookups
should use GET requests. PUT, POST, and DELETE requests should be used for
creation, mutation, and deletion.
▸ Create, Read, Update, Delete (CRUD) maps to POST, GET, PUT/PATCH, DELETE

Contenu connexe

Tendances

DBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and FlinkDBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
Timothy Spann
 
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A GrzesikApache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
mfrancis
 

Tendances (20)

Microservices & API Gateways
Microservices & API Gateways Microservices & API Gateways
Microservices & API Gateways
 
Api-First service design
Api-First service designApi-First service design
Api-First service design
 
Effective API Design
Effective API DesignEffective API Design
Effective API Design
 
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
LF_APIStrat17_Creating Communication Applications using the Asterisk RESTFul ...
 
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and FlinkDBA Fundamentals Group: Continuous SQL with Kafka and Flink
DBA Fundamentals Group: Continuous SQL with Kafka and Flink
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
The Architecture of an API Platform
The Architecture of an API PlatformThe Architecture of an API Platform
The Architecture of an API Platform
 
Apigee Demo: API Platform Overview
Apigee Demo: API Platform OverviewApigee Demo: API Platform Overview
Apigee Demo: API Platform Overview
 
REST vs GraphQL
REST vs GraphQLREST vs GraphQL
REST vs GraphQL
 
Architecting an Enterprise API Management Strategy
Architecting an Enterprise API Management StrategyArchitecting an Enterprise API Management Strategy
Architecting an Enterprise API Management Strategy
 
Kafka Streams: What it is, and how to use it?
Kafka Streams: What it is, and how to use it?Kafka Streams: What it is, and how to use it?
Kafka Streams: What it is, and how to use it?
 
Oracle api gateway overview
Oracle api gateway overviewOracle api gateway overview
Oracle api gateway overview
 
REST API Best (Recommended) Practices
REST API Best (Recommended) PracticesREST API Best (Recommended) Practices
REST API Best (Recommended) Practices
 
Enterprise Integration Patterns Revisited (again) for the Era of Big Data, In...
Enterprise Integration Patterns Revisited (again) for the Era of Big Data, In...Enterprise Integration Patterns Revisited (again) for the Era of Big Data, In...
Enterprise Integration Patterns Revisited (again) for the Era of Big Data, In...
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Introduction to GraphQL: Mobile Week SF
Introduction to GraphQL: Mobile Week SFIntroduction to GraphQL: Mobile Week SF
Introduction to GraphQL: Mobile Week SF
 
Rest API
Rest APIRest API
Rest API
 
API Strategy Introduction
API Strategy IntroductionAPI Strategy Introduction
API Strategy Introduction
 
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A GrzesikApache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
Apache Karaf - Building OSGi applications on Apache Karaf - T Frank & A Grzesik
 
Quarkus Denmark 2019
Quarkus Denmark 2019Quarkus Denmark 2019
Quarkus Denmark 2019
 

En vedette

En vedette (7)

Programmable Video Fundamentals
Programmable Video FundamentalsProgrammable Video Fundamentals
Programmable Video Fundamentals
 
What Can You Do With Twilio
What Can You Do With TwilioWhat Can You Do With Twilio
What Can You Do With Twilio
 
【最新版誘導用】クラウドコミュニケーションAPI Twilio&sakura.io体験ハンズオン
【最新版誘導用】クラウドコミュニケーションAPI Twilio&sakura.io体験ハンズオン【最新版誘導用】クラウドコミュニケーションAPI Twilio&sakura.io体験ハンズオン
【最新版誘導用】クラウドコミュニケーションAPI Twilio&sakura.io体験ハンズオン
 
Watson DevCon 2016 - Do More with Less Code: Enriched Communications with Twi...
Watson DevCon 2016 - Do More with Less Code: Enriched Communications with Twi...Watson DevCon 2016 - Do More with Less Code: Enriched Communications with Twi...
Watson DevCon 2016 - Do More with Less Code: Enriched Communications with Twi...
 
Data Analytics in Digital Transformation
Data Analytics in Digital TransformationData Analytics in Digital Transformation
Data Analytics in Digital Transformation
 
Twilio+Node-REDで作る自動モーニングコール
Twilio+Node-REDで作る自動モーニングコールTwilio+Node-REDで作る自動モーニングコール
Twilio+Node-REDで作る自動モーニングコール
 
Building Blocks for Next Generation Contact Centers
Building Blocks for Next Generation Contact CentersBuilding Blocks for Next Generation Contact Centers
Building Blocks for Next Generation Contact Centers
 

Similaire à "API Design: From User Need to Finished Spec" by Andrew Jordan, ex-Product @Twilio

Similaire à "API Design: From User Need to Finished Spec" by Andrew Jordan, ex-Product @Twilio (20)

API Best Practices
API Best PracticesAPI Best Practices
API Best Practices
 
apidays LIVE New York 2021 - Docs Driven API Development by Rahul Dighe, Paypal
apidays LIVE New York 2021 - Docs Driven API Development by Rahul Dighe, Paypalapidays LIVE New York 2021 - Docs Driven API Development by Rahul Dighe, Paypal
apidays LIVE New York 2021 - Docs Driven API Development by Rahul Dighe, Paypal
 
Flipping the script: How to take the first step towards internal developer pl...
Flipping the script: How to take the first step towards internal developer pl...Flipping the script: How to take the first step towards internal developer pl...
Flipping the script: How to take the first step towards internal developer pl...
 
Continuous API Strategies for Integrated Platforms
 Continuous API Strategies for Integrated Platforms Continuous API Strategies for Integrated Platforms
Continuous API Strategies for Integrated Platforms
 
Continuous Delivery Pipeline in the Cloud – How to Achieve Continous Everything
Continuous Delivery Pipeline in the Cloud – How to Achieve Continous Everything Continuous Delivery Pipeline in the Cloud – How to Achieve Continous Everything
Continuous Delivery Pipeline in the Cloud – How to Achieve Continous Everything
 
DataHero / Eventbrite - API Best Practices
DataHero / Eventbrite - API Best PracticesDataHero / Eventbrite - API Best Practices
DataHero / Eventbrite - API Best Practices
 
apidays New York 2023 - Hypermedia as the engine for Customer Success, Michae...
apidays New York 2023 - Hypermedia as the engine for Customer Success, Michae...apidays New York 2023 - Hypermedia as the engine for Customer Success, Michae...
apidays New York 2023 - Hypermedia as the engine for Customer Success, Michae...
 
Building a great internal platform starts with the API
Building a great internal platform starts with the API Building a great internal platform starts with the API
Building a great internal platform starts with the API
 
Practical guide to building public APIs
Practical guide to building public APIsPractical guide to building public APIs
Practical guide to building public APIs
 
Making Your Customer Experience Great Before You Hit Production - AppSphere16
Making Your Customer Experience Great Before You Hit Production - AppSphere16Making Your Customer Experience Great Before You Hit Production - AppSphere16
Making Your Customer Experience Great Before You Hit Production - AppSphere16
 
API product strategy - Intro to Internal, External APIs and Developer Platforms
API product strategy - Intro to Internal, External APIs and Developer PlatformsAPI product strategy - Intro to Internal, External APIs and Developer Platforms
API product strategy - Intro to Internal, External APIs and Developer Platforms
 
ENT206 Product Development in the Cloud
ENT206 Product Development in the CloudENT206 Product Development in the Cloud
ENT206 Product Development in the Cloud
 
Spec-first API Design for Speed and Safety
Spec-first API Design for Speed and SafetySpec-first API Design for Speed and Safety
Spec-first API Design for Speed and Safety
 
Everybody loves Swagger (Massimo Crippa @ Integration Monday)
Everybody loves Swagger (Massimo Crippa @ Integration Monday)Everybody loves Swagger (Massimo Crippa @ Integration Monday)
Everybody loves Swagger (Massimo Crippa @ Integration Monday)
 
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
 
API Management For Building Software Applications Powerpoint Presentation Slides
API Management For Building Software Applications Powerpoint Presentation SlidesAPI Management For Building Software Applications Powerpoint Presentation Slides
API Management For Building Software Applications Powerpoint Presentation Slides
 
Streamlining API with Swagger.io
Streamlining API with Swagger.ioStreamlining API with Swagger.io
Streamlining API with Swagger.io
 
Everybody loves Swagger
Everybody loves SwaggerEverybody loves Swagger
Everybody loves Swagger
 
Building the Eventbrite API Ecosystem
Building the Eventbrite API EcosystemBuilding the Eventbrite API Ecosystem
Building the Eventbrite API Ecosystem
 
Collaborative Contract Driven Development
Collaborative Contract Driven DevelopmentCollaborative Contract Driven Development
Collaborative Contract Driven Development
 

Plus de TheFamily

Plus de TheFamily (20)

Building a design culture from day one
Building a design culture from day oneBuilding a design culture from day one
Building a design culture from day one
 
Individual Contributors vs Managers
Individual Contributors vs ManagersIndividual Contributors vs Managers
Individual Contributors vs Managers
 
Build the decentralized team you ever dreamed of
Build the decentralized team you ever dreamed ofBuild the decentralized team you ever dreamed of
Build the decentralized team you ever dreamed of
 
CEOs best practices to win time back & focus on what matters
CEOs best practices to win time back & focus on what mattersCEOs best practices to win time back & focus on what matters
CEOs best practices to win time back & focus on what matters
 
Managing fully remote teams
Managing fully remote teamsManaging fully remote teams
Managing fully remote teams
 
State of European Tech by Atomico
State of European Tech by AtomicoState of European Tech by Atomico
State of European Tech by Atomico
 
Building a real estate startup
Building a real estate startupBuilding a real estate startup
Building a real estate startup
 
A VC view on Enterprise Sales
A VC view on Enterprise SalesA VC view on Enterprise Sales
A VC view on Enterprise Sales
 
Find your style and create emotions
Find your style and create emotionsFind your style and create emotions
Find your style and create emotions
 
From product to ecosystem
From product to ecosystemFrom product to ecosystem
From product to ecosystem
 
Demystifying the product black box
Demystifying the product black boxDemystifying the product black box
Demystifying the product black box
 
The secrets to create bank brand love
The secrets to create bank brand loveThe secrets to create bank brand love
The secrets to create bank brand love
 
Building an insurance startup with Alan, Luko, Coverd & Balderton
Building an insurance startup with Alan, Luko, Coverd & BaldertonBuilding an insurance startup with Alan, Luko, Coverd & Balderton
Building an insurance startup with Alan, Luko, Coverd & Balderton
 
Mixing Product & Tech by Jean Lebrument, CTO & CPO at Brigad
Mixing Product & Tech by Jean Lebrument, CTO & CPO at BrigadMixing Product & Tech by Jean Lebrument, CTO & CPO at Brigad
Mixing Product & Tech by Jean Lebrument, CTO & CPO at Brigad
 
A new breed of CTO - Philippe Vimard, CTO & COO at Doctolib
A new breed of CTO - Philippe Vimard, CTO & COO at DoctolibA new breed of CTO - Philippe Vimard, CTO & COO at Doctolib
A new breed of CTO - Philippe Vimard, CTO & COO at Doctolib
 
Building a logistics startup  with Trusk, Totem & SpaceFill
Building a logistics startup  with Trusk, Totem & SpaceFillBuilding a logistics startup  with Trusk, Totem & SpaceFill
Building a logistics startup  with Trusk, Totem & SpaceFill
 
Building an accounting startup with Fred de la compta, Acasi & Chaintrust
Building an accounting startup with Fred de la compta, Acasi & ChaintrustBuilding an accounting startup with Fred de la compta, Acasi & Chaintrust
Building an accounting startup with Fred de la compta, Acasi & Chaintrust
 
Scale your tech team from 0 to Series A
Scale your tech team from 0 to Series A Scale your tech team from 0 to Series A
Scale your tech team from 0 to Series A
 
Onboarding developers and setting them up for success
Onboarding developers and setting them up for successOnboarding developers and setting them up for success
Onboarding developers and setting them up for success
 
Apprendre à penser comme un journaliste
Apprendre à penser comme un journalisteApprendre à penser comme un journaliste
Apprendre à penser comme un journaliste
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

"API Design: From User Need to Finished Spec" by Andrew Jordan, ex-Product @Twilio

  • 4. ON TODAY’S AGENDA END TO END REST API DESIGN ▸ API as a Business Model ▸ API Flavors ▸ Resource Design ▸ Testing and Feedback ▸ Resources for Further Reading ▸ Questions
  • 5. API FIRST AS A BUSINESS MODEL CLEAN AND SIMPLE MESSY AND HARD YOUR CLIENTS YOUR API YOUR SERVICES
  • 6. API FIRST AS A BUSINESS MODEL
  • 7. API FIRST AS A BUSINESS MODEL ▸ “Solve hard problems for which customers will pay” ▸ Founded in 2007, IPO in 2016 for 2.8 Billion ▸ Twilio Voice API ▸ 100+ million API requests a day ▸ $100+ million ARR business ▸ 99.999% Uptime ▸ 99.999% Request Success Rate
  • 9. API FLAVOR DEFINE YOUR API FLAVOR ▸ Choose HTTP methods that will be supported ▸ Choose the data interchange formats that will be accepted and returned ▸ Choose the format for dates, times that will be used ▸ Define what fields must always be returned for every response
  • 10. API FLAVOR DEFINE YOUR API FLAVOR ▸ The sum of these decisions dictate the flavor of your API, having a flavor makes your API predictable to use across endpoints. ▸ At minimum these decisions need to be codified in a style guide and enforced by people, at scale these need to be enforced with tests. ▸ In the absence of the time to do the above, copy the design decisions of a good API.
  • 11. ACCEPTS URLENCODED PARAMS RETURNS JSON FLAVORED API - “TWILIO FLAVOR” REQUEST curl -X POST https://api.thefamily.co/v1/talks 
 -d ‘speaker_name=Andrew%20Jordan
 -d ‘topic=End%20to%20End%20REST%20API%20Design’
 -u ‘[Username]:[Password]’ 
 -H 'content-type: application/x-www-form-urlencoded'
  • 12. ACCEPTS URLENCODED PARAMS RETURNS JSON FLAVORED API - “TWILIO FLAVOR” RESPONSE 201 Created
 {
 "guid": "7abb4f67-84dc-4ddb-9f33-8d0410e8bacd",
 "date_created": "2017-06-17T11:17:32Z",
 "date_updated": “2017-06-17T11:17:32Z",
 “speaker_name": “Andrew Jordan”,
 "topic": "End to End REST API Design",
 "uri": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json",
 "subresource_uris": {
 “slides": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides.json",
 “videos": “api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/ videos.json”
 }
  • 14. Written Spec Tech Spec Internal Testing External Testing GA
  • 15. Written Spec Tech Spec Internal Testing External Testing GA COSTS OF CHANGES INCREASE EXPONENTIALLY RATE OF CHANGE SHOULD DROP OVER TIME
  • 16. Written Spec Tech Spec Internal Testing External Testing GA
  • 17. DESIGNING FOR PREDICTABILITY UNDERSTAND YOUR CUSTOMER AND THEIRS ▸ API Design is “Meta” Product Management ▸ Your customer is the developer, but they have a customer too. ▸ What is the developer trying to build? ▸ What do the developer’s customers care about?
  • 18. DESIGNING FOR PREDICTABILITY WRITE A NARRATIVE FOR YOUR API ▸ Generate a document that details the problem, your customer interviews and preliminary API design. ▸ This doc is for you as a PM and your engineering team to work out the rough details of the API. ▸ This doc is the seed of your documentation ▸ Engineering should sign off this doc to flag any security or scaleability issues early ▸ A cleaned up version of this doc should be shared with customer as early as possible for feedback
  • 19. DESIGNING FOR PREDICTABILITY DEFINE YOUR RESOURCES ▸ Every resource should be a noun, not a verb ▸ Choosing the correct level of abstraction is the art of API design ▸ Expose a minimal number of resource properties to start ▸ 80% or more of the time spent designing an API is spent taking the underlying system and translating it into an object model that makes sense ▸ This underlying structure is most disruptive to change so spend the most time getting it right
  • 20. Written Spec Tech Spec Internal Testing External Testing GA
  • 21. DESIGNING FOR PREDICTABILITY TECHNICAL SPECIFICATION ▸ Document laying out object model, request flow, sequence diagrams ▸ If you are using Swagger or similar, this is where you start generating those specifications ▸ Once technical specification is finalized feed any changes back into your written narrative and validate changes with your customers.
  • 22. Written Spec Tech Spec Internal Testing External Testing GA
  • 23. DESIGNING FOR PREDICTABILITY INTERNAL TESTING ▸ As a Product Manager building an API, you are your first customer, code against your API early and often. ▸ Evaluate the usability of your API ▸ Generate code samples to use in your documentation
  • 24. DESIGNING FOR PREDICTABILITY INTERNAL TESTING ▸ Plan an internal hackathon to build against your API, treat your team like your customers. ▸ Detail out several use cases that they should be able to build. ▸ Customer facing docs should be completed by this point, do not allow use of internal docs. ▸ Improve customer facing docs as hackathon progresses. ▸ Keep shared google sheet for team to compile issues
  • 25. Written Spec Tech Spec Internal Testing External Testing GA
  • 26. DESIGNING FOR PREDICTABILITY EXTERNAL TESTING ▸ Define release stages for your API and clearly communicate them, for instance Preview, Beta, GA ▸ Preview APIs could have significant breaking changes, and may not be totally operationalized ▸ Beta APIs may have small breaking changes should be production ready ▸ GA APIs had no breaking changes allowed without a version change, fully operationalized with SLAs
  • 27. DESIGNING FOR PREDICTABILITY EXTERNAL TESTING ▸ Getting good customer feedback for an API is incredibly difficult ▸ Customers don't want to do throw away development work integrating an API that will significantly change. Customers want to engage once API is nearly final, without customer feedback API will never be final, goto 1. ▸ Hackathons + Amazon cards work pretty well, paid user testing, cultivate a few customers that you take very good care of in exchange for their API feedback. ▸ The Beta stage is where you need to start selling your API, lag time to integrate can be months, need to get your API on dev schedules in advance.
  • 28. Written Spec Tech Spec Internal Testing External Testing GA
  • 29. DESIGNING FOR PREDICTABILITY GENERAL AVAILABILITY ▸ In the best case, having an API in GA should be very low overhead, predicable ▸ Documentation is a never-ending maintenance task, it can always be better ▸ Fix bugs (some of them), improve API performance ▸ Gather feedback for future enhancements
  • 30. DESIGNING FOR PREDICTABILITY IF YOU HAVE TO CHANGE, DO SO CAREFULLY ▸ Plan for and document your change policy, clearly communicate it to your customers. ▸ Additive changes are usually safe ▸ Add new resources or new parameters to resources ▸ Add new subdomains for new products
  • 31. DESIGNING FOR PREDICTABILITY IF YOU HAVE TO CHANGE, DO SO CAREFULLY ▸ Versioning is a massive undertaking and has very large indirect costs. ▸ Will need to maintain parallel, docs, support FAQ everything, may double your overhead to maintain API. ▸ Version with a non date identifier, https://api.thefamily.co/v1/talks to https:// api.thefamily.co/v2/talks ▸ “We’ll just migrate the last few customers off the old endpoint and shut it down”
  • 32. DESIGNING FOR PREDICTABILITY ▸ Predictability, consistency, and stability above all else. ▸ APIs are a contract, define a clear contact and honor it. ▸ Use GUIDs or UUIDs as resource identifiers ▸ All time in ISO 8601, in UTC, always ▸ Version APIs using version numbers, not dates ▸ Separate APIs should live on Subdomains ▸ Implement HATEOS ▸ Start small and make additive non-breaking changes ▸ Basic auth is probably fine, a scoped token scheme is better, think about how auth impacts developer experience. ▸ HTTPS only and always ▸ Customer feedback on APIs is hard to come by, plan on doing most of the lifting internally. TAKEAWAYS
  • 33. WRITING AND TALKS ▸ Amanda Folson, Your API is Bad and you should Feel Bad ▸ Vinay Sahni: API Best Practices ▸ Gordon Wintrob's GET PUT POST newsletter ▸ Kevin Burke on API Docs ▸ Kevin Burke on Client Libs ▸ And the other talks from API Mixtape conference API EXAMPLES ▸ Classic Flavor Twilio API ▸ Modern Flavor Twilio API ▸ Shippo API ▸ Stripe API ▸ 18F API Standards ▸ Microsoft API Guidelines FURTHER CONTENT TOOLING ▸ Swagger ▸ POSTman
  • 36. REST Request: curl -G http://api.thefamily.co/v1/talks 
 -u ‘23679019-81dd-4c24-83c5-2b625c71186c:e592b87e-3c5f-4fed-8d8f-a1edbc88c880' Response: 200 OK {    "uri": "api.thefamily.co/v1/talks.json",    "first_page_uri": "api.thefamily.co/v1/talks?Page=0",    "previous_page_uri": null,    "next_page_uri": "api.thefamily.co/v1/talks?Page=1",    "talks": [{        "guid": "7abb4f67-84dc-4ddb-9f33-8d0410e8bacd",        "date_created": "Friday, 30-Jun-17 11:17:32 UTC",        "date_updated": "Friday, 30-Jun-17 11:17:32 UTC",        "speaker_name": “Andrew Jordan”,        "topic": "End to End REST API Design",        "uri": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json",        "subresource_uris": {            "slides": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides.json",            "recordings": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides/recordings.json"}}, {        "guid": "a680011a-5286-4d10-96b8-a9cbcfbd1d08",
  • 37. REST Request: curl -G http://api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json
 -u ‘23679019-81dd-4c24-83c5-2b625c71186c:e592b87e-3c5f-4fed-8d8f-a1edbc88c880' Response: 200 OK { “guid": "7abb4f67-84dc-4ddb-9f33-8d0410e8bacd",
 "date_created": "Friday, 30-Jun-17 11:17:32 UTC",
 "date_updated": "Friday, 30-Jun-17 11:17:32 UTC",
 “speaker_name": “Andrew Jordan”,
 "topic": "End to End REST API Design",
 "uri": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json",
 "subresource_uris": {
 "slides": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides.json",
 “recordings": “api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides/recordings.json” }
  • 38. REST Request: curl -X POST http://api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json 
 -d ‘topic=Front%20to%20Back%20REST%20API%20Design’
 -u ‘23679019-81dd-4c24-83c5-2b625c71186c:e592b87e-3c5f-4fed-8d8f-a1edbc88c880' 
 -H 'content-type: application/x-www-form-urlencoded' Response: 201 Created { "guid": "7abb4f67-84dc-4ddb-9f33-8d0410e8bacd",
 "date_created": "Friday, 30-Jun-17 11:17:32 UTC",
 "date_updated": "Friday, 30-Jun-17 13:42:32 UTC",
 “speaker_name": “Andrew Jordan”,
 "topic": "Front to Back REST API Design",
 "uri": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json",
 "subresource_uris": {
 "slides": "api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides.json",
 “recordings": “api.thefamily.co/v1/talks/7abb4f67-84dc-4ddb-9f33-8d0410e8bacd/slides/recordings.json” }
  • 39. REST Request: curl -X DELETE http://api.thefamily.co/v1/talks/ 7abb4f67-84dc-4ddb-9f33-8d0410e8bacd.json 
 -u ‘23679019-81dd-4c24-83c5-2b625c71186c:e592b87e-3c5f-4fed-8d8f- a1edbc88c880' Response: 204 No Content
  • 40. API FLAVOR WHAT IS REST ▸ REST (Representational State Transfer) is an architectural style which advocates that web applications should use HTTP as it was originally envisioned. Lookups should use GET requests. PUT, POST, and DELETE requests should be used for creation, mutation, and deletion. ▸ Create, Read, Update, Delete (CRUD) maps to POST, GET, PUT/PATCH, DELETE