Each time you use a social media app, send an instant message, or check the weather on your phone, you are using an API.
API is an acronym for Application Programming Interface. It is software that sits between applications and programmatically allows them to “talk” to each other. A bridge of sorts. APIs’ are critical, standardized components for integrating applications and data.
There are lots of popular APIs from companies you know and love for adding weather forecasts, maps, and directions, taking payments and enhancing security to custom websites. Additionally, developers need APIs for building custom databases for doing things like analyzing social media feeds.
Businesses like APIs. They save time and money.
Over the past two decades the internet spawned several popular APIs now in use, mainly: SOAP, REST, and gRPC.
SOAP an acronym for Simple Object Access Protocol is a messaging protocol developed by Microsoft in the late 1990s-early 2000s. A messaging protocol is a set of rules and a defined data format for sending “messages” between applications.
SOAP uses an XML data format. If your not familiar, XML or “Extensible Markup Language” is a set of rules or “tagged content” for creating messages. A sample SOAP message that a stock quote app might use would look something like this:
POST /StockQuote HTTP/1.1
Host: www.stockquoteserver.com
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
SOAPAction: "Some-URI"
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<m:GetLastTradePrice
xmlns:m="Some-URI">
<symbol>MSFT</symbol>
</m:GetLastTradePrice>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Most if not all, modern operating systems, and programming languages support XML. It travels easily over the internet from source to destination through firewalls and proxies. SOAP XML messages need the Hypertext Transport Protocol (HTTP) to send XML data between sources and destinations.
SOAP is less "simple" than the name suggests. It can be complex, requires bulky XML data and lots of network bandwidth. Large XML files can be painfully slow to process. Around ten years ago as a response to these issues’ developers started migrating away from SOAP towards REST.
REST or Representational State Transfer (REST) is not a protocol but a software design “style”. It defines an approach for creating web services. As mentioned above, web services allow developers to easily add ready to use, third-party features like weather forecasts, maps, directions, payments, and annoying ads to custom websites.
Compared to SOAP, REST is easier to use. It is light weight and scalable. REST message data, usually in JSON format easily moves across HTTP:
[
{
"id": 13,
"type": "programming",
"setup": "There are 10 types of people in this world...",
"punchline": "Those who understand binary and those who don't"
}
]
REST data is “stateless”. That is a server does not save any data pertaining to the client or source request. The client saves this “state data” on its end. For the most part, REST has become the de facto design pattern for web services.
RPC or remote procedure call is a computer program that runs a process on a remote computer. It is coded as if it were running on the calling or local computer. The approach has been around for over 50 years.
Around ten years ago Google built “Stubby” a single general-purpose RPC to connect the large number of microservices running in Googles’ data centers. In March 2015, Google decided to build the next version of Stubby and make it open source. The result was gRPC, which is now used in organizations outside of Google to power use cases from microservices to the “last mile” of computing like mobile, web, and Internet of Things(IoT). Square, Netflix, Cisco and others now use it.
It depends. Developer and author Kristopher Sandoval agrees. If you need security, high performance in a B2B setting then gRPC may be your ticket. REST is the most popular and still may be best for consumer to business (C2B) apps.
The door to continue using SOAP however is shutting. Microsoft is not supporting SOAP on .Net. If your running SOAP your due for an upgrade. Migrating from SOAP to gRPC is possible. There are some tools out there to help automate the process.
Be Well.
Here are some useful categories to links that will help decipher some of the mysteries of SQL Server and other data technologies