We argued that APIs need SDKs but how do you select the best SDK for an API in your programming language? Can it be done automatically? And what would be the results? Let’s find out.
Finding NPM client libraries (SDKs) for APIs
As a developer when I want to use a Web API in Node.js I would search the NPM catalog for the best client library for accessing that API. The best library may not be called “Foo API SDK” or “Foo API Software Development Kit” but it may be described as a client library or just mentioned that it is a “wrapper” for the API, or provides API capabilities, or it is Foo API binding etc. So many choices and opportunities to miss the best library for the API.
What could we do to help developers select SDK library? We could automate the steps that a developer is doing when searching for the library and provide an easy to use list of libraries next to API description. And that is what we have now in API Harmony. For example see “Software Development Kits” section in Instagram API page
Quality of the search result
Typically there will be more than one NPM library matching API search results. If there is exactly one or no libraries then it is easy - no need to decide which library to show first in the results.
If there are just a few that may be good - we just need to make sure that each library is related to the API. When there are too many results we need to do filtering and ranking to show top N libraries that are related to the API. If no library is found developers may also use one of the REST libraries to access Web API directly - we have described advantages and disadvantages of using SDK versus using REST API directly in separate blog post.
To get the list of libraries we created full text index of NPM skimdb and use it to find all NPM packages that contain name of an API. We experimented with different rankings and currently we are using last month downloads number - it is easy to understand and a good proxy for how popular is the NPM catalog. In the future based on our user feedback we may add more ways to do the ranking, include more metrics (like github project stars etc.), and possibly allow users to look for SDKs across multiple APIs (for example find top SDKs for all “travel” APIs.)
Results: Long Tail
Currently we have processed about 700 APIs and allowed maximum number of 10 SDKs per API (after filtering.) We can show the results by creating the following histogram:
Looking at the results the most interesting or surprising observation is how many APIs have no SDKs. The reason for it is that many Web APIs are simple enough to use that there is no need for a specialized library - for example using HTTP GET with parameters may be enough to query and get data such as Hospital Inpatient Potentially Preventable Readmission (PPR) Rates by Hospital API can be accessed directly using URLs that have query parameters such as discharge_year > 2009.
On the other hand we have some APIs that have 10 or more related client libraries. Those are popular APIs such as Instagram API.
Being able to write code to invoke API in any programming language is important. If systems, such as API Harmony, can help with selecting libraries and providing code samples then developer will be able to create better code faster.
We are going to experiment with improvements to SDKs ranking and how we are gathering APIs and SDKs related metrics to see what works the best for developers. Our intention is to take advantage of big code analysis (applying big data analytics techniques to source code related artifacts) to understand what developers are doing and provide results that increase developers productivity - finding SDKs for APIs is one of the first steps in that direction.
And we would love to hear form our blog readers - how do you search for SDKs? Let us know in comments below.