API Architecture
Sakai’s API is built on several complementary layers:1. Modern REST API (WebAPI)
The WebAPI module provides modern Spring-based REST controllers located inwebapi/src/main/java/org/sakaiproject/webapi/controllers/. These endpoints follow RESTful conventions and return JSON responses.
Base Path: /api/
Key Controllers:
LoginController- Authentication and session managementUserController- User information and rolesSitesController- Site/course informationDashboardController- Dashboard dataCalendarController- Calendar eventsAnnouncementsController- AnnouncementsGradesController- Gradebook accessForumsController- Forum discussionsTasksController- Task managementNotificationsController- User notifications
2. Entity Broker System
The Entity Broker provides a flexible, capability-based system for exposing entities via REST APIs. Located in theentitybroker/ module, it allows tools to register entity providers that automatically expose CRUD operations.
Base Path: /direct/
Key Features:
- Auto-registration of entity providers
- CRUD operations (Create, Read, Update, Delete)
- Custom actions on entities
- Multiple output formats (JSON, XML, HTML)
- Search and filtering capabilities
- Batch operations
/direct/{prefix}/{id}/{action}.{format}
Examples:
/direct/assignment/123.json- Get assignment with ID 123 as JSON/direct/site/site123/pages.xml- Get pages for site as XML/direct/user/current.json- Get current user as JSON
3. Java Kernel Services
The Kernel provides core services that both APIs use internally: Session Management (SessionManager):
UserDirectoryService):
- User authentication and management
- User profile access
- Preferences management
SiteService):
- Course/project site management
- Site membership and permissions
- Tool configuration within sites
ContentHostingService):
- File upload and storage
- Resource management
- Collections and folders
AuthzGroupService, SecurityService):
- Permission checking
- Role management
- Security assertions
API Request Flow
All API requests must include a valid Sakai session. The session is typically established via the
/api/login endpoint and maintained using session cookies.- Authentication: Client authenticates via
/api/login - Session Creation: Server creates session and returns session ID
- Session Cookie: Client includes
JSESSIONIDcookie in subsequent requests - Request Processing: API controllers validate session and process request
- Response: Server returns JSON/XML response
Available Endpoints
Sites and Courses
- List of user’s sites/courses
- Site tools and configuration
- Pinned sites
- Site notifications
User Information
Access user profiles, roles, and permissions:/api/user/roles- Check user roles/direct/user/{userId}.json- Get user profile
Calendar and Events
Manage calendar events and schedules:/api/calendar/*- Calendar operations/direct/calendar/*- Calendar entity access
Gradebook
Access grades and assignments:/api/grades/*- Gradebook data/direct/gradebook/*- Gradebook entities
Data Formats
Both API layers support multiple data formats: JSON (Default):Error Handling
APIs use standard HTTP status codes:- 200 OK - Successful request
- 201 Created - Resource created successfully
- 400 Bad Request - Invalid request parameters
- 401 Unauthorized - Missing or invalid authentication
- 403 Forbidden - Insufficient permissions
- 404 Not Found - Resource not found
- 500 Internal Server Error - Server error
Security Considerations
Important: All API endpoints respect Sakai’s security model. Users can only access resources they have permission to view or modify.
- Session-based authentication required
- Permission checks on all operations
- Site membership validation
- Resource-level access control
- Audit logging of API access
Next Steps
- Authentication - Learn about API authentication methods
- Entity Broker Guide - Deep dive into Entity Broker
- WebAPI Reference - Complete WebAPI endpoint reference