What is the PSTN?

An API, or application programming interface, is a set of definitions and protocols that provides an easy, standard way for two applications to communicate with each other. A communication API provides those services for communications channels, such as voice, SMS/MMS, chat, or video.

APIs follow a client-server model. An application can call an API as a client, and may ask for data from or send data to a server. The server receives the request from the API, interprets it, performs the necessary actions, and sends data back, or just a confirmation or status message if that’s all that’s necessary. The client application can then determine how to act; it might display the information it received or move on to another task.

APIs have been around for decades. They were first used to let two applications running on the same computer exchange data more easily. In today’s cloud computing environment, the client and server are usually on separate networks connected to the internet.

Nowadays most APIs that communicate over the internet use a software architecture called representational state transfer (REST). These RESTful APIs use operations such as GET, PUT, and DELETE to exchange data over HTTP. Client requests look like URLs that you might see in a web browser, but they return responses with data and status information in a standard format — usually JSON (JavaScript Object Notation) or XML (Extensible Markup Language).

Example: how an API sends and receives data

Here’s an example of how an API works. Suppose you’re a software developer writing a program to send out text messages, and you want to find out whether a phone number is mobile or landline, since landline numbers (typically) can’t receive texts. In this case, the server includes a list of all the phone numbers it knows about, plus information about that phone number — the country it’s associated with, which carrier owns it, and whether it’s assigned to a customer, among other things. The company that hosts the data publishes an API with standard operators that let anyone query the database using a specific syntax. The call might look something like this.

https://lookup.phonebankinfo.com/Number/+12025551234?type=carrier

When the server receives a query, it sends back data in a standard documented format, which might look like this JSON example.

{
 "api_id": "e4a25a0a-a19f-4ff6-b8b5-1841bea253f6",
 "phone_number": "+2025551234",
 "country": {
  "name": "United States",
  "iso2": "US"
 },
 "carrier": {
  "name": "Verizon",
  "type": "fixed"
 }
}

The program that called the API can now look at the type field, determine that it’s not a mobile number, and forgo creating a message to send to that number.

Built-in security

The example above is simplified, and leaves out a core component of APIs — security. To use all but a few public APIs, you must identify yourself and show that you have authorization to access or modify the resources you want to work with. Every call to an API requires some kind of account ID plus a security token that functions like a password for the call. Data exchanged by APIs is encrypted to make it inaccessible to any people or programs that lack the proper credentials.

Benefits of APIs

The use of APIs benefits both software vendors and their customers.

From the vendor’s point of view, APIs make it easy for other applications to use their services and their data. Vendors can stick to improving their core functionality and take advantage of adjunct subsystems that another vendor offers via APIs. Consider how many applications might need map or weather information; if another organization makes that information available via APIs, developers don’t have to duplicate their work.

From a developers’ point of view, using APIs increases development speed and efficiency. Rather than having to write new functions to get the data they need, they can call existing APIs. That also makes their code easier to maintain over time