Skip to main content

Introduction

The Campus API provides programmatic access to all platform features including posts, comments, spaces, groups, events, and materials. The API is built on top of PocketBase, which provides a RESTful interface with automatic CRUD operations for all collections.

Base URL

The API base URL depends on your deployment:
  • Development: http://localhost:8090/api
  • Production: https://your-domain.com/api
The PocketBase URL can be configured via the POCKETBASE_URL environment variable for server-side requests.

Authentication

All API endpoints require authentication using PocketBase’s authentication system. Include the authentication token in your requests:
curl -X GET "https://your-domain.com/api/posts" \
  -H "Authorization: Bearer YOUR_AUTH_TOKEN"
See the Authentication page for details on obtaining and managing tokens.

PocketBase REST API

Campus leverages the full PocketBase REST API for direct database access. In addition to the custom endpoints documented here, you can use PocketBase’s standard collection endpoints:
  • GET /api/collections/{collection}/records - List records
  • GET /api/collections/{collection}/records/{id} - Get single record
  • POST /api/collections/{collection}/records - Create record
  • PATCH /api/collections/{collection}/records/{id} - Update record
  • DELETE /api/collections/{collection}/records/{id} - Delete record
Refer to the PocketBase API documentation for complete details.

Collections

Campus uses the following main collections:
  • users - User accounts and authentication
  • profiles - Extended user profile information
  • posts - User-generated posts and content
  • comments - Comments on posts
  • likes - Post likes and reactions
  • spaces - Community spaces
  • space_members - Space membership
  • groups - Groups within spaces
  • group_members - Group membership
  • events - Calendar events
  • event_participants - Event RSVPs
  • materials - Educational materials and files
  • material_access_logs - Material access tracking
  • notifications - User notifications
  • reports - Content moderation reports

Response Format

All API responses follow PocketBase’s standard format:
{
  "id": "RECORD_ID",
  "collectionId": "COLLECTION_ID",
  "collectionName": "collection_name",
  "created": "2026-01-01 00:00:00.000Z",
  "updated": "2026-01-01 00:00:00.000Z",
  // ... collection-specific fields
}
List endpoints return paginated results:
{
  "page": 1,
  "perPage": 30,
  "totalItems": 100,
  "totalPages": 4,
  "items": [
    // ... array of records
  ]
}

Error Handling

Errors follow PocketBase’s format with appropriate HTTP status codes:
{
  "code": 400,
  "message": "Error message",
  "data": {
    // Additional error details
  }
}
Common status codes:
  • 200 - Success
  • 201 - Created
  • 400 - Bad Request
  • 401 - Unauthorized
  • 403 - Forbidden
  • 404 - Not Found
  • 409 - Conflict
  • 500 - Internal Server Error

Rate Limiting

Rate limiting is handled by PocketBase. Consult your PocketBase configuration for specific limits.

SDK and Type Safety

Campus includes TypeScript type definitions generated from PocketBase schema:
import type { PostsRecord, CommentsRecord } from './pocketbase-types'
See pocketbase-types.ts for complete type definitions of all collections.

Build docs developers (and LLMs) love