API (Application Programming Interface). An API is a defined set of rules and protocols that lets one software program talk to another. It specifies what requests can be made, how they must be formatted and what responses to expect.
APIs are the invisible connective tissue of modern software - the reason your weather app knows tomorrow's forecast, your payment goes through when you tap your phone at checkout, and you can sign into dozens of websites with a single Google account.
Whether you are a software developer working on integrations, a product manager assessing technical capabilities or a business leader deciding on technology, knowing how APIs work is essential for getting around the digital economy.
What Is an API? The Core Concept
Two software systems communicate through an API or Application Programming Interface, as a defined interface with agreed-upon rules for what requests can be made, how they must be formatted, what responses look like and what error codes mean. This allows a provider (server) and a consumer (client) to trade data without either side having to know how the other works internally and only knowing the shared contract between them.
The Interface Analogy
Understanding APIs comes down to grasping what the word interface means. Two systems interact across a defined boundary that is an interface. Agreed-upon rules govern how each side behaves.
Consider a power outlet. It has a standardized interface: a specific shape, voltage (120V in the United States, 230V in most of Europe), and connection protocol. Any device built to that standard can plug in and draw electricity. The outlet does not need to know whether the device is a lamp, a refrigerator, or a computer.
Whether the electricity comes from a coal plant, a wind farm or a nuclear reactor, the device does not have to know. The interface abstracts away complexity on both sides and lets the two systems work together through a simple, predictable contract.
An API does the same thing for software. It defines:
- What requests can be made - what operations are available to the requesting system
- How requests must be formatted - what data must be included and in what structure
- What responses look like - what the requesting system will receive back
- What error codes mean - what happened when something goes wrong
The system offering the API is called the provider (or server). The system making requests is the consumer (or client). Neither needs to understand the other's internal workings. Both only need to understand the interface - the contract between them.
"Any sufficiently advanced technology is indistinguishable from magic."
Arthur C. Clarke
Through APIs comes the mechanism for delivering that "magic." Behind simple, predictable interfaces lies enormous complexity that APIs hide.
A Brief History
The term "Application Programming Interface" dates to a 1968 paper by Ira W. Cotton and Frank S. Greatorex, though the concept existed earlier in the form of subroutine libraries. Early APIs were primarily local - one program calling functions in another program on the same computer.
A transformative shift came with networked APIs in the late 1990s and early 2000s. As the internet matured, companies began exposing their services over HTTP. This allowed remote systems to interact with them. Salesforce launched one of the first major web APIs in 2000.
Amazon Web Services followed in 2002. eBay, Google Maps, and Flickr released public APIs in 2004-2005, sparking the mashup era in which developers combined data from multiple APIs to create entirely new products.
Postman's State of the API Report through 2023 showed that 89% of developers view APIs as more important to their organizations than they did the year before. Over 40,000 public APIs were reported by RapidAPI in its marketplace. What was once a technical implementation detail has become a basic business strategy.
How a REST API Works
The Dominant Architecture
REST (Representational State Transfer) is the dominant architectural style for web APIs. It was formalized by computer scientist Roy Fielding in his 2000 doctoral dissertation at the University of California, Irvine.
Most public APIs went with REST as the default approach. This happened because of its simplicity and natural alignment with the existing structure of the web, namely HTTP protocols, URLs and standard data formats.
A REST API makes resources available as data entities such as users, products, orders or messages through URLs that are also called endpoints. Every resource gets its own distinct URL and you interact with it using standard HTTP methods:
| HTTP Method | Purpose | Example | Analogy |
|---|---|---|---|
| GET | Retrieve a resource | GET /users/123 | Looking up a contact in a phonebook |
| POST | Create a new resource | POST /orders | Placing a new order at a restaurant |
| PUT | Replace a resource entirely | PUT /users/123 | Rewriting an entire contact card |
| PATCH | Update part of a resource | PATCH /users/123 | Changing just the phone number on a card |
| DELETE | Remove a resource | DELETE /orders/456 | Canceling a restaurant order |
When a client makes a request, it includes any needed data (typically as JSON in the request body) and authentication credentials (typically in the request headers). The server processes the request and returns a response with two critical pieces: an HTTP status code indicating success or failure, and data in the response body.
HTTP Status Codes: The Language of API Responses
Status codes follow a logical numbering system that any developer learns to read intuitively:
2xx - Success: The request was received, understood, and processed.
- 200 OK - Standard success response
- 201 Created - A new resource was successfully created
- 204 No Content - Success, but nothing to return (common for DELETE)
4xx - Client Error: Something was wrong with the request.
- 400 Bad Request - Malformed request (missing required fields, wrong data types)
- 401 Unauthorized - Missing or invalid authentication credentials
- 403 Forbidden - Authenticated but not permitted to perform this action
- 404 Not Found - The requested resource does not exist
- 429 Too Many Requests - Rate limit exceeded
5xx - Server Error: The request was valid, but the server failed to process it.
- 500 Internal Server Error - Something went wrong on the server side
- 502 Bad Gateway - The server received an invalid response from an upstream service
- 503 Service Unavailable - The server is temporarily overloaded or under maintenance
A well-designed REST API is predictable. Anyone who understands HTTP and the URL structure can reason about what is available and how to interact with it.
Predictability is what made REST the universal language of web services and what keeps it as the default choice for most public APIs more than two decades past the date of Fielding's dissertation.
REST vs. GraphQL vs. gRPC: Choosing the Right Architecture
REST is not the only way to build an API. Looking at the other options makes it much clearer what tradeoffs engineers and product teams weigh when they design systems.
GraphQL: The Client-Controlled Query
GraphQL is a query language for APIs developed at Facebook (now Meta) by Lee Byron, Nick Schrock, and Dan Schafer in 2012, open-sourced in 2015. Instead of multiple fixed endpoints, GraphQL exposes a single endpoint. Clients send queries that specify exactly what data they need, and the server returns exactly that - no more, no less.
The REST problem GraphQL solves: Consider a mobile app displaying a user profile. With REST, the app might need three separate requests: one for the user's basic information (/users/123), one for their recent posts (/users/123/posts), and one for their follower count (/users/123/followers).
Far more fields than the app actually needs come back in each response. Two well-known problems result from this.
- Over-fetching. Getting more data back per request than the client needs, which wastes bandwidth as well as processing time.
- Under-fetching. Having to make several requests to gather the data for one screen, which raises latency.
GraphQL solves both by letting the client specify, in a single query, exactly which fields from which related resources it needs. The server returns precisely that data structure and nothing else.
The tradeoffs: GraphQL is more complex to implement and operate than REST. HTTP caching, which works naturally with REST's URL-per-resource model, becomes significantly harder with GraphQL because every query to the single endpoint can request different data.
Tuning performance on the server side gets harder because the server cannot tell ahead of time which combinations of data clients are going to ask for. When an API is simple and its data needs are stable and well understood, REST is usually easier to run and faster.
GraphQL shines for complex, data-rich products with many different clients (web, mobile, third-party integrations) that each have different data needs.
gRPC: The High-Performance Internal Protocol
gRPC is a high-performance Remote Procedure Call framework developed by Google and open-sourced in 2015. Instead of HTTP/JSON, gRPC uses Protocol Buffers (a compact binary serialization format developed by Google) and HTTP/2.
For high-volume, low-latency service-to-service communication, this combination makes gRPC much faster and more bandwidth-efficient than REST.
Where REST sends human-readable JSON text, gRPC sends compact binary data. Where REST requires a new connection for each request-response cycle (in HTTP/1.1), gRPC supports multiplexed streaming over persistent connections (via HTTP/2).
In practice, the speed gap is big. Benchmarks regularly show gRPC handling 5 to 10 times more requests per second than comparable REST APIs while keeping latency much lower.
gRPC is the standard for internal microservice communication at companies like Google, Netflix, Square, and Lyft.
It is less suitable for public-facing APIs because browsers cannot call gRPC natively (requiring a proxy layer) and because clients need the Protocol Buffer definition files that describe the API contract - a barrier for external developers.
| Feature | REST | GraphQL | gRPC |
|---|---|---|---|
| Data format | JSON (human-readable) | JSON (human-readable) | Protocol Buffers (binary) |
| Multiple resources per request | No (requires multiple calls) | Yes (single query) | Yes (streaming) |
| HTTP caching | Excellent (native) | Complex (single endpoint) | Minimal |
| Browser support | Full | Full | Requires proxy |
| Typical use case | Public APIs, CRUD services | Complex frontends, mobile apps | Internal microservices |
| Learning curve | Low | Medium | High |
| Performance | Good | Good | Excellent |
API Authentication and Security
APIs are not typically open to the entire internet. They require authentication (proof of who you are) and often authorization (confirmation that you are permitted to do what you are requesting).
API Keys
The simplest and most common way to authenticate an API. When you sign up for access, the provider gives you an API key, a unique string of 32 to 64 characters. Every request of yours needs this and most often it goes in as an HTTP header.
Authorization: Bearer sk_live_abc123xyz789...The server looks up the key, identifies your account, checks the permissions associated with it and decides whether to fulfill the request.
Beyond authentication, API keys have several roles. Providers can use them to track usage by customer, enforce rate limits (how many requests per second or per month you are allowed) and bill based on consumption.
The critical security rule: API keys are secrets, equivalent in sensitivity to passwords. They should never be committed to version control (a 2019 study found over 100,000 GitHub repositories containing leaked API keys and other secrets[6]).
Never put them in client-side browser code that users can check with developer tools. Store them in environment variables or a secret management system and rotate them immediately once they are compromised.
OAuth 2.0: Delegated Authorization
For scenarios where a user needs to authorize an application to access their data on a third-party service, API keys are insufficient.
OAuth 2.0, formalized in RFC 6749 (2012), is the standard protocol for delegated authorization - the mechanism behind "Sign in with Google," "Connect to Spotify," and "Authorize with GitHub."
The OAuth flow works through a carefully choreographed sequence:
- Your application redirects the user to the authorization server (e.g., Google's login page)
- After logging in, the user gives approval for the specific permissions that your application is asking for (for example, "read your email" or "access your calendar").
- The authorization server redirects back to your application with a short-lived authorization code
- Your application exchanges that code - server-to-server, using your application's secret credentials - for an access token
- Your application uses the access token to make API calls on behalf of that user
What matters most for security is that your application never sees the user's actual password. Instead, the authorization server (such as Google or GitHub) vouches for who the user is and your app gets only the exact permissions that the user approved.
That is why OAuth became the universal standard for third-party integrations. It allows powerful interoperability without any application that users access needing to get hold of their credentials.
JWT (JSON Web Tokens)
JWTs are a common mechanism for carrying authentication and authorization information in API requests. A JWT is a digitally signed token containing claims about the user (their identity, roles, permissions, and the token's expiration time).
Because the server can check a token's authenticity without doing a database lookup on every request, JWTs work very efficiently for high-volume APIs.
In a standard JWT setup, a user logs in once with a password, OAuth or another method, gets back a JWT and sends that token in the header of later API calls. The server checks the digital signature, reads the claims inside and handles the request.
Webhooks vs. Polling: Two Models for Real-Time Data
One of the most practically important architectural decisions in API design is the choice between polling and webhooks for receiving updates.
Polling: The Ask-Repeatedly Model
Your app sends the server repeated requests through polling to ask for updates. The questions are "Any new orders?" "Has the payment been confirmed?" "Are there new messages?" How often you poll depends on how time-sensitive the updates are and you might poll every 5 seconds, every 30 seconds or every 5 minutes.
Polling is simple to implement - it uses standard API calls on a schedule. But it is fundamentally wasteful: the vast majority of poll requests return nothing new. At scale, thousands of clients polling creates enormous unnecessary server load.
Zapier has reported that the vast majority of polling requests in polling-based integrations return no new data.
Webhooks: The Event-Driven Model
Webhooks invert the polling model entirely. Instead of repeatedly asking "anything new?", you register a URL, your webhook endpoint, and tell the server what events you care about. When those events occur, the server sends an HTTP POST request to your URL immediately with the relevant data.
Real-world examples make this concrete:
- Stripe: When a payment is completed, Stripe sends a webhook to your server with the payment details, so your system can fulfill the order.
- GitHub: When a pull request is merged, GitHub sends a webhook to your CI/CD system, triggering an automatic deployment.
- Shopify: When a new order is placed, Shopify sends a webhook to your inventory management system to update stock levels.
- Twilio: When an SMS reply is received, Twilio sends a webhook to your application with the message content.
Event-driven and efficient, webhooks communicate just as something happens and not following a wasteful polling schedule.
Security is the main complication. Your endpoint needs to be publicly accessible, which calls for signature verification to stop spoofing. Idempotency is another major issue. Your endpoint has to handle the possibility that the same event gets delivered more than once because webhook delivery systems most often retry on failure.
Real-World API Examples That Power the Digital Economy
Stripe: The Payment Infrastructure
Stripe, founded by Irish brothers Patrick and John Collison in 2010, built a company valued at over $50 billion by making one thing excellent: payment processing via a clean, developer-friendly API. When a customer enters their card on an e-commerce site, the site never touches the card details directly.
Card information goes from the browser to Stripe's API via Stripe.js. The API handles tokenization, which converts the card number into a single-use token. It then talks to the card network (Visa, Mastercard and others) and returns a success or failure response.
The merchant's server never sees the raw card number, dramatically simplifying PCI compliance.
Stripe processes hundreds of billions of dollars annually. Its API documentation is widely considered the gold standard in the industry - clear, comprehensive, with working code examples in multiple languages.
Google Maps Platform: Location Intelligence
Opening a restaurant delivery app and seeing a map that shows where your driver is, that map does not come from the delivery company. It is Google Maps rendered via the Maps JavaScript API and the company adds its custom markers, routing data and real-time location updates on top.
Beyond a free tier, Google charges for each API call. As of 2024, that comes to about $7 per 1,000 map loads and $5 per 1,000 geocoding
An estimated 5 million websites and applications use the Google Maps API, according to BuiltWith. The platform handles over 1 billion API requests per day.
Twilio: Communications as a Service
Twilio, founded by Jeff Lawson in 2008, provides communications infrastructure via API. When you receive a text message saying "Your order has shipped" or "Your verification code is 482931," that message was almost certainly sent through Twilio's Messaging API (or a competitor like Vonage or MessageBird).
The sending company's system sends an API call with the recipient's phone number and message text. Twilio then routes that to the right mobile carrier.
Each year, Twilio processes more than 100 billion API calls and runs communications behind companies such as Uber, Airbnb, Netflix and Twitch.
OpenAI API: AI as a Service
The OpenAI API represents a newer category: artificial intelligence capabilities delivered as an API service. Applications built on GPT models do not contain the AI model themselves - the models are far too large (hundreds of gigabytes) to run on most hardware.
Instead, they send prompts to OpenAI's API and get generated text in return. All tools powered by ChatGPT, AI writing assistants, customer service chatbots and coding helpers that use GPT models are clients of this API and pay per token for generation.
By mid-2024, the OpenAI API was handling about 100 billion tokens per day and that shows the scale on which AI applications depend on API infrastructure.
API Design Principles Worth Knowing
Whether you are building APIs or evaluating them, several principles separate well-designed APIs from frustrating ones:
Consistency is the most important quality. An API that uses user_id in one endpoint and userId in another, or returns dates as Unix timestamps in some responses and ISO 8601 strings in others, creates traps for every developer who integrates with it.
Daniel Jacobson, former VP of Engineering at Netflix, has written extensively about how API consistency reduces integration time and support burden. Stripe's API is consistent to an almost obsessive degree, which is a primary reason developers prefer it.
Versioning protects existing consumers when the API evolves. Common approaches include URL versioning (/v1/users, /v2/users) and header versioning (Accept: application/vnd.api+json;version=2). Without versioning, any change to the API's behavior or data structure risks breaking existing clients - a cardinal sin in API design.
Idempotency. When a request is made multiple times, idempotency means it has the same effect as making it once. Operations that deal with money or state changes need this in particular. Network failures in those operations could make it unclear whether a request got processed.
Stripe requires clients to send a unique Idempotency-Key with payment requests so that retried requests are not processed twice - preventing the nightmare scenario of charging a customer multiple times for one purchase.
Rate limiting protects the provider from abuse and runaway clients. Well-designed rate limiting includes informative response headers that tell clients how many requests they have remaining and when the limit resets, rather than simply returning a 429 Too Many Requests error with no guidance.
Clear, actionable error messages dramatically reduce developer frustration and support load. An error that says "Invalid request" helps nobody. An error that says "The email field is required and must be a valid email address. You provided: null" tells the developer exactly what to fix.
The API Economy: Why APIs Matter Beyond Software
APIs have transformed not just software architecture but entire business models. The concept of the API economy describes how organizations expose their core competencies as services that others can build on, generating revenue from each interaction.
Stripe built a company worth tens of billions of dollars by making one thing, payment processing, excellent and exposing it via a clean API. Twilio did the same for communications. SendGrid (now part of Twilio) for email delivery. Mapbox for maps and geolocation.
Algolia for search. Each of these companies enables startups to build products in days that would have taken months or years to build from scratch, by purchasing commodity infrastructure as a service and focusing engineering effort on their specific differentiator.
Salesforce has reported that roughly 50% of its transactions come through its API, according to the company's developer documentation. Expedia generates over 90% of its revenue through API-based partner integrations. eBay processes more than 8 billion API calls per day.
For non-engineers, understanding APIs matters because:
- Product decisions depend on which APIs exist, their costs and the constraints their terms of service impose.
- Security decisions rest on understanding authentication, key management, and data handling practices
- Partnership decisions frequently involve evaluating and negotiating API integrations
- Competitive strategy more and more comes down to API ecosystems, specifically who can integrate with whom and on what terms.
An API is ultimately an agreement - a contract about how two parties will exchange value. Understanding that contract, even at a conceptual level, is increasingly a prerequisite for effective work in any organization that runs on software.
Getting Started: How to Make Your First API Call
For those who want to move from theory to practice, here is the simplest path to making a real API call:
Choose a free, public API: OpenWeatherMap (weather data), JSONPlaceholder (fake data for testing), or the Pokemon API (yes, it exists) all offer free access without requiring authentication.
Use a tool: Postman (desktop application) or curl (command line) are the standard tools for making API requests without writing code. Postman provides a graphical interface; curl is text-based but universally available.
Make a GET request: Point Postman at
https://jsonplaceholder.typicode.com/users/1and click Send. You will receive a JSON response containing a fake user's data. That is an API call - you requested a resource, and the server returned it.Read the documentation: Every well-designed API provides documentation describing its endpoints, required parameters, authentication method, and response formats. Stripe's documentation () is widely considered the best in the industry and worth reading as a model even if you never use Stripe.
Most people think that the gap between grasping APIs conceptually and putting them to practical use is larger than it is. An afternoon spent with Postman and a public API makes the abstract concrete.
Sources & Further Reading
- Fielding, Roy Thomas. "Architectural Styles and the Design of Network-based Software Architectures." Doctoral dissertation, University of California, Irvine, 2000. View source
- Jacobson, Daniel, Greg Brail, and Dan Woods. APIs: A Strategy Guide. O'Reilly Media, 2012.
- Lauret, Arnaud. The Design of Web APIs. Manning Publications, 2019.
- Saunier, Brenda Jin, Saurabh Sahni, and Amir Shevat. Designing Web APIs: Building APIs That Developers Love. O'Reilly Media, 2018.
- Postman. "2023 State of the API Report."
- Meli, Michael, Matthew R. McNiece, and Bradley Reaves. "How Bad Can It Git? Characterizing Secret Leakage in Public GitHub Repositories." NDSS Symposium, 2019.
- Stripe API Documentation.
- GraphQL Foundation. "Introduction to GraphQL." View source
- gRPC Documentation. View source
- RFC 6749: The OAuth 2.0 Authorization Framework. View source








