There are many types of APIs. We sometimes organize them into two broad categories: web APIs and native library APIs.
Web APIs, also known as HTTP APIs or web services, are a class of APIs that communicate and exchange information over the internet using the HTTP protocol. Web APIs are typically used for connecting web applications and services. For example, a web developer can use the Twitter API to add some Twitter functionalities, like posting tweets and reading timelines, to his website.
With Web APIs, it doesn't matter what language you use because requests and responses are made through a common web protocol — HTTP. REST (representational state transfer ) and SOAP (simple object access protocol) are the most common types of web API.
Native Library APIs, a.k.a. system-level APIs or library APIs, are toolkits (called code libraries) developers use to extend the capabilities of their apps or to access some useful functions of the operating system or software development framework they’re working with.
Native Library APIs provide a way for apps to tap into the native capabilities of the system they’re running on. For example, a mobile app developer may use the Andriod API, which is a set of tools for building Android apps, to add features like text messaging and GPS to the app she’s building. These APIs are typically written in languages like C or C++ and are specific to the platform they are designed for.
How are web APIs and native-library APIs different?
Web APIs enable communication between web-based services using standard internet protocols. Native Library APIs provide access to system-level functionality for applications built on a specific platform.
While Web APIs deal with communication and data exchange over the internet, Native Library APIs deal with the resources and capabilities of the system on which an app is running.
Native Library APIs are typically platform- and language-specific. For example, the Windows API (Win23 API) is a platform for building native C/C++ Windows applications (note the language and platform specification). It can’t be used for building, say, a macOS application. You’ll need the Cocoa framework for that.
But web APIs, on the other hand, are language- and platform-agnostic: it doesn’t matter whether you’re writing in Python or Java or C — from a Mac or Windows or Linux OS — you can send a request to the Open Weather Map API and get a response.