SlideShare uma empresa Scribd logo
1 de 35
API DESIGN ANTI-
PATTERNS
Jason Harmon
API Design @PayPal @Braintree
@jharmn
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
COLLECTOR OF
MISTAKESJob #1 in creating consistent DX
MIXED UP
CONVENTION
S
Path, query parameters,
headers, fields
resourceName
resource-name
resource_name
PICK ONE, BE
CONSISTENT!
PARAMETER
CONFUSIONPath, Query, Body, Header?
• A few rules of thumb:
• Path: required, resource-identifier
• Query: optional, query collections
• Body: resource-specific/logic
• Header: global/platform-wide
API PARAMETERS
JSON JUNK DRAWER
https://www.youtube.com/watch?v=-
MBXsmSrKE8
REST API Design: Avoid future proofing with the JSON junk
drawer
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
SEQUENTIAL
IDENTIFIERS
/invoices/8765432
Usually derived from
database sequences
+1 each time a resource is
created
• https://www.owasp.org/index.php/Top_10_20
10-A4-Insecure_Direct_Object_References
• Developers suck at securing resources
• Better to use non-sequential strings for
resource IDs
• UUID/GUID is an obvious option
INSECURE DIRECT OBJECT
REFERENCE
IDENTITY IN URLS
/license?user=BR548076
/license?token=E43FD312
/users/T22000129/license
HTTP DEFINES AUTH
http://tools.ietf.org/html/rfc7235#section-4.2
Use the Authorization header + token
DON’T FORGET THE
LOGSMost web servers/proxies/intermediaries log:
Verb + URL, not often query, rarely headers
RELAX.
These are pretty easy fixes, if it’s not live yet (or
v2).
Plus, there’s a bright future.
DESIGN FIRST
There’s really not a reasonable debate
A DESIGN REMEDIAL
Thinking developer experience
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
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
AUTOMATE
Spec-driven development
DESIGN
Collaborate on new design in API spec
GOVERNANCE
Validate design against API standards
CREATE STANDARDS
Make the rules, and stick to them
STANDARDS
Some of the primary concerns
• Authentication/Authorizat
ion
• Versioning
• Naming conventions for
URLs, parameters,
headers
• Interaction patterns with
verbs
• Paging/sorting
• Hypermedia semantics
SHARE STANDARDS!
If we all share, broad consistency can exist
PayPal API Style Guide
https://devblog.paypal.com/paypals-api-style-guide/
DISCOVER
Render specs in developer portal
Indicate planned APIs vs live
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
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
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
DEVELOP
Build APIs according to specs
Validate request/response in app from spec
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
VALIDATE DESIGN
Check request/response vs spec in acceptance
tests
BDD FTW
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
GO LIVE!
Be sure to integrate validation with CI
WORKS AS DESIGNED
You can still always screw up, so be smart
Jason Harmon
API Design @PayPal @Braintree
@jharmn

Mais conteúdo relacionado

Mais de Jason Harmon

Essential Ingredients for a Successful API Program
Essential Ingredients for a Successful API ProgramEssential Ingredients for a Successful API Program
Essential Ingredients for a Successful API ProgramJason Harmon
 
Do's and Don'ts of APIs
Do's and Don'ts of APIsDo's and Don'ts of APIs
Do's and Don'ts of APIsJason Harmon
 
Api Design Anti-Patterns
Api Design Anti-PatternsApi Design Anti-Patterns
Api Design Anti-PatternsJason Harmon
 
Tools and techniques for APIs
Tools and techniques for APIsTools and techniques for APIs
Tools and techniques for APIsJason Harmon
 
Past, Present, Future of APIS
Past, Present, Future of APISPast, Present, Future of APIS
Past, Present, Future of APISJason Harmon
 
Scaling API Design
Scaling API DesignScaling API Design
Scaling API DesignJason Harmon
 
Scaling API Design - Nordic APIs 2014
Scaling API Design - Nordic APIs 2014Scaling API Design - Nordic APIs 2014
Scaling API Design - Nordic APIs 2014Jason Harmon
 
Scaling API Design @restfest
Scaling API Design @restfestScaling API Design @restfest
Scaling API Design @restfestJason Harmon
 
Scaling API Design
Scaling API DesignScaling API Design
Scaling API DesignJason Harmon
 

Mais de Jason Harmon (12)

Essential Ingredients for a Successful API Program
Essential Ingredients for a Successful API ProgramEssential Ingredients for a Successful API Program
Essential Ingredients for a Successful API Program
 
Do's and Don'ts of APIs
Do's and Don'ts of APIsDo's and Don'ts of APIs
Do's and Don'ts of APIs
 
Api Design Anti-Patterns
Api Design Anti-PatternsApi Design Anti-Patterns
Api Design Anti-Patterns
 
Api Design
Api DesignApi Design
Api Design
 
Tools and techniques for APIs
Tools and techniques for APIsTools and techniques for APIs
Tools and techniques for APIs
 
Past, Present, Future of APIS
Past, Present, Future of APISPast, Present, Future of APIS
Past, Present, Future of APIS
 
Scaling API Design
Scaling API DesignScaling API Design
Scaling API Design
 
Scaling API Design - Nordic APIs 2014
Scaling API Design - Nordic APIs 2014Scaling API Design - Nordic APIs 2014
Scaling API Design - Nordic APIs 2014
 
Scaling API Design @restfest
Scaling API Design @restfestScaling API Design @restfest
Scaling API Design @restfest
 
Scaling API Design
Scaling API DesignScaling API Design
Scaling API Design
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 

Último

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 

Último (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

API Design Anti-Patterns

Notas do Editor

  1. YAML & Markdown-based editing have moved this forward a lot from early JSON days
  2. This is an emerging field. Side project coming together to look at this problem with Swagger
  3. Swagger/RAML/Blueprint give you a free UI to view the spec
  4. Tangible. Curl it or it didn’t happen. Swagger/RAML/Blueprint all have free projects to make this happen, some integrated into the UI
  5. Validating request/response is not an easy drop-in for most languages. A bit of an emerging area.
  6. 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.
  7. Make sure the design first pipeline is CI automated This process ensures confident change, as well as quality design