Redis OM Python¶
Object mapping, and more, for Redis and Python.
Overview¶
Redis OM Python is a modern object mapping library for Redis that provides high-level abstractions to model and query Redis data with Python. Built on Pydantic for robust data validation, it supports both async and sync operations.
Features¶
Hash & JSON Models¶
Store data as Redis Hashes or JSON documents with automatic serialization.
Powerful Queries¶
Django-like ORM syntax with support for complex queries using RediSearch.
Pydantic Validation¶
Full Pydantic v2 support for data validation and type safety.
Async & Sync¶
Both async (aredis_om) and sync (redis_om) APIs available.
Quick Start¶
Installation¶
Define a Model¶
from redis_om import HashModel, Field
class Customer(HashModel, index=True):
name: str = Field(index=True)
email: str = Field(index=True)
age: int = Field(index=True, sortable=True)
Create and Query¶
# Create a customer
customer = Customer(name="Alice", email="alice@example.com", age=30)
customer.save()
# Find customers by name
results = Customer.find(Customer.name == "Alice").all()
Requirements¶
- Python 3.10+
- Redis 8 (recommended) or Redis Stack — see Redis Setup
Learn More¶
- Getting Started - Full tutorial to get up and running
- Redis Setup - Choose and connect to Redis
- Models - Deep dive into model definition and field types
- FastAPI Integration - Build APIs with Redis OM
Upgrading from 0.x?
See the Migration Guide for breaking changes and upgrade instructions.