GitHub CopilotPythonAPI Design
REST API Design Rules — GitHub Copilot (Python)
REST API Design best practices for GitHub Copilot with Python. Enforced coding rules for AI assistants.
.github/copilot-instructions.md
# REST API Design Rules — GitHub Copilot (Python)
# REST API Design Rules
When generating API endpoints, follow these conventions:
## URL Design
- Plural nouns for resources: `/users`, `/posts`, `/orders`
- Hierarchical: `/users/{id}/orders/{orderId}`
- Lowercase, kebab-case: `/blog-posts` not `/blogPosts`
- Versions in URL: `/api/v1/users`
- Actions as POST endpoints: `/users/{id}/activate`
## HTTP Methods
- GET: read (idempotent, cacheable)
- POST: create or action
- PUT: full replace
- PATCH: partial update
- DELETE: remove
## Status Codes
- 200 OK, 201 Created, 204 No Content
- 400 Bad Request (validation), 401 Unauthorized, 403 Forbidden, 404 Not Found
- 409 Conflict, 422 Unprocessable Entity
- 429 Too Many Requests, 500 Internal Server Error
## Request/Response
- JSON everywhere — consistent Content-Type: application/json
- camelCase field names in JSON
- Consistent error format: `{ error: { code, message, details } }`
- Pagination: `{ data: [], meta: { total, page, perPage, lastPage } }`
## Security
- Authenticate every non-public endpoint
- Rate limiting on all endpoints
- Request size limits
- Never return passwords or secrets in responsesHow to use with GitHub Copilot
Create `.github/copilot-instructions.md` in your repository. GitHub Copilot uses these to customize suggestions across your whole repo.
#copilot#python#api-design#ai-coding-rules
Related Rules
Python Cursor Rules
CursorPython
Best Cursor AI coding rules for Python development. Enforce type hints, PEP 8, Pythonic patterns, and modern Python best practices in your .cursorrules file.
Code Style
python · type-hintsCopy Ready
TypeScript GitHub Copilot Instructions
GitHub CopilotTypeScript
GitHub Copilot custom instructions for TypeScript: strict types, modern patterns, and team conventions.
Code Style
typescript · copilotCopy Ready
React GitHub Copilot Instructions
GitHub CopilotReact
GitHub Copilot instructions for React: hooks, patterns, and best practices for modern React apps.
Code Style
react · copilotCopy Ready
Next.js GitHub Copilot Instructions
GitHub CopilotNext.js
GitHub Copilot custom instructions for Next.js App Router projects.
Architecture
nextjs · copilotCopy Ready