effective api design

Download Effective API Design

Post on 15-Jun-2015




0 download

Embed Size (px)


Effective API Design


  • 1. Effective API DesignBansi Haudakari

2. APIs AreFor the Developers,By The DevelopersAndOf the Developers- Bansi Haudakari 3. Who Am I? An API Developer An API Consumer An API Designer A Seasoned JAVA Programmerwho has been consuming JAVAAPIs since JDK 1.0 And OtherOpen Source APIs For SoftwareDevelopment 4. Agenda What is an API? Driving factors Of an API Principles of Effective API Design Value Of Great APIs Pitfalls of mediocre APIs Craft APIs that Developers Love 5. What is an API?Application Programming Interface provides away for developers to interact with and consume aservice. 6. Analogy: Electrical Sockets APIs are gateways between Services and Consumers, providingconsumers access to services through various interfacesExample: Service : Electricity AND Consumer : Plug Our laptops, consumes electricity through a socket. Through its ownAPI, a USB socket, it can provide that same electricity service tocharge other devices. 7. Driving Factors Business Agility : Business Logic is exposed thruAPIs thereby enabling customers to focus oninnovations API Economy : Businesses are developing APIproducts as new sources of revenue. Expediagenerates over $2 billion thru data madeavailable through their API Internet of things: The number of things thatcan be connected is growing fast; everythingfrom your coffee pot to your thermostat toyour car can now be accessed thru APIs 8. Principle 1 : Design First API With Design-First approach, focus is onwell-defined API specs instead ofimplementation concerns. 9. With an Design-First API approach, ratherthan implementing an application and thenbuilding API on top of it, first create theinterface and then put the back-end logicinto place - whether it be cloud-based oron-premise. An optimal API design enables applicationsdevelopers to easily understand thepurpose and functionality of the API. It also allows organizations to focus ongetting API design right before investing inback-end implementation, 10. The best way to design an API that developerswant to use is to iteratively define thestructure of the API in an expressive mannerand get feedback from developers on itsusability and functionality As the API is designed, application developerscan interact with it and test its behavior,thanks to an integrated mocking service thatreturns the values a call to the live API wouldproduce. 11. There is no such thing as a one-size-fits-all API An API should be optimized to fulfill a specificbusiness 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 datasize so API should be designed to limit backendcalls and minimize the size of data returned 12. Principle 2 Runtime API Once an API is designed, created and its back-endimplemented, its time to find the rightrun-time as it affects How successful your APIstrategy will be in terms of service, liability,scale and ability to meet future needs. Hybrid support: As more and more businessesare moving to the cloud, so it is important tofind runtime that allows to deploy applicationsboth in the cloud as well as on-premise withouthaving to modify anything. 13. Scalability, reliability, availability: These -ilities,along with performance, are crucial whensearching for a solid API runtime. The last thingyou want is an unstable runtime that crashes orexperiences outages. Choosing the rightenterprise grade technology for your API runtimeis crucial to the success of your API. Strong Orchestration: A successful runtime shouldprovide strong orchestration and orchestrationcapabilities. The ability to carry out complex back-endorchestration plays a key role in translationbetween the API layer and back-endimplementation. 14. Principle 3 API Design Contract API publishers should offer a way to easilycreate well-defined policies and contracts andassociate them with the right APIs andconsumers. API Contracts are crucial for enforcing securityand managing SLAs with API consumers. In addition, publish API version which helps inlifecycle management and allows API publishersto assess the impact of retiring a version.Example REST APIs 15. Principle 4 - Monitor API Usage The ability to monitor API usage over a period oftime and understand usage patterns from bothtechnical and business perspectives is valuable asit helps business owners and technical teamsbetter understand their users and ultimatelycreate 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 perconsumer usage, businesses can closely monitorAPI activity and engagement. 16. Principle 5 - Continuous Improvement The ability to re-factor your APIs by iteratingthrough habits 1-6 multiple times allows you tooptimize your API over time to improveconsumer experience and productivity. API is not a static entity as new use cases areidentified and use of your API expands,enhancements and fixes are inevitable. 17. Principle 6 -Socialize Your APIs Create a developer portal to establish acommunity around your API is important to itssuccess. By making it easy for users to followyour API, download documentation and askquestions, API publishers can engage with APIconsumers on an ongoing basis. Example create a developer portal for company-wideREST services and document it usingSwagger 18. APIs delivers an end-to-end solution to designAPIs that developers will love; easily connectthem with backend services; run them in asecure, scalable environment; and managethem throughout their lifecycle. 19. APIs Are Everywhere 20. Value of Great APIs Is a Product Help Grow a Eco-System of employees, customersand Partners Evolve in a way that are mutually beneficial Encourage Adoption Ease Of Use Great APIs arent difficult to develop if you design for your users and the business processes if you make it easy for developers to find and consumeyour API, and you actively manage your API developer community asan extension of your business. 21. Pitfalls of a mediocre APIs Doesnt engage Stake-holders limited adoption by developers and ultimately, afailure to meet business objectives Starts with implementation first Design of API is dictated by the constraints ofinternal systems or processes. Too often APIs are modeled after the design of thebackend services or applications they exposeinstead of the use case they fulfill. This results inpoor performance of the client application, pooruser experience, and ultimately, poor adoption.