Software Development Kits (SDKs) and APIs (Application Programming Interfaces) may seem unrelated at first glance, but they have an interesting and complex relationship. SDKs contain everything a developer needs to build an application with a system, while APIs establish relationships and expose resources to developers. How might these two work together? This article will describe how SDKs and APIs complement each other and help developers build software every day.
SDKs contain the tools and instructions for developers to build applications within a standardized operating system, environment, or development process. For example, to build Android mobile apps, a developer would get the Android SDK, to build ios mobile apps, the developer would get the ios SDK. An SDK contains a standard set of tools for a specific platform or use case, similar to buying Lego building blocks to build the model depicted on the box.
An API, or Application Programming Interface, is a set of rules that define how computers and applications can communicate with each other. If you recall the old switchboards that operators used to field phone calls to their destinations, APIs are a little like that. A client makes a request to an API at an endpoint which it has access to. The API validates the request and passes the request to the destination server or program. The server sends a response back, first through the API, which then transfers it back to the client.
At the heart of RESTful APIs is the contract between client and server. This contract defines what the API will do and what kind of requests and responses it will issue. If you call the API, you must do so in a way that it understands, and you must be able to accept its responses, also. An example of an API contract can be seen here. You can see the APIs URLs, verbs, HTTP responses, and contract statuses- all the rules of interacting with this API are defined in the contract. For more on contracts, check out the Open API spec.
An SDK may contain APIs, but APIs do not contain SDKs. A developer who wants to develop a new application for a specific platform would be best served with that platform's SDK. If they already have an application that just needs a certain functionality- for example, an IP geolocation feature- an API would serve their needs.
How do SDKs and API relate? Well, consider what service SDKs provide to programmers. SDKs provide the building blocks and tools to construct a software product, and as web developers know, software isn't built in isolation. SDKs allow programmers to communicate with resources via the APIs, drawing in functions as they are needed without having to build everything from scratch. SDK APIs also ensure developers are receiving up-to-date resources and employing them correctly within their environment.
A recent example of SDKs and APIs is the new Android Game Developer Kit, or AGDK. This is a SDK specially tooled for- you guessed it- Android game development. It includes:
The AGDK includes other tools, but you can see in this example what this SDK is all about: encouraging game development in Android by providing developers the tools they might need. In the AGDK documentation there is information on the `GameTextInput` REST API. This API displays the soft keyboard, sets or gets the currently-edited text, and receives notifications when the text is changed, all without the developer having to write a keyboard function from scratch. Actually using this API is outside the scope of this article, but as you've seen, the `GameTextInput` API is called from the SDK if the developer decides its function would solve a problem for their Android application. The API exists only as a contract and interface for the SDK to access resources.
SDKs include APIs in their libraries for added functionality beyond the included development tools, while still keeping developers inside of the development environment. APIs provide functions without developers having to write code from scratch to solve common problems. This helps companies extend their reach with developers, so an SDK is both a technical product and a marketing product, part of the developer experience, or DX. The more developers happily building games in Android, the happier Google will be. Devkits provide API solutions to make developers' lives easier on their platform, which will persuade developers to adopt the technology.