API Overview
The Studley AI API provides programmatic access to our AI-powered study platform. Build integrations, automate workflows, and create custom learning experiences using our comprehensive REST API.Base URL
All API requests are made to:API Architecture
Studley AI uses a Next.js App Router architecture with API routes organized by feature:Core API Endpoints
- Authentication (
/api/auth/*) - User authentication, login, signup, and session management - AI Tutor (
/api/ai-tutor/*) - Interactive AI tutoring sessions and chat - AI Workspace (
/api/ai-workspace/*) - AI-powered workspace sessions - Content Generation - Generate quizzes, flashcards, notes, and study materials
- Materials (
/api/materials/*) - Document upload and management - Dashboard (
/api/dashboard/*) - User dashboard data and analytics - Tools (
/api/tools/*) - Specialized study tools and utilities
Request Format
Content Type
All API requests should use JSON format:HTTP Methods
The API uses standard HTTP methods:GET- Retrieve resourcesPOST- Create resources or execute actionsPUT- Update resourcesDELETE- Remove resources
Example Request
Response Format
All API responses are returned in JSON format:Success Response
Error Response
HTTP Status Codes
The API uses standard HTTP status codes:| Code | Description |
|---|---|
200 | Success - Request completed successfully |
400 | Bad Request - Invalid parameters or missing required fields |
401 | Unauthorized - Authentication required or invalid credentials |
403 | Forbidden - Authenticated but insufficient permissions |
404 | Not Found - Resource does not exist |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error - Server-side error occurred |
Rate Limiting
To ensure fair usage and platform stability, the Studley AI API implements rate limiting on content generation endpoints.Rate Limit Configuration
- Limit: 10 generations per 5-minute window
- Window: Rolling 5-minute window
- Cooldown: 5 minutes after hitting the limit
How It Works
Rate limits are tracked per user identifier (user ID for authenticated requests, IP address for anonymous requests). The system uses a sliding window algorithm:- Each generation request is recorded with a timestamp
- Recent requests within the 5-minute window are counted
- If the count exceeds 10, subsequent requests are rejected
- Once requests age beyond the 5-minute window, they no longer count toward the limit
Rate Limit Headers
When you hit a rate limit, the response includes:Best Practices
Implement exponential backoff when receiving rate limit errors. Use the
retryAfter value to determine when to retry your request.Pagination
Endpoints that return lists of items support pagination:Pagination Parameters
page- Page number (default: 1)limit- Items per page (default: 20, max: 100)
Pagination Response
Error Handling
The API uses consistent error response formats:Common Error Codes
INVALID_REQUEST- Malformed request or missing required parametersAUTHENTICATION_REQUIRED- User must be authenticatedRATE_LIMIT_EXCEEDED- Too many requestsRESOURCE_NOT_FOUND- Requested resource does not existINTERNAL_ERROR- Server-side error
Versioning
The Studley AI API is currently in version 1. All endpoints are stable unless marked as beta. Breaking changes will be communicated with advance notice.
/v2/api/*).
Next Steps
Authentication
Learn how to authenticate API requests
AI Tutor API
Build AI-powered tutoring experiences
Content Generation
Generate quizzes, flashcards, and study materials
Rate Limits
Understanding rate limits and best practices