What is an API?

If you've ever wondered how your phone's map app always seems to know where you want to go, it's because of APIs. APIs (Application Programming Interfaces) are a set of definitions and protocols that allow software components to communicate with each other making the connected world possible. 

In other words, they help us make our software talk to each other! In this blog post, we will explain what APIs are and how they can help your business. We'll also give a few real-world examples of how APIs are being used today. So what are you waiting for? Read on to learn more!

To the Point:

Audience: Business Owners, Executives

Summary: API stands for "Application Programming Interface" and is a term used to describe how different software systems communicate with each other. APIs can be built to expose your business services without exposing your logic allowing you to distribute your data to developers openly or behind an authorization or paygate. APIs are used as a common messaging framework extensively in operating systems, software development and mobile apps. APIs can be built and distributed on cloud infrastructure or on a traditional server architecture.

What is an API ?

APIs Application Programming Interface) allow your product or service to communicate with other products and services without requiring knowledge of their implementation. This can help you build apps more quickly and inexpensively. APIs give you flexibility, reduce complexity in design, administration, and use, as well as provide opportunities for innovation when developing new technologies or managing existing ones.

Developers don't need to know how an API is built; all they have to do is use the API's interface to interact with other systems and services. APIs have increased in popularity over the last decade, to the point that many of today's most popular web applications could not exist without them.

The most important aspect of an API is that it can surface business logic results without exposing the underlying logic. So whether you need to create an invoice or lookup historical data, an API allows you to provide users with critical access to business data without letting them in on trade secrets or complicated business logic.

As a developer I utilize APIs extensively to support client apps. For instance, a electrical company needed to warehouse all its product data but it's ERP import solution was bulky and slow. Instead of using a PIM I built a high performance API service and Angular App to facilitate product entry, organization and promotions. In the customer's previous system we had the ability to upload about 15,000 skus in a day can now be done in less than 10 mins. At the end of the day, APIs allow developers to facilitate the transfer and processing of data so that your business can move faster.

What is an API and how do they work

How Do APIs Work?

An application programming interface (API) is a collection of rules that describe how computers and programs communicate with one another. These rules can be defined as a protocol (SOAP APIs) or as an architecture (REST API). APIs often operate as an intermediary layer between an application and a web server, facilitating data transfer across systems.

Here’s how an API works on the web:
  1. The client application, such as Google Maps App or the NYTimes.com, initiates an API request call to retrieve information. This "request" is processed from an application to the web server via the API’s Uniform Resource Identifier (URI) and includes a "request" verb (GET,POST,PUT,DELETE,UPDATE), headers, and sometimes, a request data payload.

  2. After receiving the request, the API service makes a call to the external program, database or web server.

  3. The server sends a "response" to the API with the requested information.

  4. The API transfers the data to the initial requesting application.

The data transfer may vary based on the web service being utilized, but it all takes place via an API. APIs are built for use by a computer or program rather than people.

Many APIs are built inside the software itself to help facilitate development on that platform. For instance, the Chrome web browser has many APIs for interacting with the web page DOM; specifically JavaScript APIs such as document and window.

 

Why Do We Need an API?

API's are needed because they provide a way to interact with back-end systems in an efficient manner. When developing an application, you don't have to worry about all the different ways you can access data or what format that data needs to be in.

An API takes care of all of that for you and provides a standard set of protocols that both applications can use. This makes development much simpler and faster, as well as reduces the amount of code required. It also makes your application more reliable since everything is standardized.

There are many reasons why you might want to build an API for your business:

- To make it easier for developers to create applications that work with your system

- To give third-party developers access to your data or services

- To create a system that is easy to use and can be accessed from anywhere

- To improve performance by caching resources

- To gather analytics on how your data is being used

- To provide a better user experience for your customers or users

SOA vs Microservice Architecture

The two most popular ways to build a system that uses a remote API are service-oriented architecture (SOA) and micro services architectures. SOA is the older approach to a monolithic app; the idea was to develop scalable and standardized software.

SOA was an evolution of monolithic app design where the application will do everything along with a number of functions are provided by different apps whose integration patterns are loosely connected. While SOA has many advantages in the way it can be used for many different tasks in a broader context than an monolithic app, it can be particularly difficult to manage as the application grows in size and users.

Microservice architecture often relies on a RESTful (Representational State Transfer) architecture for standardizing the communication between client and server. Microservices architectures are similar to SOA patterns in their use of specialized, loosely coupled services. But they go even further in breaking down traditional architectures.  Using RESTful APIs allows developers to deliver new features and updates much faster. Each service is discrete and one service can be replaced, enhanced, or dropped without affecting any other service in the architecture.

SOAP vs. REST vs GraphQL for Application Programming Interface Development

As APIs are growing, the protocol specifications have been developed to standardize data exchange between client and service. Simple Object Access Protocol, also called SOAP was the first widely adapted protocol. APIs developed in SOAP rely on XML format and usually send requests via HTTP. SOAP helps developers share information with other software programs that can run on multiple environments.

REST is a network paradigm described by Roy Fielding in a dissertation in 2000. REST is all about a client-server connection, in which server-side data are represented using simple formats. Web APIs that adhere to a REST architectural constraint are called RESTful APIs. REST has fundamental differences with SOAP: it is a protocol while REST is a style architecture.

Further, REST is not tied to XML or HTML as SOAP is. JSON has become popular for payloads transported in RESTful APIs due to its efficiency and readability by humans. When developing and interacting with APIs JSON has become the defacto standard for many companies.

GraphQL (Graph Query Language) is basically RPC with a default procedure providing a query language, a little like SQL. You ask for specific resources and specific fields, and it will return that data in the response. Because GraphQL was designed by Facebook, who had previously created a REST-like API, they are familiar with REST/HTTP API standards.

Many of those existing features were drawn upon as inspiration for GraphQL features or directly incorporated as part of it. A few of the most useful REST ideas were neglected intentionally thus focusing how the architecture should be used.

The main selling point of GraphQL is that it defaults to providing the very smallest response from an API, as you are requesting only the specific bits of data that you want, which minimizes the content download portion of the HTTP request making interactions fast and efficient.

JSON vs. XML

Just as there are different types of APIs, there are also different ways that data can be transmitted between the client and server. One option is JSON (JavaScript Object Notation), which is a lightweight data-interchange format. It is easy for humans to read and write, and it can be parsed by computers very easily. When using JSON, the client sends a request in JSON format and the server responds with a response in JSON format. Modern web APIs almost all utilize JSON to exchange data.

Another option is XML (Extensible Markup Language). XML is heavier than JSON but provides more options for formatting data. When using XML, the client sends a request in XML format and the server responds with a response in XML format.

XML is widely used in RPC (Remote Procedure Calls). RPC is the earliest, simplest form of API interaction. RPC is just a bunch of functions, but in the context of an HTTP API, that entails putting the method in the URL and the arguments in the query string or body. RPC is merely a concept, but that concept has a lot of specifications, all of which have concrete implementations which we will not five into here.

What does an API gateway do?

Modern API (Application Programming Interface) gateways are a system for the management of API resources that sits between clients and the backend service. API gateways provide a single access point for all the APIs used by an enterprise and enforces security, rate limiting, and other policies on behalf of the backend services. API gateways may also cache data to improve performance and manage load on backend systems.

An API gateway is essentially an intermediary layer that sits between your client applications (whether they're internal or external) and the various back-end systems that power them. By centralizing management of your APIs using an API gateway, you can greatly simplify both development and ongoing operations allowing you to release new features and updates faster. Your client connections may also enjoy improved performance and reliability as a result of caching and load balancing implemented by the gateway.

API Management

API management solutions provide a centralized platform for managing all aspects of your API program. This includes the publishing of APIs, managing API keys and authorizations, tracking usage and performance, gathering analytics, and more. API management solutions provide a single point of control for all aspects of your API, making it easier to manage and scale as your program grows. An API gateway is a type of API management tool.

There are many different types of API management solutions on the market today. Choosing the right one for your organization can be a daunting task. The first step is understanding what features you need in order to meet your organization's goals. Here are some things to consider:

- Do you need support for public or private APIs?

- Do you have a lot of external or internal services to centralize?

- What level of security do you require?

- Are you looking for an API gateway that also provides caching and load balancing?

- Do you need to integrate and combine legacy systems?

- Do you have a lot of credentials to store for your current api endpoints?

What is API Security?

APIs provide security by design since they serve as a middleman and enable the abstraction of functionality between two systems - the API endpoint separates the consuming application from the infrastructure providing the service. To minimize security concerns, API calls frequently contain authorization credentials to limit attacks on the server, and an API gateway may restrict access to decrease risk. Additionally, HTTP headers, cookies, or query string parameters provide additional security layers to the data.

For example, consider an API offered by a payment processing service. Customers can enter their card details on the frontend of an application for an ecommerce store. The payment processor doesn’t require access to the user’s bank account; the API creates a unique token for this transaction and includes it in the API call to the server. This ensures a higher level of security against potential hacking threats.

Open Vs Private APIs

Open APIs have publicly available endpoints to use like OAuth APIs from Google. They typically require only a authorization key that can be created when you sign up for the service. So, they are also known as Public APIs.

Private service APIs on the other hand are not available to outside users and are typically locked by an authorization key and by requesting domain or path. These APIs are developed by companies to use in their internal systems.

Remote APIs

Remote API endpoints are designed for interactions with communication devices. Remote means the resources manipulated using API are in a location outside the server requesting the request. Because the most common communications channel is the Internet, API design is mostly built using web standards. Not every remote API is a web API, however you can assume that web APIs are remote. Web API typically uses HTTP to send requests and provides information on the structure of responses. They typically come in XML format or JSON. JSON and XML are preferred, as both provide the efficient solutions.

Is API Documentation Important?

Perhaps the most important part of a public API is the documentation and use examples. When developing an API for a client I often stress just how important and time consuming the documentation stage can be, in fact if you are building a public api for your customers, the api documentation is often the largest cost after development.

By creating organized, comprehensive and well documented examples you can facilitate the adoption of your API service by a broader range of developers. The better your documentation is at explaining how your service can be interacted with the more efficient and faster your clients can integrate your api services.

Sum it Up: What is an API?

APIs connect data together allow the modern world to be connected, without them none of your modern electronics could interact with the software and none of your web apps could show you information. Modern APIs are all around us and help to find exactly the data your app needs to thrill your business partners.

GraphQL and REST apis are primarily what I focus on at Discourse Digital. If you are interested in finding out how an API may be useful for your business please contact me to start the discussion!