Good API Design
Names, versions, errors.
An API is a promise. Once other people build on it, changing it can break their apps. So it's worth designing it carefully, the first time.

- An API is a promise
- Changes break others
- Design it carefully
Habits of good APIs
Good APIs share a few habits. Use plural nouns, like slash products, not verbs, like slash get products. Put a version in the path, like slash v one, so you can change things later without breaking old clients. Return clear errors, with a status code and a message. And be consistent everywhere.
A helpful error
Compare two errors. The first just says error, which helps nobody. The second gives a status, a machine readable code, and a message a human can act on. Run it. A developer seeing the second one knows exactly what to fix.
import json
bad = {"error": "error"}
good = {
"status": 400,
"code": "INVALID_QUANTITY",
"message": "quantity must be between 1 and 99",
}
print(json.dumps(bad))
print(json.dumps(good, indent=2)){"error": "error"}
{
"status": 400,
"code": "INVALID_QUANTITY",
"message": "quantity must be between 1 and 99"
}Summary
Good APIs use nouns, versions, clear errors, and the same style everywhere. Next, how to return a long list without sending everything at once.
Key takeaways- Nouns, not verbs
- Version from day one
- Errors people can act on