What Is an API?
An API, or application programming interface, is a defined set of rules that lets one software program request services or data from another. The API specifies the requests a program can make, the data formats it must use, and the responses it receives, hiding the internal workings of the service behind a stable interface. Roy Fielding defined the REST architectural style in his 2000 doctoral dissertation, the model behind most web APIs today.
This article defines an API, then explains how APIs work through requests and responses, the types of API, the difference between REST, SOAP, and GraphQL, how API authentication protects access, and real-world examples such as weather, payment, and maps services. A comparison table summarizes the web API styles.
Each section answers one question and states the measurable detail. The result gives a clear understanding of how APIs let programs communicate and why they form the backbone of modern software.
What Is an API?
An API, or application programming interface, is a defined interface that lets one program request data or services from another program using a fixed set of rules and formats. The API describes what requests are valid and what responses follow, without exposing how the receiving program works internally. An API provides three core things:
- A contract defines the available operations, the required inputs, and the structure of the response, which both programs agree to follow.
- Abstraction hides the internal implementation of a service, so a program uses it without knowing how it stores or processes data.
- Interoperability lets programs written in different languages and running on different machines exchange data through the shared interface.
An API works like a defined doorway between programs: one program sends a request in the agreed format, and the other returns a response. The guide to programming languages explains the languages that call APIs, while the overview of the internet covers the network that web APIs travel across. The API lets software reuse the functions of another program without rebuilding them.
How Do APIs Work?
APIs work through a request-and-response cycle, where a client program sends a structured request to a defined endpoint and the server returns a structured response. The request specifies the operation, and the response carries the data or a status result. The request-response cycle involves four core parts:
- The endpoint is the address the client sends the request to, identifying the specific resource or operation the API exposes.
- The request carries a method, parameters, and sometimes a body that tells the server what data or action the client wants.
- The response returns the requested data, usually formatted as JSON, along with a status code that reports success or failure.
- The status code reports the outcome, such as 200 for success or 404 for a missing resource, following HTTP conventions.
A web API uses HTTP methods such as GET to read data and POST to send data, with the server returning a status code and a response body. The explanation of how data travels on the internet covers the network path the request and response follow. JSON has become the common response format because it is compact and readable by programs in any language.
What Are the Types of API?
APIs fall into several types, including web APIs, library APIs, operating system APIs, and hardware APIs, each exposing a different kind of service to programs. The type of API depends on what it connects and where it runs. The main types of API are listed below:
- Web APIs let programs communicate over a network using HTTP, returning data from remote servers, as REST and GraphQL APIs do.
- Library APIs expose the functions of a code library to a program, defining how to call its functions from source code.
- Operating system APIs let programs request services from the operating system, such as reading files or allocating memory.
- Hardware APIs let software communicate with devices through drivers, controlling printers, graphics cards, and sensors.
Web APIs dominate modern development because they connect applications across the internet, while library and operating system APIs work within a single machine. The overview of software frameworks shows how frameworks expose library APIs that developers call. Each API type defines the same idea of a fixed interface, applied to a different layer of software.
What Is the Difference Between REST, SOAP, and GraphQL?
REST, SOAP, and GraphQL are three styles of web API, where REST uses HTTP and resources, SOAP uses strict XML messaging, and GraphQL lets clients request exactly the data they need. The style shapes how a client requests and receives data. The three web API styles differ as listed below:

- REST, defined by Roy Fielding in 2000, uses HTTP methods and resource URLs, returning JSON, and is the most common web API style.
- SOAP is a protocol that exchanges structured XML messages with strict standards, used in enterprise systems requiring formal contracts.
- GraphQL, released by Facebook in 2015, lets a client request exactly the fields it needs in one query, reducing over-fetching of data.
REST suits most public web APIs because it maps cleanly to HTTP and resources, while GraphQL suits applications that need flexible, precise data queries. SOAP remains in enterprise and financial systems that require formal messaging contracts. The guide to how the internet works explains the HTTP foundation that REST and GraphQL both build on.
How Does API Authentication Work?
API authentication verifies which program is making a request, using methods such as API keys, OAuth tokens, and JSON Web Tokens to control access to the API. Authentication prevents unauthorized programs from using a service or reading its data. The main API authentication methods are listed below:

- API keys are unique strings a client includes with each request, identifying the calling application to the server.
- OAuth is an authorization standard that issues access tokens, letting a user grant an application limited access without sharing a password.
- JSON Web Tokens are signed tokens that carry user identity and permissions, which the server verifies on each request without storing session state.
- Basic authentication sends a username and password with each request, used over encrypted connections for simple internal APIs.
OAuth has become the standard for letting an application access a user’s data on another service, such as signing in with a Google account. API keys identify the calling application but do not identify an individual user. The explanation of how data travels on the internet covers the encrypted HTTPS connections that protect these credentials in transit.
What Are Real-World Examples of APIs?
Real-world APIs include weather services, payment processors, and mapping platforms, each letting applications add features without building the underlying service. Most modern applications combine several external APIs. Common real-world API examples are listed below:
- Weather APIs return current conditions and forecasts for a location, letting apps display weather without operating their own sensors.
- Payment APIs such as those from Stripe and PayPal process card payments, handling the secure transaction so the app never stores card data.
- Maps APIs such as Google Maps and OpenStreetMap supply maps, directions, and location search for applications to embed.
- Social and login APIs let users sign in with an existing account and share content, using OAuth to grant limited access.
A single mobile app may call a maps API for navigation, a payment API for checkout, and a weather API for forecasts, combining services it never builds itself. This reuse is why APIs underpin modern software. The software framework guide shows how frameworks simplify calling these external APIs from application code.
What Is the Difference Between an API and a Web Service?
A web service is a type of API that communicates over a network using web protocols, while an API is the broader concept covering any defined interface between programs, networked or local. Every web service is an API, but not every API is a web service. The two terms differ as listed below:
- Scope separates the two, since an API covers any interface between software components while a web service specifically communicates over a network.
- Transport differs, with a web service always using web protocols such as HTTP, while an API may run entirely within one machine.
- Data formats for web services use XML or JSON sent across the network, while a local library API passes data structures directly in memory.
- Examples show the relation, since a REST web service is an API, but a library API that runs in-process is not a web service.
A web service requires a network and a web protocol, which makes it a networked subset of the wider API concept. Local APIs, such as operating system and library APIs, need no network and run within a single program. The guide to how the internet works explains the network layer that every web service depends on but a local API does not.
API Styles Comparison Table
The table below compares the three main web API styles, REST, SOAP, and GraphQL, across protocol, data format, flexibility, and typical use, summarizing how each handles communication between programs.
| Aspect | REST | SOAP | GraphQL |
|---|---|---|---|
| Type | Architectural style | Protocol | Query language and runtime |
| Data format | Usually JSON | XML only | JSON |
| Transport | HTTP | HTTP, SMTP, others | HTTP |
| Data fetching | Fixed endpoints per resource | Operations defined in WSDL | Client requests exact fields |
| Defined by | Roy Fielding, 2000 | W3C standard | Facebook, 2015 |
| Common use | Public web APIs | Enterprise and finance | Flexible client-driven apps |
Key Takeaways
- An API is a defined interface that lets one program request data or services from another using fixed rules and formats.
- APIs work through requests and responses, where a client sends a structured request to an endpoint and the server returns a response.
- API types include web, library, operating system, and hardware APIs, each exposing a different kind of service.
- REST, SOAP, and GraphQL are web API styles, with REST the most common, SOAP strict XML, and GraphQL client-driven.
- Authentication controls access through API keys, OAuth, and JSON Web Tokens that verify the calling program or user.
- Real-world APIs include weather, payment, and maps services that apps combine without building the underlying systems.
What is an API in simple terms?
An API, or application programming interface, is a set of rules that lets one program request data or services from another. It defines the valid requests and the responses without exposing internal code.
How does an API work?
An API works through a request and response cycle. A client sends a structured request to a defined endpoint, and the server returns a response with data and a status code, usually formatted as JSON.
What is the difference between REST and SOAP?
REST is an architectural style that uses HTTP methods and resource URLs, usually returning JSON. SOAP is a protocol that exchanges strict XML messages, used in enterprise systems needing formal contracts.
What is a REST API?
A REST API is a web API following the REST style defined by Roy Fielding in 2000. It uses HTTP methods like GET and POST against resource URLs and typically returns data in JSON format.
What is API authentication?
API authentication verifies which program or user is making a request. Common methods include API keys, OAuth tokens, and JSON Web Tokens, which control access and prevent unauthorized use of the API.
What are examples of APIs?
Common APIs include weather services, payment processors such as Stripe and PayPal, and mapping platforms such as Google Maps. Apps combine these APIs to add features without building the underlying services.
Last Thoughts on APIs
An API is the defined interface that lets programs communicate, sending structured requests to endpoints and receiving structured responses without exposing internal code. Web APIs built on REST, SOAP, and GraphQL connect applications across the internet, while library and operating system APIs work within a machine.
Authentication protects access, and real-world weather, payment, and maps APIs let apps reuse services they never build. Readers can continue with the guide to programming languages, the overview of how the internet works, or the software applications guide that links the full software cluster.


