Class 7 · CBSE AI · Strand B — Python for AI

What is an API? The mental model every coder needs — Class 7

An API is a contract for how two programs talk. REST, GET and POST explained simply. For Class 7.

What this concept actually says

  • An API (Application Programming Interface) is a defined contract for how two pieces of software communicate
  • Request-response is the fundamental pattern: you send a structured request, the server processes it, and returns a structured response
  • Authentication, rate limits, and error codes are the three things that always matter when using any API

An analogy your child will recognise

Bank teller window

An API is like a bank teller window. There is a specific form to fill in (the request format), you need your ID (the API key), there is a maximum number of transactions per day (rate limit), and you get a standardised slip in return (the response). You do not need to know how the bank's internal systems work — just the interface at the window.

IRCTC train booking

When you book a train on IRCTC, you do not talk directly to the railway's database. You use a defined interface — select train, enter details, pay, receive confirmation. That interface is an API. IRCTC's app and your booking are on one side; the railway's servers are on the other, connected by a contract.

Common misconceptions to watch for

  • Once an API is working, it will always work the same way — in reality, APIs are versioned and providers deprecate old versions; code must be maintained
  • API keys are safe to share with trusted friends — in reality, an API key is a credential that carries your billing and usage responsibility, never share it

Key facts in one breath

  • REST (Representational State Transfer) is the most common API architecture — it uses standard HTTP methods: GET, POST, PUT, DELETE
  • API responses are almost always in JSON (JavaScript Object Notation) format, which is why knowing dictionaries in Python is essential
  • HTTP status codes: 200 = success, 400 = bad request, 401 = unauthorised, 404 = not found, 429 = too many requests, 500 = server error
  • API documentation is the contract — reading it carefully before coding saves hours of debugging

How Dhee Learning teaches this — the 3-stage question loop

Every Dhee Learning session for this concept follows three stages. We share the questions Dhee actually asks, so you can hear what a session sounds like.

Stage 1 — Surface

You have used two APIs now — one for images and one for language. What do they have in common? What pattern did you notice in how you talked to both of them?

Rote answer

"Both need an API key and you send them something and get something back"

Understood

"Both follow the same request-response pattern with a defined input format, authentication to prove who you are, and a structured response you can parse — the specific content is different but the contract is the same"

Stage 2 — Reasoning

Why does an API have rate limits — a maximum number of requests per minute? Who benefits from rate limits, and who is inconvenienced by them?

Follow-up Dhee may use: If you are building a product that many users will use simultaneously, how does rate limiting change how you design your system?

Stage 3 — Application

An API returns a 401 error. Another returns a 429 error. A third returns a 200 but with an empty response body. What is wrong in each case, and what would you do to fix it?

Misconception Dhee watches for: Treating all errors as 'the API is broken' rather than reading the error code to diagnose what specifically went wrong

Related concepts

Want your child to actually understand this?

Dhee turns this concept into a 15-minute spoken session — asking, listening, and probing — so your child builds the idea themselves.

Frequently asked questions

What is the api mental model — explained for kids? +

An API is a contract for how two programs talk. REST, GET and POST explained simply. For Class 7.

What's the most common mistake children make about this concept? +

Once an API is working, it will always work the same way — in reality, APIs are versioned and providers deprecate old versions; code must be maintained

How does Dhee Learning teach this in a Class 7 session? +

Dhee opens with a question — for example: "You have used two APIs now — one for images and one for language. What do they have in common? What pattern did you notice in how you talked to both of them?" — listens to your child's answer, then probes the reasoning behind it. The session ends when the child can apply the idea to a brand-new situation, not just recall it.