SlideShare a Scribd company logo
Effective API Design
Bansi Haudakari
API’s Are
For the Developers,
By The Developers
And
Of the Developers
- Bansi Haudakari
Who Am I?
• An API Developer
• An API Consumer
• An API Designer
• A Seasoned JAVA Programmer
who has been consuming JAVA
API’s since JDK 1.0 And Other
Open Source APIs For Software
Development
Agenda
• What is an API?
• Driving factors Of an API
• Principles of Effective API Design
• API Design Guidelines
• API Design In Action
• Value Of Great APIs
• Pitfalls of mediocre APIs
What is an API?
Application Programming Interface provides a
way for developers to interact with and consume a
service.
Analogy: Electrical Sockets
• APIs are gateways between Services and Consumers,
providing consumers access to services through various
interfaces
Example: Service : Electricity AND Consumer : Plug
• Our laptops, consumes electricity through a socket.
Through its own “API,” a USB socket, it can provide that
same electricity service to charge other devices.
Driving Factors
• Design of CHM
• Business Agility : Business Logic is exposed thru
APIs thereby enabling customers to focus on
innovations
• API Economy : Businesses are developing “API
products” as new sources of revenue. Expedia
generates over $2 billion thru data made
available through their API
• Internet of things: The number of things that
can be connected is growing fast; everything
from your coffee pot to your thermostat to
your car can now be accessed thru APIs
Principle 1 : Design First API
• With Design-First approach, focus is on
well-defined API spec’s instead of
implementation concerns.
• With an Design-First API approach, rather
than implementing an application and then
building API on top of it, first create the
interface and then put the back-end logic
into place - whether it be cloud-based or
on-premise.
• An optimal API design enables applications
developers to easily understand the
purpose and functionality of the API.
• It also allows organizations to focus on
getting API design right before investing in
back-end implementation,
• The best way to design an API that developers
want to use is to iteratively define the
structure of the API in an expressive manner
and get feedback from developers on its
usability and functionality
• As the API is designed, application developers
can interact with it and test its behavior,
thanks to an integrated mocking service that
returns the values a call to the live API would
produce.
• There is no such thing as a one-size-fits-all API
• An API should be optimized to fulfill a specific
business request in a specific context.
• Optimize API for a specific use case e.g.
– coarse or fine-grained
– constraints e.g. network trips, latency and data
size so API should be designed to limit backend
calls and minimize the size of data returned
API Design Guidelines
• Know the requirements
• Write use cases before you write any other
code
• Look for similar APIs in the same library
• Define the API before you implement it
otherwise it embodies the evils of
implementation-driven APIs i.e. don’t let
implementation considerations leak into the
API, apart in exceptional cases
API Design Guidelines
• Consider the perspective of the caller
• Make sure each method does only one thing
• Make all method calls atomic
• Limit the number of Mutator methods i.e.
set/get methods
• Favor generic methods over a set of overloaded
methods
• Avoid long-running methods
• Avoid forcing callers to write loops for basic
scenarios
API Design Guidelines
• Avoid “option” parameters to modify behavior
• Avoid non-reentrant methods
• Do not strengthen the precondition of an already released API
method
• Do not weaken the post condition of an already released API
method
• Do not add new methods to released interfaces
• Do not add a new overload to a released API
• Favor interfaces over concrete classes as return types
• Favor empty collections to null return values
• Consider making defensive copies of mutable parameters
• Consider storing weak object references internally
• Avoid parameter types exposing implementation details
API Design Guidelines
• Avoid returning references to mutable internal 
objects
• Consider a builder when faced with many 
constructor parameters
• Consider returning immutable collections from 
a getter
• Consider read-only properties
•  Document method preconditions
•  Document the performance characteristics of 
the algorithm implemented
Measure API Design
• Conceptual Complexity Measurement :
– double digit : use case is simple ;
– single digit : complex ;
– negative number : time to re-design
– In your code, Count the number of name constructs used in API
• try {
 AuthenticationProvider20 provider = new LocalAuthenticationProvider19();
SearchCriteria18 criteria = new SearchCriteria17(EntityName16.USER15);
criteria.addPropertyToFetch14(PropertyName13.COMMON_NAME12);
….
while(iterator.hasNext()4){
Profile3 profile = iterator.next()2;
Property1 commonName =
profile.getProperty0(PropertyName.COMMON_NAME); Property phone =
profile.getProperty(PropertyName.PHONE);
System.out.println(commonName.getValue()-1, “ ”, phone.getValue()); } }
catch(AuthenticationProviderException-2 e) { }
API Design In Action
Before After Design Rule
public long[]
getAllMessages() throws
MailboxException;
public abstract
SortedSet<T>
readAllMessageHeaders(
) throws
RemoteException,
MailboxException;
Favor collections over
arrays as parameters and
return values
Ensure no boilerplate
code is needed to
combine method calls
Reserve “get”, “set” and
“is” for JavaBeans
methods accessing local
fields
Throw checked
exceptions only for
recoverable errors
API Design In Action
Before After Design Rule
public void markRead(boolean
read, long[] ids) throws
MailboxException;
public abstract void
markRead(Collection<T>
headers) throws
NullPointerException,
RemoteException,
MailboxException;
Make all method calls atomic
 Avoid Boolean parameters
Ensure no boilerplate code is
needed to combine method
calls
Consider generic methods
Consider method pairs, where
the effect of one is reversed by
the other
Favor generic collections over
raw (untyped) collections
Throw NullPointerException to
indicate a prohibited null
parameter value
 Favor standard Java
exceptions over custom
exceptions
Principle 2 – Runtime API
• Once an API is designed, created and its back-
end implemented, it’s time to  find the right 
run-time as it affects How successful your API 
strategy will be in terms of service, liability, 
scale and ability to meet future needs.
• Hybrid support: As more and more businesses 
are moving to the cloud, so it is important to 
find runtime that allows to deploy applications 
both in the cloud as well as on-premise without 
having to modify anything.
• Scalability, reliability, availability: These “-ilities”, 
along with performance, are crucial when 
searching for a solid API runtime. The last thing 
you want is an unstable runtime that crashes or 
experiences outages. Choosing the right 
enterprise grade technology for your API runtime 
is crucial to the success of your API.
• Strong Orchestration: A successful runtime should 
provide strong orchestration and orchestration 
capabilities. The ability to carry out complex back-
end orchestration plays a key role in translation 
between the API layer and back-end 
implementation.
Principle 3 – API Design Contract
• API publishers should offer a way to easily 
create well-defined policies and contracts and 
associate them with the right APIs and 
consumers. 
• API Contracts are crucial for enforcing security 
and managing SLAs with API consumers.
• In addition, publish API version which helps in 
lifecycle management and allows API publishers 
to assess the impact of retiring a version. 
Example REST API’s
Principle 4 - Monitor API Usage
• The ability to monitor API usage over a period of
time and understand usage patterns from both
technical and business perspectives is valuable as
it helps business owners and technical teams
better understand their users and ultimately
create a better service.
• You need to see how consumers are using it i.e.
which parts of your service are being used.
• With metrics for both overall usage and per
consumer usage, businesses can closely monitor
API activity and engagement.
Principle 5 - Continuous Improvement
• The ability to re-factor your APIs by iterating
through habits 1-6 multiple times allows you to
optimize your API over time to improve
consumer experience and productivity.
• API is not a static entity – as new use cases are
identified and use of your API expands,
enhancements and fixes are inevitable.
Principle 6 -Socialize Your APIs
• Create a developer portal to establish a
community around your API is important to its
success. By making it easy for users to follow
your API, download documentation and ask
questions, API publishers can engage with API
consumers on an ongoing basis.
• Example create a developer portal for company-
wide REST services and document it using
Swagger
APIs Are Everywhere
Value of Great API’s
• Is a Product
• Help Grow a Eco-System of employees, customers
and Partners
• Evolve in a way that are mutually beneficial
• Encourage Adoption
• Ease Of Use
• Great APIs aren’t difficult to develop
– if you design for your users and the business processes
– if you make it easy for developers to find and consume
your API, and
– you actively manage your API developer community as
an extension of your business.
Pitfalls of a mediocre APIs
• Doesn’t engage Stake-holders
• limited adoption by developers and ultimately, a
failure to meet business objectives
• Starts with implementation first
• Design of API is dictated by the constraints of
internal systems or processes.
• Too often APIs are modeled after the design of the
backend services or applications they expose
instead of the use case they fulfill. This results in
poor performance of the client application, poor
user experience, and ultimately, poor adoption.
THANK YOU
Q & A

More Related Content

What's hot (17)

PPTX
Mule api management
Bhanu Chandra Nalleboyina
 
PDF
OpenAPI 3.0, And What It Means for the Future of Swagger
SmartBear
 
PPTX
API-first development
Vasco Veloso
 
PDF
OpenAPI Spec at Google (Open API Initiative Meetup on 2016-09-15)
Open API Initiative (OAI)
 
PDF
Design First API's with RAML and SoapUI
Daniel Feist
 
PPTX
Making Sense of Hypermedia APIs – Hype or Reality?
Akana
 
PDF
Evaluating Recommended Applications
rsse2008
 
PPTX
Why API? - Business of APIs Conference
Daniel Jacobson
 
PDF
Why your APIs should fly first class
LibbySchulze
 
PDF
KPIs for APIs (and how API Calls are the new Web Hits, and you may be measuri...
John Musser
 
PPTX
Huge: Running an API at Scale
Apigee | Google Cloud
 
PPTX
How to define an api
Alexandru Chica
 
PPTX
A Tasty deep-dive into Open API Specification Links
Tony Tam
 
PDF
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret
apidays
 
PPT
API 101 - Understanding APIs
3scale
 
PDF
Why vREST?
vrest_io
 
PDF
I Love APIs 2015: Continuous Integration the Virtuous Cycle
Apigee | Google Cloud
 
Mule api management
Bhanu Chandra Nalleboyina
 
OpenAPI 3.0, And What It Means for the Future of Swagger
SmartBear
 
API-first development
Vasco Veloso
 
OpenAPI Spec at Google (Open API Initiative Meetup on 2016-09-15)
Open API Initiative (OAI)
 
Design First API's with RAML and SoapUI
Daniel Feist
 
Making Sense of Hypermedia APIs – Hype or Reality?
Akana
 
Evaluating Recommended Applications
rsse2008
 
Why API? - Business of APIs Conference
Daniel Jacobson
 
Why your APIs should fly first class
LibbySchulze
 
KPIs for APIs (and how API Calls are the new Web Hits, and you may be measuri...
John Musser
 
Huge: Running an API at Scale
Apigee | Google Cloud
 
How to define an api
Alexandru Chica
 
A Tasty deep-dive into Open API Specification Links
Tony Tam
 
apidays LIVE Paris - The Augmented API Design Reviewer by Arnaud Lauret
apidays
 
API 101 - Understanding APIs
3scale
 
Why vREST?
vrest_io
 
I Love APIs 2015: Continuous Integration the Virtuous Cycle
Apigee | Google Cloud
 

Viewers also liked (20)

PPTX
Water Master Plan Update
City of College Station
 
PDF
05 Conflict Management Strategies
Roberto de Paula Lico Junior
 
DOCX
class_desriptions
Isaac Long
 
PPT
Resumen Curso Elisava
Fernando de la Rosa Herrero
 
PPT
ProspectusPresentationPrinterFriendly
martijnetje
 
DOCX
Clonación cell stem
Nicolas Adolfo Coria Mendez
 
PDF
Advantages In Registration Of Llp In India
Startupwala
 
PPT
Nfais Presentation20080226 F
rotciv
 
PDF
Flyer by Angela's group
Kolej Tun Datu Tuanku Hj Bujang
 
PPTX
บริการต่างๆบนอินเตอร์เน็ต.
na12890
 
PDF
Procedure in incorporation of llp in nagpur
Bala Nadar
 
PPT
5 testimonianze
rinaldi6109
 
DOCX
Murad camarad wysinger c.d.pt.1 html files.doc
Aztanahmian
 
PPTX
Tema 14 lengua
papanatounianos
 
PDF
NLP approach for medical translation task
Anastasiia Kornilova
 
PPTX
Presentation on switchgear
Shubham Nagarale
 
PDF
Doctor of philosophy updated 2014
Adhy Ramones
 
PPTX
How to Use Algorithms to Scale Digital Business
Teradata
 
PDF
Query Understanding: A Manifesto
Daniel Tunkelang
 
PPTX
La salud
papanatounianos
 
Water Master Plan Update
City of College Station
 
05 Conflict Management Strategies
Roberto de Paula Lico Junior
 
class_desriptions
Isaac Long
 
Resumen Curso Elisava
Fernando de la Rosa Herrero
 
ProspectusPresentationPrinterFriendly
martijnetje
 
Clonación cell stem
Nicolas Adolfo Coria Mendez
 
Advantages In Registration Of Llp In India
Startupwala
 
Nfais Presentation20080226 F
rotciv
 
Flyer by Angela's group
Kolej Tun Datu Tuanku Hj Bujang
 
บริการต่างๆบนอินเตอร์เน็ต.
na12890
 
Procedure in incorporation of llp in nagpur
Bala Nadar
 
5 testimonianze
rinaldi6109
 
Murad camarad wysinger c.d.pt.1 html files.doc
Aztanahmian
 
Tema 14 lengua
papanatounianos
 
NLP approach for medical translation task
Anastasiia Kornilova
 
Presentation on switchgear
Shubham Nagarale
 
Doctor of philosophy updated 2014
Adhy Ramones
 
How to Use Algorithms to Scale Digital Business
Teradata
 
Query Understanding: A Manifesto
Daniel Tunkelang
 
La salud
papanatounianos
 
Ad

Similar to How to design effective APIs (20)

PPT
Effective API Design
Bansilal Haudakari
 
PDF
Recipes for API Ninjas
Nordic APIs
 
PPTX
Practical Application of API-First in microservices development
Chavdar Baikov
 
PPTX
Patterns for automating API delivery. API conference
ssuser9e7c64
 
PDF
Dependency Down, Flexibility Up – The Benefits of API-First Development
Nordic APIs
 
PDF
Extend soa with api management Sangam18
Vinay Kumar
 
PDF
Api manager
chaitanya581
 
PDF
Service api design validation & collaboration
Uchit Vyas ☁
 
PPTX
apidays LIVE New York 2021 - Service API design validation by Uchit Vyas, KPMG
apidays
 
PPTX
Extend soa with api management spoug- Madrid
Vinay Kumar
 
PPTX
apidays New York 2025 - Two tales of API Change Management by Eric Koleda (Coda)
apidays
 
PDF
How to Design a Good API and Why it Matters.pdf
SimranjyotSuri
 
PPTX
Lessons learned on the Azure API Stewardship Journey.pptx
apidays
 
PDF
API Management Building Blocks and Business value
WSO2
 
PDF
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays
 
PDF
Extend soa with api management Doag18
Vinay Kumar
 
PPTX
Building a REST API for Longevity
MuleSoft
 
PDF
Designing your API Server for mobile apps
Mugunth Kumar
 
PPTX
API Strategy Introduction
Doug Gregory
 
PPTX
Pain Points In API Development? They’re Everywhere
Nordic APIs
 
Effective API Design
Bansilal Haudakari
 
Recipes for API Ninjas
Nordic APIs
 
Practical Application of API-First in microservices development
Chavdar Baikov
 
Patterns for automating API delivery. API conference
ssuser9e7c64
 
Dependency Down, Flexibility Up – The Benefits of API-First Development
Nordic APIs
 
Extend soa with api management Sangam18
Vinay Kumar
 
Api manager
chaitanya581
 
Service api design validation & collaboration
Uchit Vyas ☁
 
apidays LIVE New York 2021 - Service API design validation by Uchit Vyas, KPMG
apidays
 
Extend soa with api management spoug- Madrid
Vinay Kumar
 
apidays New York 2025 - Two tales of API Change Management by Eric Koleda (Coda)
apidays
 
How to Design a Good API and Why it Matters.pdf
SimranjyotSuri
 
Lessons learned on the Azure API Stewardship Journey.pptx
apidays
 
API Management Building Blocks and Business value
WSO2
 
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays
 
Extend soa with api management Doag18
Vinay Kumar
 
Building a REST API for Longevity
MuleSoft
 
Designing your API Server for mobile apps
Mugunth Kumar
 
API Strategy Introduction
Doug Gregory
 
Pain Points In API Development? They’re Everywhere
Nordic APIs
 
Ad

Recently uploaded (20)

PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PPTX
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
PDF
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PPTX
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PPTX
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
Code and No-Code Journeys: The Maintenance Shortcut
Applitools
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
MiniTool Power Data Recovery 8.8 With Crack New Latest 2025
bashirkhan333g
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
UITP Summit Meep Pitch may 2025 MaaS Rebooted
campoamor1
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
prodad heroglyph crack 2.0.214.2 Full Free Download
cracked shares
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
iaas vs paas vs saas :choosing your cloud strategy
CloudlayaTechnology
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Code and No-Code Journeys: The Maintenance Shortcut
Applitools
 

How to design effective APIs

  • 2. API’s Are For the Developers, By The Developers And Of the Developers - Bansi Haudakari
  • 3. Who Am I? • An API Developer • An API Consumer • An API Designer • A Seasoned JAVA Programmer who has been consuming JAVA API’s since JDK 1.0 And Other Open Source APIs For Software Development
  • 4. Agenda • What is an API? • Driving factors Of an API • Principles of Effective API Design • API Design Guidelines • API Design In Action • Value Of Great APIs • Pitfalls of mediocre APIs
  • 5. What is an API? Application Programming Interface provides a way for developers to interact with and consume a service.
  • 6. Analogy: Electrical Sockets • APIs are gateways between Services and Consumers, providing consumers access to services through various interfaces Example: Service : Electricity AND Consumer : Plug • Our laptops, consumes electricity through a socket. Through its own “API,” a USB socket, it can provide that same electricity service to charge other devices.
  • 7. Driving Factors • Design of CHM • Business Agility : Business Logic is exposed thru APIs thereby enabling customers to focus on innovations • API Economy : Businesses are developing “API products” as new sources of revenue. Expedia generates over $2 billion thru data made available through their API • Internet of things: The number of things that can be connected is growing fast; everything from your coffee pot to your thermostat to your car can now be accessed thru APIs
  • 8. Principle 1 : Design First API • With Design-First approach, focus is on well-defined API spec’s instead of implementation concerns.
  • 9. • With an Design-First API approach, rather than implementing an application and then building API on top of it, first create the interface and then put the back-end logic into place - whether it be cloud-based or on-premise. • An optimal API design enables applications developers to easily understand the purpose and functionality of the API. • It also allows organizations to focus on getting API design right before investing in back-end implementation,
  • 10. • The best way to design an API that developers want to use is to iteratively define the structure of the API in an expressive manner and get feedback from developers on its usability and functionality • As the API is designed, application developers can interact with it and test its behavior, thanks to an integrated mocking service that returns the values a call to the live API would produce.
  • 11. • There is no such thing as a one-size-fits-all API • An API should be optimized to fulfill a specific business request in a specific context. • Optimize API for a specific use case e.g. – coarse or fine-grained – constraints e.g. network trips, latency and data size so API should be designed to limit backend calls and minimize the size of data returned
  • 12. API Design Guidelines • Know the requirements • Write use cases before you write any other code • Look for similar APIs in the same library • Define the API before you implement it otherwise it embodies the evils of implementation-driven APIs i.e. don’t let implementation considerations leak into the API, apart in exceptional cases
  • 13. API Design Guidelines • Consider the perspective of the caller • Make sure each method does only one thing • Make all method calls atomic • Limit the number of Mutator methods i.e. set/get methods • Favor generic methods over a set of overloaded methods • Avoid long-running methods • Avoid forcing callers to write loops for basic scenarios
  • 14. API Design Guidelines • Avoid “option” parameters to modify behavior • Avoid non-reentrant methods • Do not strengthen the precondition of an already released API method • Do not weaken the post condition of an already released API method • Do not add new methods to released interfaces • Do not add a new overload to a released API • Favor interfaces over concrete classes as return types • Favor empty collections to null return values • Consider making defensive copies of mutable parameters • Consider storing weak object references internally • Avoid parameter types exposing implementation details
  • 15. API Design Guidelines • Avoid returning references to mutable internal  objects • Consider a builder when faced with many  constructor parameters • Consider returning immutable collections from  a getter • Consider read-only properties •  Document method preconditions •  Document the performance characteristics of  the algorithm implemented
  • 16. Measure API Design • Conceptual Complexity Measurement : – double digit : use case is simple ; – single digit : complex ; – negative number : time to re-design – In your code, Count the number of name constructs used in API • try {  AuthenticationProvider20 provider = new LocalAuthenticationProvider19(); SearchCriteria18 criteria = new SearchCriteria17(EntityName16.USER15); criteria.addPropertyToFetch14(PropertyName13.COMMON_NAME12); …. while(iterator.hasNext()4){ Profile3 profile = iterator.next()2; Property1 commonName = profile.getProperty0(PropertyName.COMMON_NAME); Property phone = profile.getProperty(PropertyName.PHONE); System.out.println(commonName.getValue()-1, “ ”, phone.getValue()); } } catch(AuthenticationProviderException-2 e) { }
  • 17. API Design In Action Before After Design Rule public long[] getAllMessages() throws MailboxException; public abstract SortedSet<T> readAllMessageHeaders( ) throws RemoteException, MailboxException; Favor collections over arrays as parameters and return values Ensure no boilerplate code is needed to combine method calls Reserve “get”, “set” and “is” for JavaBeans methods accessing local fields Throw checked exceptions only for recoverable errors
  • 18. API Design In Action Before After Design Rule public void markRead(boolean read, long[] ids) throws MailboxException; public abstract void markRead(Collection<T> headers) throws NullPointerException, RemoteException, MailboxException; Make all method calls atomic  Avoid Boolean parameters Ensure no boilerplate code is needed to combine method calls Consider generic methods Consider method pairs, where the effect of one is reversed by the other Favor generic collections over raw (untyped) collections Throw NullPointerException to indicate a prohibited null parameter value  Favor standard Java exceptions over custom exceptions
  • 19. Principle 2 – Runtime API • Once an API is designed, created and its back- end implemented, it’s time to  find the right  run-time as it affects How successful your API  strategy will be in terms of service, liability,  scale and ability to meet future needs. • Hybrid support: As more and more businesses  are moving to the cloud, so it is important to  find runtime that allows to deploy applications  both in the cloud as well as on-premise without  having to modify anything.
  • 20. • Scalability, reliability, availability: These “-ilities”,  along with performance, are crucial when  searching for a solid API runtime. The last thing  you want is an unstable runtime that crashes or  experiences outages. Choosing the right  enterprise grade technology for your API runtime  is crucial to the success of your API. • Strong Orchestration: A successful runtime should  provide strong orchestration and orchestration  capabilities. The ability to carry out complex back- end orchestration plays a key role in translation  between the API layer and back-end  implementation.
  • 21. Principle 3 – API Design Contract • API publishers should offer a way to easily  create well-defined policies and contracts and  associate them with the right APIs and  consumers.  • API Contracts are crucial for enforcing security  and managing SLAs with API consumers. • In addition, publish API version which helps in  lifecycle management and allows API publishers  to assess the impact of retiring a version.  Example REST API’s
  • 22. Principle 4 - Monitor API Usage • The ability to monitor API usage over a period of time and understand usage patterns from both technical and business perspectives is valuable as it helps business owners and technical teams better understand their users and ultimately create a better service. • You need to see how consumers are using it i.e. which parts of your service are being used. • With metrics for both overall usage and per consumer usage, businesses can closely monitor API activity and engagement.
  • 23. Principle 5 - Continuous Improvement • The ability to re-factor your APIs by iterating through habits 1-6 multiple times allows you to optimize your API over time to improve consumer experience and productivity. • API is not a static entity – as new use cases are identified and use of your API expands, enhancements and fixes are inevitable.
  • 24. Principle 6 -Socialize Your APIs • Create a developer portal to establish a community around your API is important to its success. By making it easy for users to follow your API, download documentation and ask questions, API publishers can engage with API consumers on an ongoing basis. • Example create a developer portal for company- wide REST services and document it using Swagger
  • 26. Value of Great API’s • Is a Product • Help Grow a Eco-System of employees, customers and Partners • Evolve in a way that are mutually beneficial • Encourage Adoption • Ease Of Use • Great APIs aren’t difficult to develop – if you design for your users and the business processes – if you make it easy for developers to find and consume your API, and – you actively manage your API developer community as an extension of your business.
  • 27. Pitfalls of a mediocre APIs • Doesn’t engage Stake-holders • limited adoption by developers and ultimately, a failure to meet business objectives • Starts with implementation first • Design of API is dictated by the constraints of internal systems or processes. • Too often APIs are modeled after the design of the backend services or applications they expose instead of the use case they fulfill. This results in poor performance of the client application, poor user experience, and ultimately, poor adoption.

Editor's Notes

  • #20: The ability to develop applications once and deploy them in the cloud or on-premise provides a host of possibilities without complexity