# What makes an API good? Principles of API design

> What qualities make an API well designed, and how would you judge one in a design review?

Canonical: https://www.internhack.in/learn/interview/api-design-interview/api-what-makes-good-api
Last updated: 2026-11-28

Difficulty: Beginner

## Question

What qualities make an API well designed, and how would you judge one in a design review?

## Answer

Think of an API as a user interface whose users happen to be programmers. Just like a good app UI, a good API is judged by how quickly a stranger can accomplish a task without reading a manual. That framing is the one interviewers love, because it moves the conversation away from memorising rules and towards reasoning about the consumer.

The first quality is consistency. If one endpoint returns createdAt and another returns created_at, or one paginates with page and the next with offset, every integrator pays a tax. Pick conventions for naming, casing, date formats (ISO 8601 in UTC), pagination and error shapes, and stick to them everywhere. Stripe is the usual example: once you have learned one resource, the rest feel predictable.

The second is the principle of least surprise. A GET must never change state, a DELETE on something already deleted should not explode, and a field named amount should say whether it is in rupees or paise. Ambiguity is where production bugs live, so be explicit: store money as integer minor units with a currency code, never as floating point.

Third is simplicity and focus. Model the domain the consumer cares about, not your database tables. If clients must call five endpoints and stitch results to render one screen, the API is leaking your internal structure. Good APIs expose stable business concepts such as orders, payments and refunds, and hide the messy storage behind them.

Fourth is evolvability. You will be wrong about something, and clients you do not control will depend on it. Design so that you can add fields, add optional parameters and add new enum values without breaking anyone, and have a versioning and deprecation policy before you need it. Tell consumers to ignore unknown fields, and avoid making response shapes depend on undocumented behaviour.

Fifth is safety and reliability under real conditions. Networks fail, clients retry, and users double click. So think about idempotency for writes, rate limits with clear headers, timeouts, and meaningful error responses that say what went wrong and whether retrying helps. Security is part of design too: authenticate every call, authorize per resource, validate input, and never leak internals in error messages.

Sixth is discoverability and documentation. An OpenAPI spec, runnable examples, sandbox keys and a changelog are part of the product. If your docs and behaviour disagree, developers trust neither. Good error messages that link to docs count as documentation as well.

Finally, performance and ergonomics: sensible pagination defaults, the ability to filter and select fields, compression, and caching headers. Do not optimise prematurely, but do not ship an endpoint that returns a million rows either.

In a review, I would run a quick checklist: are names consistent, are methods used with correct semantics, are status codes accurate, is every list paginated, are writes safe to retry, is there a versioning story, and can a new developer make a first successful call in under ten minutes. That last one, time to first successful call, is a surprisingly good metric that companies like Stripe and Postman openly optimise for.

## Code examples

### Consistent resource shape

```
GET /v1/orders/ord_123 HTTP/1.1
Accept: application/json

HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": "ord_123",
  "status": "paid",
  "amount": 49900,
  "currency": "INR",
  "created_at": "2026-09-01T10:15:30Z"
}
```

Integer minor units, an explicit currency, ISO 8601 UTC timestamp, and a prefixed id that hints at the resource type.

## Key points

- Consistency across endpoints matters more than any single clever choice.
- Model business concepts, not database tables.
- Design for additive change so old clients keep working.
- Money should be integer minor units plus a currency code.
- Time to first successful call is a real API quality metric.

## Common follow-up questions

- How would you make an existing inconsistent API more consistent without breaking clients?
- Why do many APIs use prefixed ids like ord\_ or pay\_?
- How do you decide between exposing a field or hiding it?

## Interview tips

- Structure the answer around consumers: consistency, least surprise, evolvability, reliability, documentation.
- Mention a real example such as Stripe to show you have seen good design.

## Concepts covered

API design, consistency, developer experience, least surprise

Next: [REST architectural constraints explained](https://www.internhack.in/learn/interview/api-design-interview/api-rest-constraints) · [All of API Design](https://www.internhack.in/learn/interview/api-design-interview)

## More API Design questions

- [Resource naming and URL design conventions](https://www.internhack.in/learn/interview/api-design-interview/api-resource-naming)
- [HTTP methods: safe vs idempotent](https://www.internhack.in/learn/interview/api-design-interview/api-http-methods-idempotency)
- [PUT vs PATCH vs POST: when to use which](https://www.internhack.in/learn/interview/api-design-interview/api-put-vs-patch-vs-post)
- [Choosing the right HTTP status codes](https://www.internhack.in/learn/interview/api-design-interview/api-status-codes)
- [Designing error responses with RFC 9457 problem details](https://www.internhack.in/learn/interview/api-design-interview/api-error-format-problem-details)
- [Pagination: offset vs cursor (keyset) trade-offs](https://www.internhack.in/learn/interview/api-design-interview/api-offset-vs-cursor-pagination)

## Related

- [Learn](https://www.internhack.in/learn)
- [Interview Prep](https://www.internhack.in/learn/interview)
- [API Design](https://www.internhack.in/learn/interview/api-design-interview)
