REST API Cheatsheet
Based on ByteByteGo EP94 -
Summarized by ChatGPT
Key REST Principles
• Stateless interactions
• Client-server separation
• Cacheability
• Uniform interface
• Layered system architecture
• Code on demand (optional)
Core HTTP Methods
• GET: Retrieve data
• POST: Create resource
• PUT: Update or create resource
• PATCH: Partial update
• DELETE: Remove resource
Versioning Strategies
• URI-based versioning: /v1/users
• Header-based versioning: Accept header with
version info
Status Codes & Idempotency
• Use standard HTTP status codes: 200, 201,
400, 401, etc.
• Ensure idempotency for GET, PUT, DELETE
• Use idempotency keys for POST where needed
Pagination & Filtering
• Offset-based: ?offset=20&limit=10
• Cursor-based: better for performance
• Include metadata like totalCount, hasNextPage
Filtering & Sorting
• Support field filtering: ?filter[field]=value
• Sorting with indicators: ?sort=-createdAt
Security Best Practices
• Use HTTPS for secure transport
• Support authentication: API keys, OAuth2,
JWT
• Implement authorization: roles, scopes
• Apply rate limiting and throttling
Endpoint Design Guidelines
• Use resource-based URLs: /orders/123/items
• Avoid verbs in paths; rely on HTTP method
Summary & Best Practices
• RESTful design follows consistent principles
• Use correct HTTP verbs and status codes
• Secure and paginate your API
• Keep endpoints clean and well-structured