A simple TypeScript example demonstrating how to use the ChurchTools API client to interact with your ChurchTools instance.
- Node.js (version 16 or higher)
- Access to a ChurchTools instance
- ChurchTools API credentials (username/password or Login token)
npm installCopy the example environment file:
cp .env.example .envEdit .env and fill in your ChurchTools details:
BASE_URL="https://your-church.church.tools"
USERNAME="your-username"
PASSWORD="your-password"
TOKEN=""Note: You can use either username/password OR a personal access token. If you provide a TOKEN, it will be used instead of username/password.
Replace <YOUR_BASE_URL> in package.json with your actual ChurchTools URL, then
run:
npm run generate-typesThis creates TypeScript definitions for your ChurchTools API.
For development (runs TypeScript directly):
npm run devFor production (compiles and runs):
npm run build
npm startThe example connects to your ChurchTools instance and:
- Authenticates using your credentials
- Calls the
whoamiendpoint - Displays your first name
├── src/
│ ├── index.ts # Main application entry point
│ ├── clients/
│ │ └── churchtools-api.ts # ChurchTools API client wrapper
│ ├── config/
│ │ └── index.ts # Configuration management
│ └── types/
│ └── churchtools-api.ts # Generated API types
├── .env # Your environment variables (create this)
├── .env.example # Environment template
└── package.json # Project configuration
The ChurchToolsApiClient class provides:
whoAmI()- Get current user informationgetAppointments()- Get calendar appointmentsgetCalendarAppointmentsByCalendarId(id)- Get appointments for specific calendar
- Add methods to src/clients/churchtools-api.ts
- Use them in src/index.ts
For more information about the ChurchTools API, visit the ChurchTools API documentation.