Introduction To APIs
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.
Restrictions of using APIs: When an API is made its not really released as a software for download and it has some policies governing its use or restricting its use to everyone, usually there are three main type of policies governing the APIs, those are:
- Private: These APIs are only made for a single person or entity (like a company who has spend the resources to made it or bought it).
- Partner: Just like the name it gives the authority to use APIs to some partners of entity that own API for their private use.
- Public: You should be aware of them cause you can only find these API in market for your own use if you don’t own specific API access from some entity that owns private these API for their private use. Some example of Public APIs are ‘Windows API’ by Microsoft for more public APIs you can visit this Github repository-> https://github.com/public-apis/public-apis.
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.