CodingNic

Web Fundamentals

Introduction to APIs

Web Fundamentals 12 min read

Introduction to APIs

Introduction to APIs

Modern web applications rarely work alone. They communicate with other systems through APIs.

Understanding APIs is essential because you will build and use them throughout this course.

What is an API?

API stands for Application Programming Interface.

An API allows different applications to communicate with each other.

Instead of interacting directly with a database or system, a client sends requests to an API.

How APIs Work

APIs follow the same request–response model you’ve already learned.

  • The client sends a request to an API endpoint
  • The API processes the request
  • The API returns a response

Request Response Diagram

API Endpoints

An endpoint is a specific URL where an API can be accessed.

Examples:

id="api-example"
GET /users POST /users GET /products

Each endpoint performs a specific action.

Types of APIs

There are different types of APIs, but the most common in web development is REST.

REST APIs

REST APIs use HTTP methods to interact with resources.

  • GET → retrieve data
  • POST → create data
  • PUT → update data
  • DELETE → remove data

What APIs Return

APIs usually return data in JSON format.

Example response:

id="json-example"
{ "id": 1, "name": "John", "email": "john@example.com" }

Why APIs Matter

APIs allow systems to work together.

  • Frontend apps communicate with backend servers
  • Mobile apps connect to web services
  • External services provide data (weather, payments, etc.)

Real-World Example

When you open a social media app:

  • The app sends a request to an API
  • The API retrieves posts from a database
  • The API returns the data
  • The app displays the content

How This Connects to the Course

You will:

  • Build APIs using FastAPI
  • Create endpoints for your applications
  • Connect frontend interfaces to backend APIs

Summary

  • APIs allow applications to communicate
  • They follow the request–response model
  • Endpoints define available actions
  • JSON is commonly used for data exchange

In the next lesson, you’ll learn how JSON works and how data is structured in web applications.