Difference between APIs & web services
"All the web services are APIs, but all the APIs are not web services."
"A web service always needs a network for its operation, whereas APIs do not need a network for their operation."
I tried to simplify this with examples and thought to post this
It
is important to keep in mind that the term "API" can apply to a broad
range of interfaces. Let us understand the types of interfaces.
𝐴𝑃𝐼 𝑇𝑦𝑝𝑒𝑠:
A 𝗵𝗮𝗿𝗱𝘄𝗮𝗿𝗲 𝗔𝗣𝗜 is an interface for software to talk to hardware.
Ex: How your phone's camera talks to the operating system.
A 𝘀𝗼𝗳𝘁𝘄𝗮𝗿𝗲 𝗹𝗶𝗯𝗿𝗮𝗿𝘆 𝗔𝗣𝗜 is an interface for directly consuming code from another code base.
Ex: Using methods from a library you import into your project.
A 𝘄𝗲𝗯 𝗔𝗣𝗜 is an interface for communicating across code bases over a network/internet.
Ex: fetching different hotel details from a hotel booking API over the internet.
𝐿𝑒𝑡 𝑢𝑠 𝑢𝑛𝑑𝑒𝑟𝑠𝑡𝑎𝑛𝑑 𝑤𝑖𝑡ℎ 𝑎𝑛𝑜𝑡ℎ𝑒𝑟 𝑒𝑥𝑎𝑚𝑝𝑙𝑒:
Multiple API types may be used to achieve a simple task. For example, uploading a photo to Instagram makes use of various APIs:
1. Hardware API for the app to talk to your camera
2. Software library API for the image to be processed with filters
3. Web API for sending your image to Instagram's servers so your friends can like it
𝐴𝑐𝑐𝑒𝑠𝑠𝑖𝑏𝑖𝑙𝑖𝑡𝑦 𝑜𝑓 𝑡ℎ𝑒 𝐴𝑃𝐼:
APIs also vary in the scope of who can access them:
𝗢𝗽𝗲𝗻 𝗔𝗣𝗜𝘀 are entirely free and entirely open to the public. They require no authorization to access or retrieve data.
Example: Google API, Weather API
𝗣𝘂𝗯𝗹𝗶𝗰 𝗔𝗣𝗜𝘀 are consumed by anyone who discovers the API
Example: The Hunter API, which retrieves and verifies professional email addresses, is one example of a Public API.
𝗣𝗿𝗶𝘃𝗮𝘁𝗲 𝗔𝗣𝗜𝘀, also called internal APIs, are intended solely for internal use within a company or organization.
Example: Some people in a particular organization can access it with valid authorization.
𝗣𝗮𝗿𝘁𝗻𝗲𝗿 𝗔𝗣𝗜𝘀 are consumed between one or more organizations that have an established relationship
Example: The Airbnb API is another example of a popular partner API, Payment Gateway APIs
Post a Comment