๐ฅ๐๐ฆ๐ง ๐๐ฃ๐ ๐๐ฒ๐๐ ๐ฃ๐ฟ๐ฎ๐ฐ๐๐ถ๐ฐ๐ฒ๐: ๐ ๐ฃ๐ฟ๐ฎ๐ฐ๐๐ถ๐ฐ๐ฎ๐น ๐๐๐ถ๐ฑ๐ฒ
Build APIs people love. Follow these rules for better design.
Use nouns for resources. Use plural names.
- Use /invoices.
- Do not use /invoice.
- Use HTTP methods for actions.
Use correct HTTP status codes.
- 200 for success.
- 201 for created.
- 204 for deletes.
- Do not return 200 for errors.
Standardize your errors.
- Use one structure everywhere.
- Follow RFC 9457.
- This makes integration easy.
Plan for growth.
- Add pagination from day one.
- Add filtering and sorting.
- Large lists crash production.
Protect your users.
- Use /v1/ in your URLs.
- This prevents breaking changes.
Secure your API.
- Use HTTPS everywhere.
- Follow OWASP API Security Top 10.
Stop duplicate data.
- Make unsafe operations idempotent.
- This prevents double charges during network failure.
Document your work.
- Use OpenAPI.
- Follow industry standards.
Source: https://dev.to/raisul_islam_100/rest-api-best-practices-a-practical-guide-2gin