Introduction
OneGlance provides a type-safe tRPC API for tracking how AI providers mention your brand. The API uses tRPC for end-to-end type safety and superjson for data serialization, supporting advanced JavaScript types like Date, Map, and Set.Authentication
The OneGlance API uses session-based authentication powered by Better Auth. All API requests must include valid session credentials.Authentication Types
The API has three authentication levels:- Public Procedures: No authentication required
- Protected Procedures: Requires authenticated user session
- Authorized Workspace Procedures: Requires authentication and workspace membership
Making Authenticated Requests
Authentication is handled automatically through session cookies when using the tRPC client. All workspace-specific endpoints require aworkspaceId parameter to identify which workspace the operation applies to.
Request Format
OneGlance uses tRPC which provides type-safe RPC-style calls. There are two types of procedures:Queries
Queries are used for data retrieval (GET operations):Mutations
Mutations are used for data modification (POST/PUT/DELETE operations):Error Handling
The API uses a structured error format with domain-specific error codes:Error Types
- ValidationError: Input validation failed or business rule violated
- AuthError: Authentication or authorization failed
- TRPCError: General tRPC errors (BAD_REQUEST, UNAUTHORIZED, etc.)
Zod Validation Errors
When input validation fails, the error includes azodError field with detailed validation information:
Rate Limits
The API implements rate limiting on specific endpoints to ensure fair usage:| Endpoint | Limit | Window |
|---|---|---|
workspace.create | 3 requests | 1 hour |
workspace.joinByCode | 5 requests | 15 minutes |
prompt.store | 20 requests | 1 minute |
analysis.analyzeMetrics | 10 requests | 1 minute |
agent.run | 3 requests | 1 minute |
TOO_MANY_REQUESTS error.
Data Serialization
The API uses superjson for data serialization, which means:- Date objects are automatically serialized and deserialized
- Special types like Map, Set, BigInt are supported
- Undefined values are preserved (unlike standard JSON)
API Routers
The OneGlance API is organized into the following routers:- Workspace - Manage workspaces, organizations, and team members
- Prompts - Store and retrieve prompts for analysis
- Analysis - Analyze prompts to extract brand mentions and metrics
- Agent - Run automated agents to collect and analyze prompts
Next Steps
Workspace API
Create and manage workspaces
Prompts API
Store and retrieve prompts
Analysis API
Analyze brand mentions
Agent API
Run automated agents