
lectio-api
io.github.asachs01/lectio-api
Lectionary readings (RCL, BCP Daily Office, Catholic) and liturgical calendar tools.
Documentation
Lectio API โ Revised Common Lectionary, Daily Office, and Catholic Lectionary API
Lectio API is a free, open-source Revised Common Lectionary API, liturgical calendar API, Book of Common Prayer Daily Office API, and Catholic lectionary API. Churches, apps, and assistants can fetch today's readings, a date's lectionary, or the current RCL year (A, B, or C) over HTTP.
curl "https://lectio-api.org/api/v1/readings/today?tradition=rcl&tz=America/New_York"
Interactive docs live at lectio-api.org/api/docs. The FAQ covers today's readings, the current RCL year, and the Daily Office (also in docs/FAQ.md). Machine-readable entry points: OpenAPI, llms.txt. A Model Context Protocol server is included for assistants (package). Built with Node.js, Express, and TypeScript.
๐ Features
- Multiple Lectionary Traditions: Support for RCL, Catholic, Episcopal/Anglican, and Lutheran traditions
- Daily Readings: Get readings for any specific date or today's readings
- Liturgical Calendar: Complete calendar information with seasons and special days
- OpenAPI 3.0 Specification: Interactive API documentation with Swagger UI
- TypeScript: Full type safety and modern development experience
- Comprehensive Testing: Unit, integration, and end-to-end tests
- Modern Architecture: Clean separation of concerns with controllers, services, and middleware
- Performance Optimized: Built-in caching, compression, and rate limiting
- Production Ready: Logging, monitoring, and deployment configuration
MCP server
A Model Context Protocol server is included in mcp-server/ and is served over official Streamable HTTP at https://lectio-api.org/mcp once this change is deployed. The health check is at /mcp/health. Local stdio (Claude Desktop, Cursor, MCPB) still works from the mcp-server package.
Canonical tools, all snake_case verb_noun, sharing date, tz, and tradition where they apply:
| Tool | Purpose |
|---|---|
get_readings | Readings for today, a YYYY-MM-DD date, or a startDate/endDate range |
get_calendar | Season, cycle, year overview, feast lookup, upcoming holy days, or factual context for a date |
list_traditions | Metadata for rcl, catholic, episcopal, and bcp |
search_lectionary | Find readings by season or feast name (not by scripture reference) |
Deprecated aliases kept for one release: explore_calendar โ get_calendar, analyze_liturgical_context โ get_calendar with focus=context. Resources include lectionary://today and lectionary://traditions. Prompts include prepare_sermon_readings. See mcp-server/README.md for configuration, the tool mapping, and the registry server.json (not published until you run mcp-publisher).
๐ Prerequisites
- Node.js 20.0.0 or higher
- npm or yarn
- PostgreSQL 12+ (for production)
- Redis (for caching, optional)
๐ ๏ธ Installation
- Clone the repository:
git clone https://github.com/asachs01/lectio-api.git
cd lectionary-api
- Install dependencies:
npm install
- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration
- Start the development server:
npm run dev
The API will be available at http://localhost:3000
๐ API Documentation
Documentation Location
All detailed documentation is located in the /docs directory:
- FAQ:
/docs/FAQ.mdโ Today's readings, the current RCL year, Daily Office, and traditions (also at https://lectio-api.org/faq) - Database Documentation:
/docs/DATABASE_*.md- Schema, setup, and optimization guides - Observability:
/docs/OBSERVABILITY.md- Monitoring and telemetry setup - Migration Guide:
/docs/MIGRATION_GUIDE.md- Database migration procedures - Entity Diagram:
/docs/ENTITY_DIAGRAM.md- Database relationship diagrams
๐ Interactive API Documentation
Once the server is running, access the interactive API documentation at:
- Swagger UI:
http://localhost:3000/api/docs - OpenAPI JSON:
http://localhost:3000/api/docs.json
๐ง API Endpoints
Health Check
GET /health- Health status of the API
Traditions
GET /api/v1/traditions- Get all lectionary traditionsGET /api/v1/traditions/:id- Get specific traditionGET /api/v1/traditions/:id/seasons- Get seasons for a tradition
Readings
GET /api/v1/readings/today- Get today's readingsGET /api/v1/readings?date=YYYY-MM-DD- Get readings for a specific dateGET /api/v1/readings/range?start=YYYY-MM-DD&end=YYYY-MM-DD- Get readings for a date range
Calendar
GET /api/v1/calendar/current- Get current liturgical calendar infoGET /api/v1/calendar/:year- Get calendar for a specific yearGET /api/v1/calendar/:year/seasons- Get seasons for a year
๐งช Testing
# Run all tests
npm test
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch
# Run type checking
npm run typecheck
# Run linting
npm run lint
๐๏ธ Building for Production
# Build the application
npm run build
# Start production server
npm start
๐ Environment Variables
Key environment variables (see .env.example for full list):
NODE_ENV=production
PORT=3000
DB_HOST=localhost
DB_PORT=5432
DB_NAME=lectionary_api
DB_USERNAME=postgres
DB_PASSWORD=your_password
REDIS_URL=redis://localhost:6379
JWT_SECRET=your_jwt_secret
๐ Project Structure
lectionary-api/
โโโ src/
โ โโโ controllers/ # Route handlers
โ โโโ services/ # Business logic
โ โโโ models/ # Data models
โ โโโ middleware/ # Express middleware
โ โโโ routes/ # API routes
โ โโโ config/ # Configuration files
โ โโโ utils/ # Utility functions
โ โโโ types/ # TypeScript type definitions
โโโ tests/
โ โโโ unit/ # Unit tests
โ โโโ integration/ # Integration tests
โ โโโ e2e/ # End-to-end tests
โโโ docs/ # Documentation
โโโ dist/ # Compiled JavaScript
๐ข Deployment
Docker
# Build Docker image
docker build -t lectionary-api .
# Run with Docker Compose
docker-compose up
DigitalOcean App Platform
This project is configured for automated deployment to DigitalOcean App Platform.
Prerequisites
-
DigitalOcean Account: Create an account at DigitalOcean
-
doctl CLI: Install the DigitalOcean command-line tool:
# macOS brew install doctl # Linux snap install doctl # Or download from: https://docs.digitalocean.com/reference/doctl/how-to/install/ -
Authentication: Configure doctl with your API token:
doctl auth init
Automated Deployment Methods
Method 1: GitHub Actions (Recommended)
The project includes a GitHub Actions workflow that automatically deploys on push to the main branch.
- Fork or push this repository to GitHub
- Add your DigitalOcean API token as a GitHub secret:
- Go to Settings โ Secrets and variables โ Actions
- Add a new secret named
DIGITALOCEAN_ACCESS_TOKEN
- Push to the
mainbranch to trigger deployment
Method 2: Command-Line Deployment
Use the included deployment script for one-command deployment:
# Deploy to DigitalOcean
./scripts/deploy.sh
# View deployment logs
./scripts/deploy.sh logs
# Get app URL
./scripts/deploy.sh url
# Destroy deployment
./scripts/deploy.sh destroy
Method 3: Manual doctl Commands
# Validate app configuration
doctl apps spec validate app.yaml
# Create new app
doctl apps create --spec app.yaml
# Update existing app
APP_ID=$(doctl apps list --format ID,Name --no-header | grep "lectio-api" | awk '{print $1}')
doctl apps update $APP_ID --spec app.yaml
Configuration
The deployment is configured in app.yaml:
- Region: NYC by default
- Instance: Basic (512MB RAM, 1 vCPU)
- Database: Managed PostgreSQL 15
- Cache: Managed Redis 7
- Auto-deploy: Enabled for main branch
Environment Variables
Production secrets should be set in the DigitalOcean dashboard:
- Navigate to your app in the DigitalOcean console
- Go to Settings โ App-Level Environment Variables
- Add the following secrets:
JWT_SECRET: Strong random string (32+ characters)DB_PASSWORD: Will be auto-generated if using managed databaseREDIS_URL: Will be auto-configured if using managed Redis
Post-Deployment Validation
After deployment, validate the API is working:
# Get the app URL
APP_URL=$(doctl apps get <app-id> --format DefaultIngress --no-header)
# Test health endpoint
curl https://$APP_URL/health
# Test API documentation
open https://$APP_URL/api/docs
# Test sample endpoint
curl https://$APP_URL/api/v1/traditions
Monitoring and Logs
# View real-time logs
doctl apps logs <app-id> --follow
# View deployment history
doctl apps list-deployments <app-id>
# Get app metrics
doctl apps get <app-id>
Cost Optimization
The default configuration uses:
- App: Basic instance (~$5/month)
- Database: Dev database (~$15/month)
- Redis: Dev instance (~$15/month)
- Total: ~$35/month
For production workloads, consider:
- Upgrading to Professional instances for auto-scaling
- Using dedicated database nodes for better performance
- Implementing CDN for static assets
๐ค Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Make your changes and add tests
- Run tests:
npm test - Commit your changes:
git commit -m 'Add new feature' - Push to the branch:
git push origin feature/new-feature - Submit a pull request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Inspired by the LectServe project
- Built with modern web technologies and best practices
- Designed for the global church community
For more information, visit the API documentation or contact the development team.
No installation packages available.