API design basics (concept)
Computer Science · Software engineering
Question 1 of 10
0The HTTP status code 500 indicates:
Stuck? Read the explanation
Unlocks at a streak of 5 correct answers in a row.
Embed this practice on your site or class page
Paste this HTML into your page. Students practise right there; it is free and needs no account.
API design basics (concept) explained
An API, or application programming interface, is the set of requests a program offers to other programs. Good API design makes requests predictable, names things consistently and tells callers clearly when something goes wrong.
An API defines the operations a client can perform, the inputs each one accepts and the output it returns. Callers depend on this contract, so changing it can break other programs. Designing it carefully before it is published is easier than fixing it later.
Key design choices include:
- Naming: use nouns for resources and keep names consistent across the API, for example users and orders rather than a mix of getUser and order_list.
- Input validation: check inputs and reject bad ones with a clear message.
- Pagination: return large lists in pages, with a page size and a way to request the next page.
- Errors: return consistent error responses that say what went wrong.
- Versioning: plan how breaking changes will be introduced, for example by publishing a new version path.
Callers see only the API. Internal code can change freely as long as the contract stays the same.
Worked example
An endpoint returns 250 items, and the page size is 20 items.
- Number of pages: .
- A partial page still needs its own request, so round up: pages.
- The last page holds items.
Check: , so 13 requests cover every item.
What you will practise
105 multiple-choice questions (Easy, Medium, Hard). Each answer is followed by an explanation.
Example questions
- An API is:
- Endpoints are:
- Good APIs are:
- API versioning:
- Rate limiting:
- HTTP GET is typically used to:
- HTTP POST is typically used to:
- A JSON object is written with:
…and 97 more.