What is an API

File Handling and Exception Handling

Learning Outcome

5

Connect APIs to Generative AI access.

4

Apply UI vs API to real scenarios.

3

Recognize the three types of APIs.

2

Identify the key components of an API.

1

Understand what an API is.

The Bank Counter

Core idea: the counter is an API: access without touching internals.

At a bank, you never enter the vault. You hand a slip and ID to the teller, who returns cash or a clear message like “insufficient balance.”

The counter has rules: valid ID, fixed format, daily limits.

Transition to Technical Concept: Think About It

A food delivery app shows maps it never built.

A food delivery app shows maps it never built.

Expected Answer: No. It went to the counter, sending a request through an API.

Exactly! So what exactly is this counter?

What is an API?

You’ve used one already: open() is part of Python’s API.

No need to know internals; the documentation is enough.

It’s a contract: right request format → agreed response format.

Application Programming Interface:
rules that let one program request data or services from another.

Why it matters: In this course, “API” mostly means web APIs, which work over the internet.

The API Cycle

Key Components of an API

Types of APIs

  • Public: open to developers via an API key (weather, maps, AI models)
  • Private: internal only (CRM ↔ LMS)
  • Partner: shared under agreement (payment gateway ↔ e-commerce)

Styles: REST (most common, used by GenAI services), SOAP (older), GraphQL (newer)

UI vs API (Comparison)

A Simple Way to Remember

Think & Discuss: APIs cost money to build and run. Why do Google and AI providers offer them instead of staying closed or opening their databases?

Real-World Applications: UI or API?

Why APIs Matter for Generative AI

Key Point: APIs aren’t a side skill in GenAI. They connect your code to the model.

Summary

5

GenAI models are accessed through APIs.

4

UI is for people; API is for programs.

3

APIs are public, private, or partner; REST leads.

2

Client, server, endpoint, request, response, authentication.

1

An API lets software request from software.

Quiz

In “Sign in with Google” on a food app, who is the client?

A. Google

B. The food delivery app

C. The user’s password

D. The map provider

Quiz-Answer

In “Sign in with Google” on a food app, who is the client?

A. Google

B. The food delivery app

C. The user’s password

D. The map provider

File Handling and Exception Handling - Advanced Exception Handling - What is an API?

By Content ITV

File Handling and Exception Handling - Advanced Exception Handling - What is an API?

  • 85