An API, or Application Programming Interface, is a set of rules that lets software systems communicate with each other. It matters because modern apps rarely work alone. A weather app, payment page, login button, or map view often depends on APIs to request data or services from another system. APIs make software modular, reusable, and easier to connect across devices and platforms.

A typical API interaction starts when a client sends a request to an endpoint, such as asking a server for a user profile or a list of products. The server checks the request, runs the needed logic, and sends back a response containing data, a status code, or an error message. Many web APIs use HTTP methods like GET, POST, PUT, and DELETE to describe the action being requested. Good API design uses clear endpoints, predictable data formats, authentication, and error handling so different systems can work together reliably.

Key Facts

  • API = Application Programming Interface, a contract for how software components exchange requests and responses.
  • Request = method + endpoint + headers + optional body.
  • Response = status code + headers + optional body.
  • GET retrieves data, POST creates or submits data, PUT updates data, and DELETE removes data.
  • Latency = response received time - request sent time.
  • Common HTTP status codes include 200 OK, 201 Created, 400 Bad Request, 401 Unauthorized, 404 Not Found, and 500 Server Error.

Vocabulary

API
An API is a defined way for one software system to request data or actions from another software system.
Endpoint
An endpoint is a specific URL or address where an API can receive a request.
HTTP Method
An HTTP method is a command such as GET, POST, PUT, or DELETE that tells the server what kind of action the client wants.
JSON
JSON is a common text format for sending structured data between a client and a server.
Authentication
Authentication is the process of proving that a user or program is allowed to access an API.

Common Mistakes to Avoid

  • Using GET to change server data is wrong because GET should normally be safe and used for retrieval, not creation, updates, or deletion.
  • Ignoring status codes is wrong because the response body alone may not clearly show whether the request succeeded, failed, or needs authentication.
  • Sending private API keys in public client-side code is wrong because anyone can inspect the app and steal the key.
  • Assuming every API returns the same data shape is wrong because endpoints can have different schemas, optional fields, and error formats.

Practice Questions

  1. 1 A client sends a request at 12:00:00.250 and receives the response at 12:00:00.890. What is the API latency in milliseconds?
  2. 2 An app makes 1,200 API requests in 10 minutes. What is the average number of requests per minute, and what is the average number of requests per second?
  3. 3 A shopping app needs to show a product list, add a new review, update a shipping address, and remove an item from a cart. Choose the most appropriate HTTP method for each action and explain your reasoning.