SlideShare a Scribd company logo
1 of 40
Download to read offline
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

More Related Content

What's hot

What's hot (20)

[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
[AWS Dev Day] 앱 현대화 | AWS Fargate를 사용한 서버리스 컨테이너 활용 하기 - 삼성전자 개발자 포털 사례 - 정영준...
 
Api Testing
Api TestingApi Testing
Api Testing
 
Appium ppt
Appium pptAppium ppt
Appium ppt
 
Component testing with cypress
Component testing with cypressComponent testing with cypress
Component testing with cypress
 
DevOps and AWS
DevOps and AWSDevOps and AWS
DevOps and AWS
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
 
Automated testing with Cypress
Automated testing with CypressAutomated testing with Cypress
Automated testing with Cypress
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
 
Nestjs MasterClass Slides
Nestjs MasterClass SlidesNestjs MasterClass Slides
Nestjs MasterClass Slides
 
Infrastructure as Code
Infrastructure as CodeInfrastructure as Code
Infrastructure as Code
 
Continuous delivery and deployment on AWS
Continuous delivery and deployment on AWSContinuous delivery and deployment on AWS
Continuous delivery and deployment on AWS
 
Amazon Kinesis
Amazon KinesisAmazon Kinesis
Amazon Kinesis
 
Appium: Automation for Mobile Apps
Appium: Automation for Mobile AppsAppium: Automation for Mobile Apps
Appium: Automation for Mobile Apps
 
Deep Dive into AWS Fargate
Deep Dive into AWS FargateDeep Dive into AWS Fargate
Deep Dive into AWS Fargate
 
Modern Python Testing
Modern Python TestingModern Python Testing
Modern Python Testing
 
Building APIs with Apigee Edge and Microsoft Azure
Building APIs with Apigee Edge and Microsoft AzureBuilding APIs with Apigee Edge and Microsoft Azure
Building APIs with Apigee Edge and Microsoft Azure
 
Getting Started with Azure Artifacts
Getting Started with Azure ArtifactsGetting Started with Azure Artifacts
Getting Started with Azure Artifacts
 
Engage your users with Amazon SNS Mobile Push (Now with Broadcast) - Jinesh V...
Engage your users with Amazon SNS Mobile Push (Now with Broadcast) - Jinesh V...Engage your users with Amazon SNS Mobile Push (Now with Broadcast) - Jinesh V...
Engage your users with Amazon SNS Mobile Push (Now with Broadcast) - Jinesh V...
 
CI/CD with GitHub Actions
CI/CD with GitHub ActionsCI/CD with GitHub Actions
CI/CD with GitHub Actions
 
Selenium test automation
Selenium test automationSelenium test automation
Selenium test automation
 

Viewers also liked

Viewers also liked (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
 

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

Similar to "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
 

More from TheFamily

More from 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
 

Recently uploaded

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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 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
 

"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