SlideShare a Scribd company logo
API 
An&pa)erns 
…iden&fying, 
and 
avoiding 
them 
Manish Pandit 
@lobster1234
Manish 
Pandit 
@lobster1234 
mpandit 
at 
neAlix 
dot 
com 
linkedin.com/in/mpandit 
slideshare.net/lobster1234 
@lobster1234
APIs 
A 
means 
for 
soGware 
to 
interact 
with 
other 
soGware. 
@lobster1234
@lobster1234
@lobster1234 
Image 
Credit: 
h)p://en.wikipedia.org/wiki/Internet_of_Things
@lobster1234
REST 
API 
REST 
is 
not 
a 
standard, 
but 
an 
architecture 
@lobster1234
REST 
API 
REST 
is 
not 
a 
standard, 
but 
an 
architecture, 
which 
uses 
HTTP 
as 
a 
model 
for 
all 
interac.ons. 
If 
HTTP 
is 
a 
standard, 
REST 
is 
a 
conven&on. 
@lobster1234
@lobster1234
REST 
API 
Noun 
è 
Resource, 
or 
the 
En&ty 
Verb 
Ac&on 
+ 
è 
Iden.fier 
@lobster1234
Image: 
h)p://www.educa&on.com/study-­‐help/ar&cle/nouns/ 
@lobster1234
Protocol 
May 
or 
may 
not 
be 
standard 
@lobster1234
Protocol 
May 
or 
may 
not 
be 
standard 
Indicates 
an 
agreement 
between 
the 
par&es 
@lobster1234
@lobster1234
Payload 
Format 
(XML, 
JSON, 
Custom 
Text, 
Binary..) 
Transport 
(HTTP, 
Binary 
over 
sockets, 
FTP..) 
@lobster1234
@lobster1234
h)p://www.neAlix.com/header/neAlix_logo.gif 
Or, 
reques.ng 
a 
resource 
from 
the 
server 
by 
giving 
its 
path 
using 
a 
protocol. 
@lobster1234
Every 
request 
deserves 
a 
response. 
@lobster1234
Headers 
describe 
the 
response 
@lobster1234
Headers 
describe 
the 
response 
Status 
Code 
indicates 
the 
success/failure 
@lobster1234
Headers 
describe 
the 
response 
Status 
Code 
indicates 
the 
success/failure 
Body 
contains 
the 
actual 
payload 
@lobster1234
Tell 
the 
server 
what 
to 
do 
via 
ac.ons 
@lobster1234
Ac&ons 
are 
HTTP 
methods, 
which 
map 
nicely 
to 
(most 
of) 
the 
business 
interac&ons 
@lobster1234
Create 
– 
POST 
Read 
– 
GET 
Update 
– 
PUT 
(or 
PATCH) 
Delete 
-­‐ 
DELETE 
HEAD, 
OPTIONS, 
TRACE, 
CONNECT 
@lobster1234
Pa)erns 
@lobster1234
Pa)erns 
Pa)erns 
are 
re-­‐usable 
solu&ons 
to 
commonly 
occurring 
problems. 
@lobster1234
Common 
Scenarios 
Gebng 
data 
from 
the 
server 
@lobster1234
Common 
Scenarios 
Gebng 
data 
from 
the 
server 
Sending 
data 
to 
the 
server 
@lobster1234
An&pa)erns 
An&pa)erns 
are 
re-­‐usable 
solu&ons 
to 
commonly 
occurring 
problems, 
that 
look 
great 
on 
the 
surface, 
but 
really 
aren’t. 
@lobster1234
Request 
An&pa)erns 
@lobster1234
Over-­‐using 
Query 
Strings 
@lobster1234
/pets?name=scruffy 
vs. 
/pets/name/scruffy 
@lobster1234
/pets?name=scruffy&zip=94568 
vs. 
/pets/name/scruffy/loca&on/zip/94568 
@lobster1234
Avoid 
query 
strings 
for 
resource 
iden&fica&on 
But 
use 
them 
for 
request 
metadata 
* 
*Except 
for 
search 
@lobster1234
Pagina&on 
Filtering 
Sor&ng 
.. 
@lobster1234
@lobster1234
Query 
Strings 
h)p://some.api.com/movies? 
start=0&count=10&sortBy=name&fields=name, 
cast,releaseDate 
@lobster1234
Allowing 
clients 
to 
scrape 
the 
data 
via 
your 
APIs 
@lobster1234
@lobster1234
Think 
batch 
jobs 
reques&ng 
the 
catalog 
nightly! 
@lobster1234
Request 
metadata 
to 
the 
rescue? 
@lobster1234
….how 
about 
a 
?since=1d 
…or 
?since=UTC 
@lobster1234
Method 
An&pa)erns 
@lobster1234
Using 
Query 
Strings 
to 
overload 
verbs 
@lobster1234
/pets?perform=update&name=scruffy&id=24 
@lobster1234
Use 
the 
appropriate 
HTTP 
Method 
to 
represent 
your 
ac&on 
@lobster1234
Using 
POST 
for 
all 
writes 
@lobster1234
GET 
to 
retrieve, 
or 
search 
POST 
to 
create, 
or 
upsert 
PUT 
to 
update 
(or 
be)er 
yet, 
PATCH) 
DELETE 
to 
delete 
@lobster1234
Using 
HTTP 
PUT 
or 
POST 
to 
set 
a 
value 
to 
null 
@lobster1234
Updates 
vs. 
Deletes 
Everything 
works 
when 
there 
is 
data, 
but 
what 
when 
there 
is 
no 
data..? 
@lobster1234
Use 
HTTP 
DELETE 
to 
set 
a 
value 
to 
null 
Remember, 
we 
have 
a 
path 
to 
not 
just 
the 
resource, 
but 
also 
it’s 
a)ributes 
@lobster1234
DELETE 
/pets/<id>/collartag 
@lobster1234
Response 
An&pa)erns 
@lobster1234
Always 
returning 
HTTP 
200 
@lobster1234
@lobster1234
HTTP 
200 
OK 
{ 
“success” 
: 
false 
} 
@lobster1234
HTTP 
200 
OK 
{ 
“error” 
: 
”Person 
jdoe 
not 
found” 
} 
@lobster1234
2xx 
for 
success 
3xx 
for 
redirects/caching 
4xx 
for 
request/client 
errors 
5xx 
for 
server 
errors 
@lobster1234
Some 
Useful 
(and 
not 
so 
common) 
Codes 
Return 
aGer 
a 
delete 
-­‐ 
204 
Failed 
database 
constraint 
-­‐ 
409 
Method 
not 
supported 
-­‐ 
405 
Trying 
to 
ask 
for 
too 
much 
data 
-­‐ 
413 
Valida&on 
Failure 
-­‐ 
418 
@lobster1234
Always 
returning 
a 
401 
for 
auth 
failures
@lobster1234
Auth 
Use 
HTTP 
401 
Unauthorized 
to 
indicate 
that 
the 
client 
needs 
to 
authen&cate 
@lobster1234
Auth 
Use 
HTTP 
403 
Forbidden 
to 
indicate 
that 
the 
client’s 
creden&als 
do 
not 
allow 
access 
to 
the 
requested 
resource 
@lobster1234
401 
vs 
403 
401 
= 
Come 
back 
with 
a 
key 
403 
= 
Your 
key 
does 
not 
work 
for 
this 
lock. 
@lobster1234
Processing 
requests 
synchronously, 
even 
&me 
intensive 
ones 
@lobster1234
Async 
the 
opera&on, 
and 
return 
HTTP 
202 
– 
Accepted 
@lobster1234
@lobster1234
Async 
opera&on’s 
response 
should 
help 
the 
caller. 
{“statusUrl”: 
<some 
URL>} 
@lobster1234
Organiza&onal 
An&pa)erns 
@lobster1234
Not 
differen&a&ng 
between 
en..es 
and 
instances 
@lobster1234
/pets?type=dog&name=big 
vs 
/pets/dogs/name/big 
@lobster1234
Namespace 
your 
resources 
in 
a 
collec&on 
Use 
paths 
and 
iden&fiers 
to 
traverse 
@lobster1234
Using 
id 
in 
the 
resource 
iden&fica&on 
path 
@lobster1234
/pets/id/1234 
vs 
/pets/1234 
@lobster1234
Use 
all 
other 
a)ributes 
in 
the 
path, 
except 
the 
id. 
id 
is 
implied 
@lobster1234
@lobster1234 
Resources 
in 
an 
island
@lobster1234
Every 
en&ty 
or 
a 
resource 
is 
&ed 
to 
others. 
@lobster1234
Every 
en&ty 
or 
a 
resource 
is 
&ed 
to 
others. 
And 
you’re 
stuck 
guessing 
the 
connec&ons! 
@lobster1234
@lobster1234 
We’ll 
just 
return 
the 
IDs!
HATEOAS 
(or 
something 
similar) 
@lobster1234
Read 
code 
to 
figure 
out 
the 
resources 
and 
a)ributes. 
@lobster1234
@lobster1234
Use 
Meta 
pages 
for 
resource 
descrip&on 
/resource/meta 
/collec&on/meta 
@lobster1234
APIs 
are 
not 
discoverable 
@lobster1234
Consider 
a 
documenta&on 
generator 
like 
Swagger, 
IODocs 
@lobster1234
Relying 
on 
cookies 
for 
authen&ca&on 
@lobster1234
@lobster1234
Accept 
cookies 
as 
a 
fallback, 
but 
prefer 
a 
query 
parameter 
or 
HTTP 
request 
header. 
@lobster1234
Storing 
state 
on 
the 
server 
nodes 
@lobster1234
Stateless 
== 
Simple 
@lobster1234
Requests 
either 
modify 
the 
state 
of 
a 
resource, 
or 
read 
it. 
All 
requests 
to 
the 
cluster 
see 
the 
same 
state 
of 
the 
resource 
@lobster1234
Avoid 
state 
as 
much 
as 
possible. 
Maintain 
the 
state 
in 
the 
database. 
If 
you 
need 
to 
store 
transient 
state 
on 
the 
server, 
it’s 
a 
code 
(or 
architecture) 
smell. 
@lobster1234
Versioning 
Using 
301s 
to 
redirect/re&re 
APIs 
Caching 
Using 
HTTP 
headers 
correctly 
Caching 
response 
bodies 
@lobster1234
@lobster1234 
Fin

More Related Content

PPTX
Google Dorks
PPTX
Exploiter le Web Semantic, le comprendre et y contribuer
PPTX
Google Dorks and SQL Injection
PDF
Building Beautiful REST APIs in ASP.NET Core
PPTX
Beautiful REST+JSON APIs with Ion
PPTX
Google Dorks
PPTX
Creating Linked Data 2/5 Semtech2011
ODP
An Overview on PROV-AQ: Provenance Access and Query
Google Dorks
Exploiter le Web Semantic, le comprendre et y contribuer
Google Dorks and SQL Injection
Building Beautiful REST APIs in ASP.NET Core
Beautiful REST+JSON APIs with Ion
Google Dorks
Creating Linked Data 2/5 Semtech2011
An Overview on PROV-AQ: Provenance Access and Query

What's hot (18)

PDF
The Google Hacking Database: A Key Resource to Exposing Vulnerabilities
PPTX
Building Beautiful REST APIs in ASP.NET Core
PPT
Enhance Your Google Search
ODP
Creating APIs over RDF
PPS
Google Search Techniques
PDF
Introduction to Elasticsearch
PDF
Kiran karnad rtc2014 ghdb-final
PDF
Demystifying Apache Kafka, once and for all | Jonathan Santilli, Snyk
PDF
Bigdive 2014 - RDF, principles and case studies
PPTX
1-04: HTML Elements
PPT
Agile Descriptions
PPTX
Google search techniques
PDF
Building Smarter Search Applications Using Built-In Knowledge Graphs and Quer...
PPTX
Chris Gutteridge: RDF Crash Course
PPT
Google
PPS
Googlesearchtechniques 090402135045-phpapp01
PPT
Google search tips
PPT
Google searching techniques
The Google Hacking Database: A Key Resource to Exposing Vulnerabilities
Building Beautiful REST APIs in ASP.NET Core
Enhance Your Google Search
Creating APIs over RDF
Google Search Techniques
Introduction to Elasticsearch
Kiran karnad rtc2014 ghdb-final
Demystifying Apache Kafka, once and for all | Jonathan Santilli, Snyk
Bigdive 2014 - RDF, principles and case studies
1-04: HTML Elements
Agile Descriptions
Google search techniques
Building Smarter Search Applications Using Built-In Knowledge Graphs and Quer...
Chris Gutteridge: RDF Crash Course
Google
Googlesearchtechniques 090402135045-phpapp01
Google search tips
Google searching techniques
Ad

Viewers also liked (20)

PDF
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
PPTX
Fonts N Tht
PPTX
Funcionlinealyafin
PPT
Activities Done
PPT
Speedinterviewing Sept2009
PPT
Προτάσεις για τη διδασκαλία ΠΕ4 γυμνασίου Γενάρης 12
PDF
Clas.Cruz09
PPT
Jointure Naturelle3
PPTX
20150901 Mapping Yorkshire
PDF
It eigo 20101029
KEY
Jason's timeline
PPS
Makro Sunum2
PPTX
Silicon Valley Code Camp: 2011 Introduction to MongoDB
PPTX
PPTX
How To
 
PDF
Small Group Makeup Workshops in Tauranga
PDF
13112282 Aig Risk Bankruptcy Report
DOC
Research Into Our Potential Target Audience
PPT
Pervasive And Personnal Learning
PPTX
Tom Gorham Class Content
OSCON 2014 - API Ecosystem with Scala, Scalatra, and Swagger at Netflix
Fonts N Tht
Funcionlinealyafin
Activities Done
Speedinterviewing Sept2009
Προτάσεις για τη διδασκαλία ΠΕ4 γυμνασίου Γενάρης 12
Clas.Cruz09
Jointure Naturelle3
20150901 Mapping Yorkshire
It eigo 20101029
Jason's timeline
Makro Sunum2
Silicon Valley Code Camp: 2011 Introduction to MongoDB
How To
 
Small Group Makeup Workshops in Tauranga
13112282 Aig Risk Bankruptcy Report
Research Into Our Potential Target Audience
Pervasive And Personnal Learning
Tom Gorham Class Content
Ad

Similar to Scalabay - API Design Antipatterns (20)

PDF
Silicon Valley 2014 - API Antipatterns
PPTX
API Design Antipatterns - APICon SF
PPTX
Creating Truly RESTful APIs
PPTX
Pragmatic REST APIs
PPTX
REST Api Tips and Tricks
ODP
NEPHP '13: Pragmatic API Development
PPTX
REST library.pptx
KEY
Designing a RESTful web service
PDF
Создание API, которое полюбят разработчики. Глубокое погружение
PPTX
A Deep Dive into RESTful API Design Part 2
PPTX
Understanding APIs.pptx
PPTX
Understanding APIs.pptx introduction chk
PPT
RESTful SOA - 中科院暑期讲座
PDF
RefCard RESTful API Design
PDF
Resource-Oriented Web Services
PPTX
Standards of rest api
PDF
REST API Basics
PDF
Don't screw it up! How to build durable API
PDF
WordPress RESTful API & Amazon API Gateway (English version)
PPTX
RESTful for opentravel.org by HP
Silicon Valley 2014 - API Antipatterns
API Design Antipatterns - APICon SF
Creating Truly RESTful APIs
Pragmatic REST APIs
REST Api Tips and Tricks
NEPHP '13: Pragmatic API Development
REST library.pptx
Designing a RESTful web service
Создание API, которое полюбят разработчики. Глубокое погружение
A Deep Dive into RESTful API Design Part 2
Understanding APIs.pptx
Understanding APIs.pptx introduction chk
RESTful SOA - 中科院暑期讲座
RefCard RESTful API Design
Resource-Oriented Web Services
Standards of rest api
REST API Basics
Don't screw it up! How to build durable API
WordPress RESTful API & Amazon API Gateway (English version)
RESTful for opentravel.org by HP

More from Manish Pandit (20)

PDF
Disaster recovery - What, Why, and How
PDF
Serverless Architectures on AWS in practice - OSCON 2018
PDF
Disaster Recovery and Reliability
PDF
OAuth2 primer
PDF
Immutable AWS Deployments with Packer and Jenkins
PDF
AWS Lambda with Serverless Framework and Java
PDF
AWS Primer and Quickstart
PPTX
Securing your APIs with OAuth, OpenID, and OpenID Connect
PPTX
Motivation : it Matters
PPTX
Building Apis in Scala with Playframework2
PPTX
Scala at Netflix
PPT
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
PPT
Evolving IGN’s New APIs with Scala
PPTX
IGN's V3 API
PPTX
Java and the JVM
PPTX
Object Oriented Programming
PPTX
Silicon Valley Code Camp 2011: Play! as you REST
PPT
NoSQLCamp : MongoDB at IGN
PPTX
MongoSF 2011 - Using MongoDB for IGN's Social Platform
PPTX
Silicon Valley Code Camp 2010: Social Platforms : What goes on under the hood
Disaster recovery - What, Why, and How
Serverless Architectures on AWS in practice - OSCON 2018
Disaster Recovery and Reliability
OAuth2 primer
Immutable AWS Deployments with Packer and Jenkins
AWS Lambda with Serverless Framework and Java
AWS Primer and Quickstart
Securing your APIs with OAuth, OpenID, and OpenID Connect
Motivation : it Matters
Building Apis in Scala with Playframework2
Scala at Netflix
Introducing Scala to your Ruby/Java Shop : My experiences at IGN
Evolving IGN’s New APIs with Scala
IGN's V3 API
Java and the JVM
Object Oriented Programming
Silicon Valley Code Camp 2011: Play! as you REST
NoSQLCamp : MongoDB at IGN
MongoSF 2011 - Using MongoDB for IGN's Social Platform
Silicon Valley Code Camp 2010: Social Platforms : What goes on under the hood

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation theory and applications.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Machine learning based COVID-19 study performance prediction
PDF
Modernizing your data center with Dell and AMD
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
MYSQL Presentation for SQL database connectivity
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
A Presentation on Artificial Intelligence
Teaching material agriculture food technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
NewMind AI Monthly Chronicles - July 2025
Per capita expenditure prediction using model stacking based on satellite ima...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation theory and applications.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Chapter 3 Spatial Domain Image Processing.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Machine learning based COVID-19 study performance prediction
Modernizing your data center with Dell and AMD
Spectral efficient network and resource selection model in 5G networks
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
MYSQL Presentation for SQL database connectivity
The Rise and Fall of 3GPP – Time for a Sabbatical?
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
A Presentation on Artificial Intelligence

Scalabay - API Design Antipatterns