Reference
API Documentation
API Documentation
Welcome to the ObjectQL API Reference.
ObjectQL provides a unified query protocol that can be exposed through multiple API styles. All styles share the same underlying metadata, validation rules, and permissions system.
Design Principles
- Protocol-First: All APIs accept/return structured JSON, never raw SQL.
- Type-Safe: Full TypeScript definitions for all requests/responses.
- AI-Friendly: Queries include optional
ai_contextfor explainability, designed for LLM generation. - Secure: Built-in validation, permission checks, SQL injection prevention.
- Universal: Same query works across MongoDB, PostgreSQL, SQLite.
Unified ID Field
ObjectQL uses a unified id field as the primary key across all database drivers:
- Consistent Naming: Always use
idin API requests and responses. - Database Agnostic: The driver handles mapping (e.g. to
_idin Mongo) automatically. - String Based: IDs are always strings to ensure JSON compatibility.
API Styles Overview
| API Style | Use Case | Endpoint Pattern | Docs |
|---|---|---|---|
| JSON-RPC | Universal client, AI agents, microservices | POST /api/objectql | Read Guide |
| REST | Traditional web apps, mobile apps | /api/data/:object | Read Guide |
| GraphQL | Modern frontends with complex data requirements | POST /api/graphql | Read Guide |
| Metadata | Admin interfaces, schema discovery | /api/metadata/* | Read Guide |
🚀 Want to optimize your queries?
Check out the Query Best Practices Guide for performance optimization strategies, detailed comparisons, and recommendations to help you choose the best approach for your use case.
Quick Links
Core Concepts
- Custom API Routes ⭐ NEW
- Authentication & Security
- Error Handling
- Rate Limiting
- Unified API Response Format
Advanced Features
Quick Start
Basic Query (JSON-RPC)
Create Record
Auto-Generated Specs
For automated tool ingestion, use the following endpoints:
- OpenAPI / Swagger:
/openapi.json(Used by/docsUI) - GraphQL Schema:
/api/graphql/schema