First, the key terms.
- Endpoint
- An address for a particular API operation.
- Schema
- A description of the shape and allowed values of data.
- Status code
- A machine-readable indication of an HTTP request’s outcome.
The idea, explained
An API can be a local library interface or a remote service. A web API often exchanges structured data through HTTP. The contract should make inputs, responses, errors and permissions clear. The same function name does not guarantee the same behavior across versions; callers need to understand the documented contract.
Identify the contract
An API lets one program request a defined operation from another. For newsletter signup, the contract might require an email and an explicit consent value. A clear contract defines required fields, expected responses and failure cases.
Distinguish format from meaning
JSON is a way to represent data, not a guarantee that the data is correct. A request can be valid JSON while missing an email or containing consent = false. Validate shape, allowed values and the requester’s permission at the trusted boundary.
Handle outcomes explicitly
A success response might mean “confirmation requested,” not “subscription confirmed.” Read what the operation promises. Timeouts, validation errors and provider failures should produce different behavior, so the interface does not tell users an email was sent when it was not.
Follow a worked example.
A school app requests a student’s timetable using an identifier. The service checks authorization and returns structured lesson times. Knowing a student identifier must not, by itself, grant access to that student’s records.
Walk it through, one step at a time
- The browser sends a signup request with email and consent = true. The server checks both.
- The server stores a pending request and asks the email provider to send confirmation. Its response describes that pending state.
- Only a later valid confirmation changes the subscription to active. The first API success must not be interpreted as proof that the user clicked the email.
Where people get stuck
An API is an interface, not a guarantee that data is public, accurate or available without authentication.
Now try it yourself.
1. Check the core idea
Can an API exist without a network connection?
Reveal the answer & reasoning
Yes. A library or operating system can expose an API for software running locally.
2. Apply what you learned
Can an application trust an input just because its own form normally creates it?
Reveal the answer & reasoning
No. A caller can send requests without using the form. The server must enforce the contract and permissions independently.