API Fundamentals
/Intermediate
Types of APIs
Definition
Categorizing APIs based on their access permissions (Public, Private, Partner) and their architectural styles (REST, GraphQL, SOAP, gRPC).
Explain Like I'm New
Not all APIs are meant for everyone. A 'Private' API is only used by your own company's apps. A 'Public' API is open for anyone in the world to use (like the Pokemon API). A 'Partner' API is only for specific companies you sign contracts with.
Real World Example
Twitter has a Private API (used by the official Twitter iPhone app), a Partner API (used by Apple to integrate tweets into iOS), and a Public API (used by random college students building sentiment analysis bots).
Common Use Cases
- •System Architecture
- •Security scoping
Interactive Example
// 1. Web API (Over the Internet via HTTP) fetch('https://api.github.com/users/octocat'); // 2. Browser API (Built into Google Chrome) navigator.geolocation.getCurrentPosition((pos) => console.log(pos)); // 3. Library API (Using a third-party code library locally) // The 'format' function IS the API of the date-fns library! import { format } from 'date-fns'; format(new Date(), 'yyyy-MM-dd');
Interview Questions
basic
- What is a Public API (also known as an Open API)?
intermediate
- What is the difference between a Web API and a Library/OS API?