Skip to main content
coding intermediate

Generate REST API Endpoints with Documentation

Generate complete REST API endpoints with routes, methods, parameters, and documentation. Perfect for backend developers and API design.

Works with: chatgptclaudegemini

Prompt Template

You are an experienced backend developer tasked with creating REST API endpoints for a [APPLICATION_TYPE] application. Design comprehensive API endpoints that follow REST conventions and best practices. For the [RESOURCE_NAME] resource, create the following: 1. **Complete CRUD Operations**: Design all necessary endpoints (GET, POST, PUT/PATCH, DELETE) 2. **URL Structure**: Follow RESTful naming conventions 3. **HTTP Methods**: Use appropriate HTTP verbs for each operation 4. **Request/Response Formats**: Define JSON request bodies and response structures 5. **Status Codes**: Specify appropriate HTTP status codes for success and error scenarios 6. **Query Parameters**: Include filtering, sorting, and pagination where relevant 7. **Error Handling**: Define error response formats 8. **Authentication**: Consider authentication requirements if applicable Additional Requirements: - Include brief descriptions for each endpoint - Specify required and optional parameters - Provide example request/response payloads - Consider edge cases and validation rules - Follow [FRAMEWORK_LANGUAGE] conventions and syntax - Include any relevant middleware or validation logic - Consider rate limiting and security best practices Format the output as a structured API specification that could be implemented directly or used to generate OpenAPI/Swagger documentation. Focus on clarity, consistency, and practical implementation details.

Variables to Customize

[APPLICATION_TYPE]

The type of application (e.g., e-commerce, social media, task management)

Example: task management

[RESOURCE_NAME]

The main resource/entity for the API endpoints

Example: tasks

[FRAMEWORK_LANGUAGE]

The programming framework or language preference

Example: Node.js with Express

Example Output

# Task Management API Endpoints ## Tasks Resource ### GET /api/v1/tasks **Description**: Retrieve all tasks with optional filtering and pagination **Query Parameters**: - `status` (optional): filter by status (pending, completed, in-progress) - `priority` (optional): filter by priority (low, medium, high) - `page` (optional): page number for pagination (default: 1) - `limit` (optional): items per page (default: 20, max: 100) - `sort` (optional): sort field (created_at, priority, due_date) **Response (200)**: ```json { "data": [ { "id": 1, "title": "Complete project proposal", "description": "Draft and review the Q4 project proposal", "status": "pending", "priority": "high", "due_date": "2024-01-15T10:00:00Z", "created_at": "2024-01-01T09:00:00Z", "updated_at": "2024-01-01T09:00:00Z" } ], "pagination": { "page": 1, "limit": 20, "total": 45, "pages": 3 } } ``` ### POST /api/v1/tasks **Description**: Create a new task **Required Fields**: title **Optional Fields**: description, priority, due_date **Request Body**: ```json { "title": "Review API documentation", "description": "Review and update API docs", "priority": "medium", "due_date": "2024-01-20T15:00:00Z" } ``` **Response (201)**: ```json { "data": { "id": 2, "title": "Review API documentation", "status": "pending", "created_at": "2024-01-02T10:30:00Z" } } ``` **Error Response (400)**: ```json { "error": { "message": "Validation failed", "details": ["Title is required"] } } ```

Pro Tips for Best Results

  • Always include proper HTTP status codes for different scenarios (200, 201, 400, 404, 500)
  • Use consistent naming conventions - prefer plural nouns for resources (/tasks not /task)
  • Include pagination parameters for list endpoints to handle large datasets efficiently
  • Define clear error response formats with helpful messages for debugging
  • Consider versioning your API from the start (e.g., /api/v1/) for future maintenance

Tags

Want 500+ Expert Prompts?

Get the Premium Prompt Pack — organized, tested, and ready to use.

Get it for $29

Related Prompts You Might Like