P
💻DeveloppementAdvancedAll AIs

Create a Complete REST API from A to Z

A complete prompt to generate a professional REST API with authentication, validation, documentation, and integrated tests.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un développeur backend senior spécialisé en conception d'API REST. Crée une API REST complète pour [DESCRIPTION DU PROJET] en utilisant [LANGAGE/FRAMEWORK] avec les spécifications suivantes :

  1. Architecture : Structure le projet selon les bonnes pratiques (controllers, services, repositories, middlewares). Fournis l'arborescence complète des fichiers.

  2. Modèles de données : Définis les entités principales avec leurs relations (one-to-many, many-to-many). Inclus les schémas de base de données avec les types de champs, contraintes et index.

  3. Endpoints CRUD : Pour chaque ressource, implémente :

    • GET (liste paginée avec filtres et tri)
    • GET by ID (avec relations imbriquées)
    • POST (avec validation des données entrantes)
    • PUT/PATCH (mise à jour partielle et complète)
    • DELETE (soft delete si pertinent)
  4. Authentification & Autorisation : Implémente JWT avec refresh tokens, middleware d'authentification, et gestion des rôles (admin, utilisateur, lecture seule).

  5. Validation & Gestion d'erreurs : Crée un système centralisé de validation des entrées et un handler d'erreurs global retournant des réponses JSON cohérentes avec codes HTTP appropriés.

  6. Middleware : Ajoute rate limiting, CORS, logging des requêtes, et compression des réponses.

  7. Documentation : Génère une documentation Swagger/OpenAPI pour chaque endpoint avec exemples de requêtes et réponses.

  8. Tests : Écris des tests unitaires pour les services et des tests d'intégration pour les endpoints principaux.

Pour chaque fichier, fournis le code complet et commenté. Commence par le setup du projet, puis implémente chaque couche progressivement.

Personalize this prompt with Léa

Answer 3 questions and Léa tailors the prompt to your situation.

Why this prompt works

<p>This prompt guides the AI to produce a production-quality REST API covering all essential layers. By specifying <strong>[PROJECT DESCRIPTION]</strong> (e.g., "a collaborative task management platform") and <strong>[LANGUAGE/FRAMEWORK]</strong> (e.g., "Node.js with Express" or "Python with FastAPI"), you get code adapted to your exact context.</p><p>The 8-point structure forces the AI to not forget anything: from file architecture to tests, through security and documentation. Each section is detailed enough to avoid superficial answers, while letting the AI adapt patterns to your tech stack.</p><p><strong>Usage tip</strong>: for complex projects, first submit the complete prompt to get the overall architecture, then request detailed implementation section by section. You can also add specific constraints such as a particular database (PostgreSQL, MongoDB), a target hosting (Docker, serverless), or performance requirements (Redis cache, cursor-based pagination).</p>

Use Cases

Create the backend of a SaaS application from scratchQuickly prototype an API for a startup MVPModernize a legacy API into a clean REST architecturePrepare a backend project for a technical interview

Expected Output

A complete REST API project with file tree, commented source code for each layer (routes, controllers, services, models), JWT authentication setup, validation middleware, Swagger documentation, and unit and integration test examples.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

  • LéaAI

    Pour un résultat optimal, précisez le framework de validation (ex : Zod, Joi, FluentValidation) et le type de base de données (SQL avec ORM ou NoSQL) dans la description. Cela permet d'obtenir un code exploitant les bonnes librairies du langage choisi.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementBeginnerAll AIs

Create Database Seed Data

Generate realistic test data for development

0181
💻DeveloppementIntermediateAll AIs

Stable Diffusion Prompt for Building a REST API

Stable Diffusion, known for its powerful image generation, can play an unexpected yet valuable role in building a REST API. While the tool doesn't generate code directly, it excels at producing architecture diagrams, data flow charts, documentation interface mockups, and technical visuals that support API development. By visualizing your endpoint structure, resource relationships, and authentication flows, you speed up the design phase and improve communication within your team. A well-crafted prompt yields clear visual representations of your REST architecture: entity-relationship diagrams, routing schemas, HTTP request pipeline illustrations, or monitoring dashboard mockups. These visual assets become living documentation tools that complement your OpenAPI specification. In this guide, we offer optimized prompts for generating professional technical visuals related to REST API design, from architecture diagrams to documentation illustrations and data model representations.

0180
💻DeveloppementIntermediateAll AIs

Set up dependency vulnerability scanning

Automate dependency scanning

0214
💻DeveloppementIntermediateAll AIs

GitHub Copilot Prompt for Creating a REST API

GitHub Copilot has become an essential assistant for developers looking to accelerate the creation of REST APIs. Thanks to its direct integration into the code editor, it understands the context of your project and generates structured code in real time. Whether you work with Node.js and Express, Python and FastAPI, or Java and Spring Boot, Copilot adapts to your tech stack to produce endpoints conforming to REST conventions. The main challenge lies in formulating the prompt: a well-structured prompt yields a complete API with data validation, error handling, authentication, and documentation. A vague prompt, on the other hand, will produce generic code requiring many adjustments. In this guide, we offer an optimized prompt that fully leverages GitHub Copilot's capabilities to generate a professional, testable, production-ready REST API. You will also discover variants adapted to your experience level as well as practical tips to get the most out of this tool on a daily basis.

0161