Skip to content

Query Builder

FastEdgy's Query Builder allows you to filter generated API endpoints using the X-Filter header with a simple array-based JSON syntax.

How it works

The Query Builder automatically transforms JSON filters into optimized SQL queries. It integrates seamlessly with endpoints generated by @api_route_model() and supports:

  • Simple Array Syntax: ["field", "operator", "value"]
  • Logical Conditions: Combine filters with AND (&) and OR (|)
  • Relations: Filter by fields on related models using dot notation
  • Field Types: Specific operators based on field type (text, number, date, boolean)
  • Automatic Validation: Field and operator validation built-in

Basic syntax

# Simple rule
GET /api/products/
X-Filter: ["name", "=", "Laptop"]

# AND condition
GET /api/products/
X-Filter: ["&", [["price", ">=", 100], ["is_active", "is true"]]]

# OR condition
GET /api/products/
X-Filter: ["|", [["category", "=", "electronics"], ["category", "=", "books"]]]

Key advantages

  • Performance: Optimized SQL queries generated automatically
  • Security: Strict validation of fields and operators
  • Flexibility: Full support for model relationships
  • Type safety: Operators adapted to each field type
  • Simplicity: One syntax for all use cases

Supported data types

  • Text: CharField, TextField with like, contains, starts with, etc.
  • Numbers: IntegerField, FloatField, DecimalField with comparisons
  • Dates: DateField, DateTimeField with comparisons and between
  • Booleans: BooleanField with is true/false
  • Relations: ForeignKey, OneToOne, ManyToMany
  • Advanced: VectorField for AI (distance calculations), PointField for geospatial queries

Get started

Ready to use Query Builder in your APIs? Learn how to implement it:

Usage Guide