What is an API?
API is an abbreviation for Application Programming Interface which is a collection of communication protocols and subroutines used by various programs to communicate between them. A programmer can make use of various API tools to make its program easier and simpler. Also, an API facilitates the programmers with an efficient way to develop their software programs.
Thus in simpler terms, an API helps two programs or applications to communicate with each other by providing them with necessary tools and functions. It takes the request from the user and sends it to the service provider and then again sends the result generated from the service provider to the desired user.
Real life example of an API:
Suppose, we are searching for a hotel room on an online website. In this case, you have a vast number of options to choose from and this may include the hotel location, the check-in and check-out dates, price, accommodation details and many more factors. So in order to book the room online, you need to interact with the hotel booking’s website which in further will let you know if there is a room available on that particular date or not and at what price.
Now in the above example, the API is the interface that actually communicates in between. It takes the request of the user to the hotel booking’s website and in turn returns back the most relevant data from the website to the intended user. Thus, we can see from this example how an API works and it has numerous applications in real life from switching on mobile phones to maintaining a large amount of databases from any corner of the world.
There are various kinds of API’s available according to their uses and applications like the Browser API which is created for the web browsers to abstract and to return the data from surroundings or the Third party API’s, for which we have to get the codes from other sites on the web(e.g. Facebook, Twitter).
Types of APIs:
There are three basic forms of API-
- WEB APIs:
A Web API also called as Web Services is an extensively used API over the web and can be easily accessed using the HTTP protocols. A Web API is an open source interface and can be used by a large number of clients through their phones, tablets. or PC’s.
- LOCAL APIs:
In this types of API, the programmers get the local middleware services. TAPI (Telephony Application Programming Interface), .NET are common examples of Local API’s.
- PROGRAM APIs:
It makes a remote program appears to be local by making use of RPC’s (Remote Procedural Calls). SOAP is a well-known example of this type of API.
Few other types of APIs:
- SOAP (SIMPLE OBJECT ACCESS PROTOCOL): It defines messages in XML format used by web applications to communicate with each other.
- REST (Representational State Transfer): It makes use of HTTP to GET, POST, PUT, or DELETE data. It is basically used to take advantage of the existing data.
- JSON-RPC: It use JSON for data transfer and is a light-weight remote procedural call defining few data structure types.
- XML-RPC: It is based on XML and uses HTTP for data transfer. This API is widely used to exchange information between two or more networks.
Above are the various types and forms of API’s extensively used over web networks to exchange information and to enhance communication between them.
Advantages of APIs –
- Efficiency: API produces efficient, quicker and more reliable results than the outputs produced by human beings in an organization.
- Flexible delivery of services: API provides fast and flexible delivery of services according to developers requirements.
- Integration: The best feature of API is that it allows movement of data between various sites and thus enhances integrated user experience.
- Automation: As API makes use of robotic computers rather than humans, it produces better and automated results.
- New functionality: While using API the developers find new tools and functionality for API exchanges.
Disadvantages of APIs –
- Cost: Developing and implementing API is costly at times and requires high maintenance and support from developers.
- Security issues: Using API adds another layer of surface which is then prone to attacks, and hence the security risk problem is common in API’s.
- Top 7 Payment Gateway APIs That Every Developer Must Know
- Exposing ML/DL Models as REST APIs
- HQL | Introduction
- SAP | An Introduction
- p5.js | Introduction
- Introduction to Sniffers
- Introduction of a Router
- Introduction to SAS programming
- Introduction to Web Scraping
- Introduction to WebRTC
- Introduction of Libra
- Robotics | Introduction
- DHTML | Introduction
- Introduction to SQLite
- AA Trees | Set 1 (Introduction)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.