Prompt Library ⚙️ Technical Build a REST API From Scratch
Any ⚙️ Technical Advanced

Build a REST API From Scratch

Design and implement a production-ready REST API with full CRUD, auth, and documentation.
👁 6 views ⎘ 0 copies ♥ 0 likes

The Prompt

Build a complete REST API for the following application:

Application purpose: [describe what the API serves]
Resources to expose: [list the main data entities — e.g. users, products, orders]
Language and framework: [Node.js/Express / Python/FastAPI / Python/Django / PHP/Laravel / Go / other]
Database: [PostgreSQL / MySQL / MongoDB / SQLite / other]
Authentication method: [JWT / API key / OAuth / session]
Expected API consumers: [web frontend / mobile app / third-party developers / all]
Special requirements: [file uploads / webhooks / rate limiting / versioning / other]

Provide a complete API implementation:

PROJECT STRUCTURE:
- Full directory and file structure
- Separation of concerns (routes / controllers / services / models / middleware)

DATABASE LAYER:
- Schema / models for all entities
- Relationships and indexes
- Migration files

AUTHENTICATION LAYER:
- Auth middleware
- Protected vs public routes

ROUTES AND CONTROLLERS:
For each resource provide:
- GET /resource (list with pagination, filtering, sorting)
- GET /resource/:id (single item)
- POST /resource (create with validation)
- PUT /resource/:id (full update)
- PATCH /resource/:id (partial update)
- DELETE /resource/:id (soft or hard delete)

INPUT VALIDATION:
- Validation rules for each endpoint
- Error response format (consistent structure)
- Sanitisation approach

ERROR HANDLING:
- Global error handler
- Custom error classes
- HTTP status code usage guide

RESPONSE FORMAT:
- Consistent response envelope
- Pagination metadata format
- Error response format

SECURITY:
- Rate limiting
- Input sanitisation
- SQL injection prevention
- CORS configuration

API DOCUMENTATION:
- OpenAPI/Swagger spec for all endpoints
- Example request and response for each

TESTING:
- Unit test examples for key controllers
- Integration test examples

📝 Fill in the blanks

Replace these placeholders with your own content:

[describe what the API serves]
[list the main data entities — e.g. users, products, orders]
[Node.js/Express / Python/FastAPI / Python/Django / PHP/Laravel / Go / other]
[PostgreSQL / MySQL / MongoDB / SQLite / other]
[JWT / API key / OAuth / session]
[web frontend / mobile app / third-party developers / all]
[file uploads / webhooks / rate limiting / versioning / other]

How to use this prompt

1
Copy the prompt

Click "Copy Prompt" above to copy the full prompt text to your clipboard.

2
Replace the placeholders

Swap out anything in [BRACKETS] with your specific details.

3
Paste into Any

Open your preferred AI assistant and paste the prompt to get started.