Gemini Prompt for Creating a REST API
Creating a REST API is a fundamental skill in modern development, but it involves many architectural decisions: framework choice, endpoint structure, authentication handling, data validation, and documentation. Google Gemini excels at generating structured code and can guide you through every step of this process. By using a well-designed prompt, you get not only the skeleton of your API but also built-in best practices from the start: appropriate HTTP codes, centralized error handling, security middleware, and layered architecture. Whether you're building a microservice for a personal project or an enterprise API meant to handle thousands of requests, Gemini adapts its response to the requested complexity level. The major advantage is time saved on the scaffolding phase: instead of spending hours manually configuring each component, you get a solid and consistent foundation in seconds, which you can then customize to your specific business needs.
The prompt
Act as a senior backend architect specialized in REST API design. Create a complete REST API to manage [RESOURCE, e.g., products] with the following specifications:
Tech stack: [Node.js/Express | Python/FastAPI | Java/Spring Boot]
Database: [PostgreSQL | MongoDB | MySQL]
Required endpoints:
- GET /api/[resource] — Paginated list with filters and sorting
- GET /api/[resource]/:id — Resource details
- POST /api/[resource] — Creation with validation
- PUT /api/[resource]/:id — Full update
- PATCH /api/[resource]/:id — Partial update
- DELETE /api/[resource]/:id — Deletion (soft delete)
Technical requirements:
- Layered architecture (routes → controllers → services → repositories)
- Input validation with typed schemas
- Centralized error handling with appropriate HTTP codes
- JWT authentication middleware
- Pagination, filtering, and sorting on list endpoints
- Configured rate limiting and CORS
- Auto-generated OpenAPI/Swagger documentation
- Environment variables for configuration
For each file, provide complete commented code, the project tree, installation commands, and an example .env file. Also include 3 example curl requests to test the main endpoints.
Personalize this prompt with Léa
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Why it works
This prompt works due to the precise expert role attribution that activates Gemini's architectural knowledge, combined with a structured list of requirements that leaves no ambiguity about the expected deliverable. The explicit mention of layered architecture and patterns like soft delete or pagination forces the model to produce production-quality code rather than a simple tutorial. Finally, the request for complete files with project tree and installation commands guarantees a directly usable result.
Expected result
Variants by level
FAQ
Which framework does Gemini most often recommend for creating a REST API?
How to ask Gemini to properly handle errors in the API?
Can Gemini be used to also generate tests for the REST API?
Related prompts
How to use this prompt
- Copy the prompt with the button above.
- Paste it into ChatGPT, Claude or your favorite AI assistant.
- Replace the bracketed variables with your details, then refine the result.
About Prompt Guide
Prompt Guide is a free library of 4800+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.
More prompts to explore
Gemini Prompt for Creating an Advertising Script
Creating a compelling advertising script requires creativity, knowledge of persuasion mechanisms, and mastery of format constraints. Google's AI model, Gemini, excels at generating marketing content...
Gemini Prompt for Creating an Email Campaign
Gemini, Google's artificial intelligence model, excels at creating email campaigns thanks to its ability to analyze complex marketing data and generate persuasive content adapted to each audience segment.
Gemini Prompt for Creating an FAQ
Creating a relevant and comprehensive FAQ is a strategic exercise for any website, service, or product. A good FAQ anticipates user questions,
Gemini Prompt for Creating E2E Tests
End-to-end (E2E) tests are essential to ensure the overall functioning of an application, but writing them is often time-consuming and repetitive. Gemini, Google's AI model, excels in generating structured code and can significantly speed up the creation of comprehensive E2E test suites. By providing the technical context of your application — technology stack, critical user journeys, and the test framework used — Gemini can produce robust test scenarios covering both main flows and edge cases. Whether you use Playwright, Cypress, or Selenium, the AI adapts to your framework's conventions to generate directly usable code. The prompt engineering approach allows you to specify the desired coverage level, preferred selector patterns, and test data management strategy. The result: maintainable, readable tests aligned with your team's best practices, produced in a fraction of the usual time.
Gemini Prompt for Creating Illustrations
Gemini, Google's artificial intelligence model, offers remarkable capabilities for creating original and detailed illustrations. Whether you are a...
Gemini Prompt for Creating Images
Gemini, Google's artificial intelligence model, now integrates advanced image generation capabilities directly into its responses. Unlike classic image generators, Gemini combines deep language understanding with visual generation, allowing you to create images from highly detailed text descriptions in English. Whether you're a graphic designer looking to quickly prototype concepts, an entrepreneur creating visuals for social media, or simply curious about AI-assisted creation, mastering the art of prompting Gemini will save you considerable time. The key lies in the precision of your instructions: artistic style, composition, lighting, color palette, and overall atmosphere are all parameters that Gemini can interpret to produce striking results. In this guide, you'll discover an optimized main prompt as well as variants suited to your skill level, to get the most out of image generation with Gemini.
Go further
Get new prompts every week
Join our newsletter.