#27 4 Reasons Why You Should Use An SDK
The apps we build on Microsoft 365 often communicate with APIs to retrieve and store their data. Whether you use Microsoft Graph, SharePoint, or store your data in Azure, you need to communicate with an API.
When building your apps, you have two choices to connect to an API: you either use its SDK or you build the web requests manually. Using SDKs basically means adding another dependency to your project. A dependency that you need to keep an eye out on and update in case there is any known issue. Over the last few years, we’ve all heard some nightmare stories where a broken dependency would break the whole app. But before you decide, let me give you, what I think, 4 compelling reasons why you should use an SDK.
- Design-time feedback
- Implements auth for you
- Abstracts away API intricacies
- Takes care of handling edge cases and exceptions
When you build your app, would you rather be surprised when your app breaks on runtime or would you prefer to see squiggly lines in your code when something’s not right? Oh, and when the API changes: would you rather again find out about it on runtime, or see what needs to be changed immediately after updating the SDK?
Auth is often one of the hardest parts of connecting to APIs. SDKs abstract the auth flow away often to a single line of code, or maybe two. But that’s it.
Despite us having standards for building APIs, not all APIs follow them. Sometimes it’s out of necessity that they need to be inconsistent or they need to implement something that is a grey area in the standard. Whether it’s a particular use of formatting requests, manipulating request headers, or handling paging, a good SDK will abstract all these intricacies away from you, allowing you to focus on the task at hand rather than building API plumbing.
Communication over HTTP is not flawless. In fact, you should always assume that your call will fail and properly handle exceptions. And if the particular API is under heavy load, it could happen that your request will get throttled. An SDK will implement handling all these exceptions for you.
So the next time you will build your app think about it: do you want to build plumbing or do you want to focus on the added value of your app and use SDK to help you make your app more robust and reliable?
PS. Check out the Microsoft 365 PnP community website to see what SDKs you can use for building apps on Microsoft 365.
Photo by Cesar Carlevarino Aragon on Unsplash