API Definition
What is an Application Programming Interface (API)?
When browsing the Internet, most of us perform our interactions with websites via web applications. A web application provides a graphical user interface (GUI) that we can see and click through, making them human-friendly.
However, this isn’t the only way to interact with many organizations’ online presences. An application programming interface (API) is designed to allow software to more easily use online resources. Instead of interacting with a visual GUI, APIs allow programs to call certain functions and receive information back in a format that is more comprehensible and usable for them.
While web applications make up the visible part of the Internet, APIs are what make it work behind the scenes. Many organizations have APIs — both private and public — designed to allow other applications to access and build on their data or services.
How Does an API Work?
When you browse to a website, you send a request to the web server for a particular webpage. The server would then respond with data formatted using HTML that your browser knows how to interpret and render into the pages that you see on your screen.
With an API, the owner of the website will have certain functions exposed to potential users. An application will send a request that executes one of those functions. After running the requested code, the API will send back the resulting data formatted using JSON, XML, or another computer-friendly format.
This web application and web API may have the exact same functionality. In fact, the web application may even call the API function behind the scenes. However, the application works to make the process human-friendly, while APIs are designed to be used by machines.
Types of APIs
APIs are designed to make it easy for software to communicate with one another. For this reason, there are standards that describe how APIs should work. While the exact functions that an API exposes depend on the purpose of the API (and should be described in the API documentation), the process for making requests and the formats used to return data should be standardized.
A few different API standards exist. Some of the most common and widely used include:
- Representational State Transfer (REST): REST APIs are lightweight, stateless APIs, meaning that a request needs to contain all of the data that the server will need to process it. They use HTTP methods to perform API requests and most often send responses in the JSON format.
- Simple Object Access Protocol (SOAP): SOAP is an XML-based API protocol. It is standards-based using the Web Services Description Language (WSDL) and WS-Security to define operations, structure, and integrated security.
- GraphQL: Developed by Facebook, GraphQL is designed to be more efficient by allowing the client to define the structure of the response. This helps to ensure that the client only receives the data that it wants and needs.
- gRPC: gRPC was developed by Google and has wide programming language support and advanced features such as load balancing. It uses Protocol Buffers to define interfaces and uses binary serialization as an efficient alternative to JSON or XML for organizing data in responses.
Conclusion
APIs are a vital part of the modern Internet and digital services. Some companies specialize in creating and maintaining an API that provides valuable data or functionality. APIs are also used to integrate microservices in the cloud, enable communication between IoT devices and cloud servers, and for various other purposes.
APIs may provide similar functionality to a web application, but they aren’t the same thing. As a result, APIs have their own design challenges and security risks that differ from traditional web applications.