โ† All skills
Tencent SkillHub ยท Developer Tools

FastAPI

Build fast, production-ready Python APIs with type hints, validation, and async support.

skill openclawclawhub Free
0 Downloads
0 Stars
0 Installs
0 Score
High Signal

Build fast, production-ready Python APIs with type hints, validation, and async support.

โฌ‡ 0 downloads โ˜… 0 stars Unverified but indexed

Install for OpenClaw

Quick setup
  1. Download the package from Yavira.
  2. Extract the archive and review SKILL.md first.
  3. Import or place the package into your OpenClaw setup.

Requirements

Target platform
OpenClaw
Install method
Manual import
Extraction
Extract archive
Prerequisites
OpenClaw
Primary doc
SKILL.md

Package facts

Download mode
Yavira redirect
Package format
ZIP package
Source platform
Tencent SkillHub
What's included
SKILL.md

Validation

  • Use the Yavira download entry.
  • Review SKILL.md after the package is downloaded.
  • Confirm the extracted package contains the expected setup assets.

Install with your agent

Agent handoff

Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.

  1. Download the package from Yavira.
  2. Extract it into a folder your agent can access.
  3. Paste one of the prompts below and point your agent at the extracted folder.
New install

I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.

Upgrade existing

I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.

Trust & source

Release facts

Source
Tencent SkillHub
Verification
Indexed source record
Version
1.0.0

Documentation

ClawHub primary doc Primary doc: SKILL.md 9 sections Open source page

Async Traps

Mixing sync database drivers (psycopg2, PyMySQL) in async endpoints blocks the event loop โ€” use async drivers (asyncpg, aiomysql) or run sync code in run_in_executor time.sleep() in async endpoints blocks everything โ€” use await asyncio.sleep() instead CPU-bound work in async endpoints starves other requests โ€” offload to ProcessPoolExecutor or background workers Async endpoints calling sync functions that do I/O still block โ€” the entire call chain must be async

Pydantic Validation

Default values in models become shared mutable state: items: list = [] shares the same list across requests โ€” use Field(default_factory=list) Optional[str] doesn't make a field optional in the request โ€” add = None or use Field(default=None) Pydantic v2 uses model_validate() not parse_obj(), and model_dump() not .dict() โ€” v1 methods are deprecated Use Annotated[str, Field(min_length=1)] for reusable validated types instead of repeating constraints

Dependency Injection

Dependencies run on every request by default โ€” use lru_cache on expensive dependencies or cache in app.state for singletons Depends() without an argument reuses the type hint as the dependency โ€” clean but can confuse readers Nested dependencies form a DAG โ€” if A depends on B and C, and both B and C depend on D, D runs once (cached per-request) yield dependencies for cleanup (DB sessions, file handles) โ€” code after yield runs even if the endpoint raises

Lifespan and Startup

@app.on_event("startup") is deprecated โ€” use lifespan async context manager Store shared resources (DB pool, HTTP client) in app.state during lifespan, not as global variables Lifespan runs once per worker process โ€” with 4 Uvicorn workers you get 4 DB pools from contextlib import asynccontextmanager @asynccontextmanager async def lifespan(app): app.state.db = await create_pool() yield await app.state.db.close() app = FastAPI(lifespan=lifespan)

Request/Response

Return dict from endpoints, not Pydantic models directly โ€” FastAPI handles serialization and it's faster Use status_code=201 on POST endpoints returning created resources โ€” 200 is the default but semantically wrong Response with media_type="text/plain" for non-JSON responses โ€” returning a string still gets JSON-encoded otherwise Set response_model_exclude_unset=True to omit None fields from response โ€” cleaner API output

Error Handling

raise HTTPException(status_code=404) โ€” don't return Response objects for errors, it bypasses middleware Custom exception handlers with @app.exception_handler(CustomError) โ€” but remember they don't catch HTTPException Use detail= for user-facing messages, log the actual error separately โ€” don't leak stack traces

Background Tasks

BackgroundTasks runs after the response is sent but still in the same process โ€” not suitable for long-running jobs Tasks execute sequentially in order added โ€” don't assume parallelism If a background task fails, the client never knows โ€” add your own error handling and alerting

Security

OAuth2PasswordBearer is for documentation only โ€” it doesn't validate tokens, you must implement that in the dependency CORS middleware must come after exception handlers in middleware order โ€” or errors won't have CORS headers Depends(get_current_user) in path operation, not in router โ€” dependencies on routers affect all routes including health checks

Testing

TestClient runs sync even for async endpoints โ€” use httpx.AsyncClient with ASGITransport for true async testing Override dependencies with app.dependency_overrides[get_db] = mock_db โ€” cleaner than monkeypatching TestClient context manager ensures lifespan runs โ€” without with TestClient(app) as client: startup/shutdown hooks don't fire

Category context

Code helpers, APIs, CLIs, browser automation, testing, and developer operations.

Source: Tencent SkillHub

Largest current source with strong distribution and engagement signals.

Package contents

Included in package
1 Docs
  • SKILL.md Primary doc