Create a basic REST API using FastAPI with automatic documentation and validation
When you need to build a modern, high-performance REST API in Python with automatic documentation, data validation, and type hints.
Create project directory: mkdir fastapi-project && cd fastapi-project
Create virtual environment: python -m venv venv
Activate virtual environment: source venv/bin/activate (Linux/Mac) or venv\Scripts\activate (Windows)
Install FastAPI and Uvicorn: pip install "fastapi[all]" uvicorn
Create main.py file: touch main.py
Add basic API code to main.py: from fastapi import FastAPI from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel): name: str price: float
@app.get("/") def read_root(): return {"Hello": "World"}
@app.get("/items/{item_id}") def read_item(item_id: int, q: str = None): return {"item_id": item_id, "q": q}
@app.post("/items/") def create_item(item: Item): return item
Run the development server: uvicorn main:app --reload
Access API documentation at: http://127.0.0.1:8000/docs
--port 8001 flag)--reload flag requires manual server restarts during developmentnpx skills add Snehal707/create-fastapi-rest-api下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer