API Reference
Pydantic
Python data validation using type annotations with parsing, serialization, and JSON schema export.
Official Documentation ↗CompatibilityThis documentation covers version
v2.9. Check the official docs for the latest API surface.Installation
pip
pip install pydanticMethods
No methods match this filter.
Pydantic is the most widely used data validation library for Python. It uses Python type annotations to define data models, then validates, parses, and serializes data with rich error messages and JSON Schema export.
Key Features
- Type-based validation: Annotated fields drive rules
- Fast: Core validation in Rust
- Serialization: model_dump and model_dump_json
- JSON Schema: Export for OpenAPI and docs
- Ecosystem: Powers FastAPI and many tools
Security notes
Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://docs.pydantic.dev/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:51:58.889Z.
- Validate untrusted data and build agents you’ll actually ship to production using our Python libraries. (https://docs.pydantic.dev/)
FAQ
- What changed between Pydantic v1 and v2?
- Pydantic v2 is rewritten in Rust for 5-50x speed, with new method names like model_validate and model_dump, stricter validation, and a new validator API. v1 methods are deprecated but available via the v1 namespace for migration.
- How does Pydantic integrate with FastAPI?
- FastAPI uses Pydantic models for request and response validation, generating OpenAPI schemas automatically. Define a model, use it as a parameter type, and FastAPI validates input and serializes output.
- Can Pydantic validate nested and custom types?
- Yes. Models can nest other models, use enums, dates, URLs, and custom annotated types. Use Annotated with constraints or custom validators for domain-specific rules.
Report a problem with this API docOpens a pre-filled issue on GitHub.