SlideShare uma empresa Scribd logo
1 de 61
API Simplicity == Speed 
Designing APIs That Are Easy and Fun to Use 
Harold Madsen, API Director @ Ancestry.com 
Positions: Platform Initiative + External APIs + Notification + Community 
Speaker: API Strategy (San Fran), RootsTech (SLC), FamilySearch DevCon (BYU) 
Publisher: InformationWeek.com 
September 18, 2014
Agenda 
I. Design Concepts 
II. Design Principles 
III. REST Standards 
IV. Client Proxy Standards 
V. Sum It Up 
Frederick Douglass, abolitionist
3 
Design Concepts 
Before we talk API standards, let’s cover some concepts
Design Affordance 
How A Physical Item 
Is Designed 
Instructs 
How It’s Used 
Psychologist James J. Gibson originally introduced the term in his 
1977 article "The Theory of Affordances“ and explored it more fully 
in his book The Ecological Approach to Visual Perception in 1979 
4
Design Matters 
www.baddesigns.com 
5
Design Matters for APIs Too 
• Good, Bad and the Ugly 
• Used a Bad API? What is it like going to work each day? 
6 
AddressVerify 
Callback 
DoCapture 
DoVoid 
MassPayment 
GetBalance 
TransactionSearch 
UpdateRecurringPaymentProfile 
SetExpressCheckOut 
RefundTransaction 
Etc. 
account.GetBalance(…) 
payments.GetInvoice(…) 
payments.Void(invoiceId) 
payments.Search(…) 
Etc.
API Smell Test 
• Does It Pass the Smell Test? 
• Methods 
 tSndMl 
 MyEventType -> let’s use verbs 
• Parameters 
 SendMail(var1, var2, var3, var4, var5, var6, var7, var8); 
- Maintainability, extensibility, and backwards/forwards compatibility 
• URLs 
 https://somedomain.com/cgi-bin/prod/load_survey_mysql?rater_id={id} 
7 • Service Name: OREM
A Pragmatic Approach to Great APIs 
8 
- Brian Mulloy 
make for happy developers 
“RESTful API Design” 
@landlessness 
Consistent APIs 
Design for simplicity 
and ease of use 
Keep the client (developer) 
in mind
Programs must be written 
for people to read, and 
only incidentally for 
machines to execute 
9 
“ 
- Abelson & Sussman 
Structure & Interpretation 
Of Computer Programs
Design Principles 
What are Ancestry.com’s guiding principles? 
10
Design Guidelines 
• Design with Developer in Mind 
• Be Consistent 
 help developers “guess the answer” 
• Your API should be Obvious 
 what it is and how to use it 
• Good Designs Take Time 
 you have permission 
• Decide as a Group 
 2+ heads make better decisions 
11 • Avoid method-driven approach
Consistency 
Help Developers Anticipate Your Thinking 
• Standard URL Patterns 
 collection/item/collection/item 
• Collections are Plural 
 persons, trees, events 
• Standard Terminology 
 personId, recordId, collectionId, treeId, UserId 
 PID 
• Standard Error Responses 
12
It’s All About Consistency 
• Time To Market 
• Developer Happiness 
• Productivity 
13
14 
Two roads diverged in a wood and I— 
I took the one less traveled by, 
And that has made all the difference. 
– Robert Frost 
REST Client 
Proxies
REST Standards 
REST Standards that bring consistency 
15
Building the Dog API 
(Brian Mulloy inspired) 
16
Starting Point 
• How to Interact with a Dog API 
• Often a Method Driven Approach 
 When Building the App 
 The developer creates a method then discovers… 
 He needs an API to complete his method 
• Pretty soon you have a mess 
• Let’s take a look… 
17
Dog Service (method-driven approach) 
18
What’s Wrong with our Dog API? 
• Verbs are at the beginning and at the end 
 Some have verbs and some don’t 
• API is not guiding the developer 
• No consistency 
• Also, the chances of new hires improving the code are not good – in 
fact, the chances of them making it more confusing are very good! 
 Why? Again, lack of consistency. 
19
A Dog’s World Is Big! 
20
Way Big! 
21
Dog Service (Expanded) 
22
This can become a slippery slope, so 
Keep the simple things simple 
23
Keep It Simple 
24 
Please, something 
good happen!
2 Base URLs Per Resource 
The first is for a collection: 
/dogs 
The second is for an element: 
/dogs/1234 
25
HTTP Verbs CRUD 
POST Create 
GET Read 
PUT Update 
DELETE Delete 
26 
Use 4 HTTP Verbs
API Design Table 
27 
Resource 
POST 
create 
GET 
read 
PUT 
update 
DELETE 
delete 
/dogs 
Create a 
new dog 
 {dogId} 
/dogs/1234
Let’s Have Some Fun! 
• Let’s design a Dog REST API 
• What’s yours going to look like? 
• Let’s go to the board and design it together 
 We’ll take 9.571 minutes 
 Who will our leader be? 
• Questions before we start??? 
• Go! 
28
10 Minutes For API Design
1 Minute Presentations 
You’ve Got 1 Minute To Present! 
30
Let’s Learn More 
Now that you’ve designed your own API, 
let’s talk design again and we’ll start with URLs 
We only need two base URLs per resource. 
31
Harold’s Dogs API 
32 
Resource 
POST 
create 
GET 
read 
PUT 
update 
DELETE 
delete 
/dogs 
/dogs/{dogId} 
Create a 
new dog 
 {dogId} 
Error 
List dogs 
Get a dog 
If not exists 
then error 
Error Error 
Update dog 
If not exists 
then error 
Delete dog 
If not exists 
then error 
* Resist the temptation to use verbs for such things as making your 
dog run for example: /dogs/{dogId}/setDogToRunningInPark
Good, Bad & Ugly 
• Good 
• Bad 
• Ugly 
33 
Nouns 
Verbs (slippery slope) 
/dogs/1234/SetDogToRunningStateInPark 
– Instead, update properties using PUT
Plurals or Singulars? 
• Dog vs Dogs 
• Owner vs Owners 
• Leash vs Leashes 
• Choose one! Consistency please 
• Ancestry standard is plurals 
34
Abstract or concrete naming? 
35
Abstract to Concrete Continuum 
• Super High 
• High 
• Medium 
• Low 
/things 
/animals 
/dogs 
/labrador
Concrete is better than abstract. 
37 
/dogs
What about associations? 
38 
GET /owners/5678/dogs 
POST /owners/5678/dogs
What about complex variations? 
39
Let’s Hide Complexity 
40
Hiding the Complexity 
41 
PUT (update) like this: 
PUT /dogs/1234 
<Dog> 
<Color>Brown</Color> 
<Location>yard</Location> 
<State>Running</State> 
</Dog>
Other Stuff 
42
Versioning Standard 
43 
• Terracotta Warriors – 1st Emperor of China (210 BCE) 
- 8,000 soldiers, 130 chariots with 520 horses, and 150 cavalry horses 
- Each face unique 
• Required 
 Facebook’s Exp 
• Major Versions Only 
 Rare 
 Minor changes OK 
- Additive 
- Robustness Principle
Versioning Standard 
44 
Versioning Examples: 
Github.com 
Accept: application/vnd.github.v3+json 
Odesk.com 
"Accept: application/vnd.odesk.api-v1+json“ 
FamilySearch.org 
“Accept: application/x-fs-v1+json” 
Pivotallabs.com 
Accept: application/vnd.github[.version].param[+json] 
David Zuelke 
Accept: application/vnd.com.myservice.v2+xml 
• Ancestry Versioning 
 External Standard (public facing): place version in url on far left 
- /v1/dogs/{dogId} 
 Internal Standard 
- Accept Header: “accept: application/[component Id].v3+json”
Other Standards 
45 
• Pagination: ?page=1&rows=100 
LinkedIn: start + count 
Google: (#s are one start based) 
+ num (nextpage) 
Facebook: offset + limit 
Twitter: page + rpp 
Spring: page + size 
FamilySearch: start + count 
FaGceitbHouobk: page + per_page 
/joe.smith/friends?fields=id,name,picture 
• Counting: /v1/dogs/count 
• Casing 
 URLs Lowercase (Service-Tier) 
“Be liberal in what you accept and conservative in what you send” 
 Properties PascalCase (language agnostic) 
• Searching: /v1/dogs/search 
 POST body 
• Partial Response: ?fields=name,description,age 
Google 
?fields=title,media:group(media:thumbnail)
46 
Use 2 base URLs 
Use HTTP 
verbs – CRUD 
Doggone ya, 
use Nouns 
Oh, and hide the 
complexity 
REST 
Summation
Client Proxy Standards 
Standards for client proxy 
47
Single Request & Response 
• Use Wrapper Classes 
 Helps with versioning 
• Naming Standard 
 Method name followed by "Request" 
or "Response" 
• Example 
GetDogResponse response = 
GetDog(GetDogRequest request); 
48
49 
Hi, my 
name is Dug 
public class Dog 
{ 
long DogId, 
string Name, “Dug” 
string Description, 
enum Color 
string Owner “Master” 
enum ActivityState 
bool TailState 
etc 
} 
Request & Response Objects
Method Naming 
• Use Full Words 
• Start with a Verb – End with a Noun 
 Use CRUD verbs only: 
- Get, Add, Update, Delete 
• Use Namespacing to Organize Your API 
 Dogs.GetDogs() 
 Dogs.AddDog(addDogRequest request) 
 Owners.GetDogs() 
50
Service Naming 
• Use Full Words 
• Limit Name to 2 Words 
 Users 
 Trees 
 Navigation 
 Records 
• Bad to Good 
OREM Record Corrections 
51
Proxy Guidelines 
• Design interfaces from the client’s perspective 
• An API design should make using it very obvious 
• Design as a group 
 Two heads are usually better than one 
• Remember: Good designs take time - and it's worth it! 
 Take the time to make good decisions 
52
Golly, use full 
words will ya? 
53 
Forget yur CRUD verbs 
(followed by a noun) and you might 
as well forget your can of worms. 
Shucks, use 
Namespacing! 
Yeah, service names ain’t 
but one word. Like 
Users, Trees, Search, Etc 
Proxy 
Summation
Sum It Up 
Let’s review what we’ve talked about 
54
Let’s Design a Trees API 
(your family tree) 
55
56 
Resource 
POST 
create 
GET 
read 
PUT 
update 
DELETE 
delete 
Let’s Use This Chart Again
Let’s Fill In The Chart Together 
57
Harold’s Trees API 
58 
Resource 
POST 
create 
GET 
read 
PUT 
update 
DELETE 
delete 
/trees 
/trees/{treeId} 
Create a 
new tree 
 {treeId} 
Error 
List trees 
(only those I 
own or shared) 
Get a tree 
If not exists 
then error 
Error Error 
Update tree 
If not exists 
then error 
Delete tree 
If not exists 
then error 
* Resist the temptation to use verbs for such things as making your 
tree public for example: /trees/{treeId}/makeMyTreePublic
What We Have Learned 
• Keep Developer In Mind 
• Keep It Simple & Obvious 
• Be Consistent 
• Design as a Group 
• REST APIs 
 Use Nouns 
 Use HTTP Verbs (CRUD) 
 2 URLs per Resource only 
 Hide the Complexity 
59 
• Proxies 
– Full words 
– CRUD Verbs 
▫ Followed by Noun 
– Namespaceing 
Resource 
POST 
create 
GET 
read 
PUT 
update 
DELETE 
delete
Reputation 
Remember, this is Your API. 
Your name is on it. 
This is your reputation riding on the line. 
Will Engineers thank you each day they go to work? 
60
Thank you 
Now Go Design Something Great!

Mais conteúdo relacionado

Semelhante a API Simplicity == Speed; Designing APIs That are Easy and Fun to Use

Do testers have to code... to be useful?
Do testers have to code... to be useful?Do testers have to code... to be useful?
Do testers have to code... to be useful?lisacrispin
 
11 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 201411 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 2014WordPressBrisbane
 
Devops kc meetup_5_20_2013
Devops kc meetup_5_20_2013Devops kc meetup_5_20_2013
Devops kc meetup_5_20_2013Aaron Blythe
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL DevelopersIke Ellis
 
DevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as CodeDevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as CodeMichael Ducy
 
Do testers have to code... to be useful? Janet Gregory and Lisa Crispin plena...
Do testers have to code... to be useful? Janet Gregory and Lisa Crispin plena...Do testers have to code... to be useful? Janet Gregory and Lisa Crispin plena...
Do testers have to code... to be useful? Janet Gregory and Lisa Crispin plena...lisacrispin
 
3.15.17 DSpace: How to Contribute Webinar Slides
3.15.17 DSpace: How to Contribute Webinar Slides3.15.17 DSpace: How to Contribute Webinar Slides
3.15.17 DSpace: How to Contribute Webinar SlidesDuraSpace
 
Introduction to RESTful API Designs
Introduction to RESTful API DesignsIntroduction to RESTful API Designs
Introduction to RESTful API DesignsRoman Kuba
 
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat
 
Master Technical Recruiting Workshop: How to Recruit Top Tech Talent
Master Technical Recruiting Workshop:  How to Recruit Top Tech TalentMaster Technical Recruiting Workshop:  How to Recruit Top Tech Talent
Master Technical Recruiting Workshop: How to Recruit Top Tech TalentRecruitingDaily.com LLC
 
Search-Driven Programming
Search-Driven ProgrammingSearch-Driven Programming
Search-Driven ProgrammingEthan Herdrick
 
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014The Hive
 
Agile Data: Building Hadoop Analytics Applications
Agile Data: Building Hadoop Analytics ApplicationsAgile Data: Building Hadoop Analytics Applications
Agile Data: Building Hadoop Analytics ApplicationsDataWorks Summit
 
SPS NL 18: Teams etiquette
SPS NL 18: Teams etiquetteSPS NL 18: Teams etiquette
SPS NL 18: Teams etiquetteMarijn Somers
 
Leveling Up at JavaScript
Leveling Up at JavaScriptLeveling Up at JavaScript
Leveling Up at JavaScriptRaymond Camden
 
Agile Data Science: Hadoop Analytics Applications
Agile Data Science: Hadoop Analytics ApplicationsAgile Data Science: Hadoop Analytics Applications
Agile Data Science: Hadoop Analytics ApplicationsRussell Jurney
 
Behaviour Driven Development (BDD) With Apex on Force.com
Behaviour Driven Development (BDD) With Apex on Force.comBehaviour Driven Development (BDD) With Apex on Force.com
Behaviour Driven Development (BDD) With Apex on Force.comSalesforce Developers
 
AI and Python: Developing a Conversational Interface using Python
AI and Python: Developing a Conversational Interface using PythonAI and Python: Developing a Conversational Interface using Python
AI and Python: Developing a Conversational Interface using Pythonamyiris
 
2023-My AI Experience - Colm Dunphy.pdf
2023-My AI Experience - Colm Dunphy.pdf2023-My AI Experience - Colm Dunphy.pdf
2023-My AI Experience - Colm Dunphy.pdfColm Dunphy
 
Ultimate Dogfooding: Behind the Scenes of Building the New Jira
Ultimate Dogfooding: Behind the Scenes of Building the New JiraUltimate Dogfooding: Behind the Scenes of Building the New Jira
Ultimate Dogfooding: Behind the Scenes of Building the New JiraAtlassian
 

Semelhante a API Simplicity == Speed; Designing APIs That are Easy and Fun to Use (20)

Do testers have to code... to be useful?
Do testers have to code... to be useful?Do testers have to code... to be useful?
Do testers have to code... to be useful?
 
11 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 201411 Amazing things I Learnt At Word Camp Sydney 2014
11 Amazing things I Learnt At Word Camp Sydney 2014
 
Devops kc meetup_5_20_2013
Devops kc meetup_5_20_2013Devops kc meetup_5_20_2013
Devops kc meetup_5_20_2013
 
14 Habits of Great SQL Developers
14 Habits of Great SQL Developers14 Habits of Great SQL Developers
14 Habits of Great SQL Developers
 
DevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as CodeDevOps Columbus Meetup Kickoff - Infrastructure as Code
DevOps Columbus Meetup Kickoff - Infrastructure as Code
 
Do testers have to code... to be useful? Janet Gregory and Lisa Crispin plena...
Do testers have to code... to be useful? Janet Gregory and Lisa Crispin plena...Do testers have to code... to be useful? Janet Gregory and Lisa Crispin plena...
Do testers have to code... to be useful? Janet Gregory and Lisa Crispin plena...
 
3.15.17 DSpace: How to Contribute Webinar Slides
3.15.17 DSpace: How to Contribute Webinar Slides3.15.17 DSpace: How to Contribute Webinar Slides
3.15.17 DSpace: How to Contribute Webinar Slides
 
Introduction to RESTful API Designs
Introduction to RESTful API DesignsIntroduction to RESTful API Designs
Introduction to RESTful API Designs
 
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your DocumentationLF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
LF_APIStrat17_Don't Repeat Yourself - Your API is Your Documentation
 
Master Technical Recruiting Workshop: How to Recruit Top Tech Talent
Master Technical Recruiting Workshop:  How to Recruit Top Tech TalentMaster Technical Recruiting Workshop:  How to Recruit Top Tech Talent
Master Technical Recruiting Workshop: How to Recruit Top Tech Talent
 
Search-Driven Programming
Search-Driven ProgrammingSearch-Driven Programming
Search-Driven Programming
 
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014
Agile Data Science by Russell Jurney_ The Hive_Janruary 29 2014
 
Agile Data: Building Hadoop Analytics Applications
Agile Data: Building Hadoop Analytics ApplicationsAgile Data: Building Hadoop Analytics Applications
Agile Data: Building Hadoop Analytics Applications
 
SPS NL 18: Teams etiquette
SPS NL 18: Teams etiquetteSPS NL 18: Teams etiquette
SPS NL 18: Teams etiquette
 
Leveling Up at JavaScript
Leveling Up at JavaScriptLeveling Up at JavaScript
Leveling Up at JavaScript
 
Agile Data Science: Hadoop Analytics Applications
Agile Data Science: Hadoop Analytics ApplicationsAgile Data Science: Hadoop Analytics Applications
Agile Data Science: Hadoop Analytics Applications
 
Behaviour Driven Development (BDD) With Apex on Force.com
Behaviour Driven Development (BDD) With Apex on Force.comBehaviour Driven Development (BDD) With Apex on Force.com
Behaviour Driven Development (BDD) With Apex on Force.com
 
AI and Python: Developing a Conversational Interface using Python
AI and Python: Developing a Conversational Interface using PythonAI and Python: Developing a Conversational Interface using Python
AI and Python: Developing a Conversational Interface using Python
 
2023-My AI Experience - Colm Dunphy.pdf
2023-My AI Experience - Colm Dunphy.pdf2023-My AI Experience - Colm Dunphy.pdf
2023-My AI Experience - Colm Dunphy.pdf
 
Ultimate Dogfooding: Behind the Scenes of Building the New Jira
Ultimate Dogfooding: Behind the Scenes of Building the New JiraUltimate Dogfooding: Behind the Scenes of Building the New Jira
Ultimate Dogfooding: Behind the Scenes of Building the New Jira
 

Último

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Último (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

API Simplicity == Speed; Designing APIs That are Easy and Fun to Use

  • 1. API Simplicity == Speed Designing APIs That Are Easy and Fun to Use Harold Madsen, API Director @ Ancestry.com Positions: Platform Initiative + External APIs + Notification + Community Speaker: API Strategy (San Fran), RootsTech (SLC), FamilySearch DevCon (BYU) Publisher: InformationWeek.com September 18, 2014
  • 2. Agenda I. Design Concepts II. Design Principles III. REST Standards IV. Client Proxy Standards V. Sum It Up Frederick Douglass, abolitionist
  • 3. 3 Design Concepts Before we talk API standards, let’s cover some concepts
  • 4. Design Affordance How A Physical Item Is Designed Instructs How It’s Used Psychologist James J. Gibson originally introduced the term in his 1977 article "The Theory of Affordances“ and explored it more fully in his book The Ecological Approach to Visual Perception in 1979 4
  • 6. Design Matters for APIs Too • Good, Bad and the Ugly • Used a Bad API? What is it like going to work each day? 6 AddressVerify Callback DoCapture DoVoid MassPayment GetBalance TransactionSearch UpdateRecurringPaymentProfile SetExpressCheckOut RefundTransaction Etc. account.GetBalance(…) payments.GetInvoice(…) payments.Void(invoiceId) payments.Search(…) Etc.
  • 7. API Smell Test • Does It Pass the Smell Test? • Methods  tSndMl  MyEventType -> let’s use verbs • Parameters  SendMail(var1, var2, var3, var4, var5, var6, var7, var8); - Maintainability, extensibility, and backwards/forwards compatibility • URLs  https://somedomain.com/cgi-bin/prod/load_survey_mysql?rater_id={id} 7 • Service Name: OREM
  • 8. A Pragmatic Approach to Great APIs 8 - Brian Mulloy make for happy developers “RESTful API Design” @landlessness Consistent APIs Design for simplicity and ease of use Keep the client (developer) in mind
  • 9. Programs must be written for people to read, and only incidentally for machines to execute 9 “ - Abelson & Sussman Structure & Interpretation Of Computer Programs
  • 10. Design Principles What are Ancestry.com’s guiding principles? 10
  • 11. Design Guidelines • Design with Developer in Mind • Be Consistent  help developers “guess the answer” • Your API should be Obvious  what it is and how to use it • Good Designs Take Time  you have permission • Decide as a Group  2+ heads make better decisions 11 • Avoid method-driven approach
  • 12. Consistency Help Developers Anticipate Your Thinking • Standard URL Patterns  collection/item/collection/item • Collections are Plural  persons, trees, events • Standard Terminology  personId, recordId, collectionId, treeId, UserId  PID • Standard Error Responses 12
  • 13. It’s All About Consistency • Time To Market • Developer Happiness • Productivity 13
  • 14. 14 Two roads diverged in a wood and I— I took the one less traveled by, And that has made all the difference. – Robert Frost REST Client Proxies
  • 15. REST Standards REST Standards that bring consistency 15
  • 16. Building the Dog API (Brian Mulloy inspired) 16
  • 17. Starting Point • How to Interact with a Dog API • Often a Method Driven Approach  When Building the App  The developer creates a method then discovers…  He needs an API to complete his method • Pretty soon you have a mess • Let’s take a look… 17
  • 19. What’s Wrong with our Dog API? • Verbs are at the beginning and at the end  Some have verbs and some don’t • API is not guiding the developer • No consistency • Also, the chances of new hires improving the code are not good – in fact, the chances of them making it more confusing are very good!  Why? Again, lack of consistency. 19
  • 20. A Dog’s World Is Big! 20
  • 23. This can become a slippery slope, so Keep the simple things simple 23
  • 24. Keep It Simple 24 Please, something good happen!
  • 25. 2 Base URLs Per Resource The first is for a collection: /dogs The second is for an element: /dogs/1234 25
  • 26. HTTP Verbs CRUD POST Create GET Read PUT Update DELETE Delete 26 Use 4 HTTP Verbs
  • 27. API Design Table 27 Resource POST create GET read PUT update DELETE delete /dogs Create a new dog  {dogId} /dogs/1234
  • 28. Let’s Have Some Fun! • Let’s design a Dog REST API • What’s yours going to look like? • Let’s go to the board and design it together  We’ll take 9.571 minutes  Who will our leader be? • Questions before we start??? • Go! 28
  • 29. 10 Minutes For API Design
  • 30. 1 Minute Presentations You’ve Got 1 Minute To Present! 30
  • 31. Let’s Learn More Now that you’ve designed your own API, let’s talk design again and we’ll start with URLs We only need two base URLs per resource. 31
  • 32. Harold’s Dogs API 32 Resource POST create GET read PUT update DELETE delete /dogs /dogs/{dogId} Create a new dog  {dogId} Error List dogs Get a dog If not exists then error Error Error Update dog If not exists then error Delete dog If not exists then error * Resist the temptation to use verbs for such things as making your dog run for example: /dogs/{dogId}/setDogToRunningInPark
  • 33. Good, Bad & Ugly • Good • Bad • Ugly 33 Nouns Verbs (slippery slope) /dogs/1234/SetDogToRunningStateInPark – Instead, update properties using PUT
  • 34. Plurals or Singulars? • Dog vs Dogs • Owner vs Owners • Leash vs Leashes • Choose one! Consistency please • Ancestry standard is plurals 34
  • 35. Abstract or concrete naming? 35
  • 36. Abstract to Concrete Continuum • Super High • High • Medium • Low /things /animals /dogs /labrador
  • 37. Concrete is better than abstract. 37 /dogs
  • 38. What about associations? 38 GET /owners/5678/dogs POST /owners/5678/dogs
  • 39. What about complex variations? 39
  • 41. Hiding the Complexity 41 PUT (update) like this: PUT /dogs/1234 <Dog> <Color>Brown</Color> <Location>yard</Location> <State>Running</State> </Dog>
  • 43. Versioning Standard 43 • Terracotta Warriors – 1st Emperor of China (210 BCE) - 8,000 soldiers, 130 chariots with 520 horses, and 150 cavalry horses - Each face unique • Required  Facebook’s Exp • Major Versions Only  Rare  Minor changes OK - Additive - Robustness Principle
  • 44. Versioning Standard 44 Versioning Examples: Github.com Accept: application/vnd.github.v3+json Odesk.com "Accept: application/vnd.odesk.api-v1+json“ FamilySearch.org “Accept: application/x-fs-v1+json” Pivotallabs.com Accept: application/vnd.github[.version].param[+json] David Zuelke Accept: application/vnd.com.myservice.v2+xml • Ancestry Versioning  External Standard (public facing): place version in url on far left - /v1/dogs/{dogId}  Internal Standard - Accept Header: “accept: application/[component Id].v3+json”
  • 45. Other Standards 45 • Pagination: ?page=1&rows=100 LinkedIn: start + count Google: (#s are one start based) + num (nextpage) Facebook: offset + limit Twitter: page + rpp Spring: page + size FamilySearch: start + count FaGceitbHouobk: page + per_page /joe.smith/friends?fields=id,name,picture • Counting: /v1/dogs/count • Casing  URLs Lowercase (Service-Tier) “Be liberal in what you accept and conservative in what you send”  Properties PascalCase (language agnostic) • Searching: /v1/dogs/search  POST body • Partial Response: ?fields=name,description,age Google ?fields=title,media:group(media:thumbnail)
  • 46. 46 Use 2 base URLs Use HTTP verbs – CRUD Doggone ya, use Nouns Oh, and hide the complexity REST Summation
  • 47. Client Proxy Standards Standards for client proxy 47
  • 48. Single Request & Response • Use Wrapper Classes  Helps with versioning • Naming Standard  Method name followed by "Request" or "Response" • Example GetDogResponse response = GetDog(GetDogRequest request); 48
  • 49. 49 Hi, my name is Dug public class Dog { long DogId, string Name, “Dug” string Description, enum Color string Owner “Master” enum ActivityState bool TailState etc } Request & Response Objects
  • 50. Method Naming • Use Full Words • Start with a Verb – End with a Noun  Use CRUD verbs only: - Get, Add, Update, Delete • Use Namespacing to Organize Your API  Dogs.GetDogs()  Dogs.AddDog(addDogRequest request)  Owners.GetDogs() 50
  • 51. Service Naming • Use Full Words • Limit Name to 2 Words  Users  Trees  Navigation  Records • Bad to Good OREM Record Corrections 51
  • 52. Proxy Guidelines • Design interfaces from the client’s perspective • An API design should make using it very obvious • Design as a group  Two heads are usually better than one • Remember: Good designs take time - and it's worth it!  Take the time to make good decisions 52
  • 53. Golly, use full words will ya? 53 Forget yur CRUD verbs (followed by a noun) and you might as well forget your can of worms. Shucks, use Namespacing! Yeah, service names ain’t but one word. Like Users, Trees, Search, Etc Proxy Summation
  • 54. Sum It Up Let’s review what we’ve talked about 54
  • 55. Let’s Design a Trees API (your family tree) 55
  • 56. 56 Resource POST create GET read PUT update DELETE delete Let’s Use This Chart Again
  • 57. Let’s Fill In The Chart Together 57
  • 58. Harold’s Trees API 58 Resource POST create GET read PUT update DELETE delete /trees /trees/{treeId} Create a new tree  {treeId} Error List trees (only those I own or shared) Get a tree If not exists then error Error Error Update tree If not exists then error Delete tree If not exists then error * Resist the temptation to use verbs for such things as making your tree public for example: /trees/{treeId}/makeMyTreePublic
  • 59. What We Have Learned • Keep Developer In Mind • Keep It Simple & Obvious • Be Consistent • Design as a Group • REST APIs  Use Nouns  Use HTTP Verbs (CRUD)  2 URLs per Resource only  Hide the Complexity 59 • Proxies – Full words – CRUD Verbs ▫ Followed by Noun – Namespaceing Resource POST create GET read PUT update DELETE delete
  • 60. Reputation Remember, this is Your API. Your name is on it. This is your reputation riding on the line. Will Engineers thank you each day they go to work? 60
  • 61. Thank you Now Go Design Something Great!