The official OpenAPI 3.1 specification for the ApostropheCMS REST API. Explore endpoints interactively, mock the API for rapid prototyping, or generate type-safe SDKs in your preferred language.
This repository contains the core ApostropheCMS OpenAPI specification - the base REST API that every Apostrophe project inherits. It documents standard endpoints for pages, pieces, assets, users, and workflow management.
Think of it as the foundation, not the complete building. Your project likely has custom piece types (like products, events, or blog posts) and project-specific routes that aren't included here.
⚠️ Important: This repository contains the API specification, not ApostropheCMS itself. For the CMS, visit the main ApostropheCMS repository.
To generate a specification that includes both core and your custom modules:
- Install @apostrophecms/openapi-generator in your Apostrophe project
- Run the generator from your project directory
- Use the generated specification for SDK creation and documentation specific to your application
Use this repository to:
- Explore the API - Browse all core endpoints in interactive documentation
- Design API contracts - Use as a foundation for planning new projects and features
- Mock for prototyping - Build frontend apps before your backend is ready
- Generate SDKs - Create client libraries in TypeScript, Python, PHP, and more
- Learn conventions - Understand ApostropheCMS API patterns and best practices
View the complete API documentation with Swagger UI:
# Install dependencies
npm install
# Open interactive documentation
npm run docs:openThis opens a browser interface where you can browse endpoints, view schemas, and test API calls.
Note: You will have to have an ApostropheCMS project running before testing the endpoints.
You can authenticate in Swagger UI using either an API key or bearer token:
The simplest method - requires one-time setup in your project:
- Add an API key to your ApostropheCMS project in
modules/@apostrophecms/express/index.js:
export default {
options: {
apiKeys: {
myTestKey: {
role: 'admin'
}
}
}
};-
In Swagger UI: Click "Authorize" → scroll to "ApiKeyAuth" → enter
myTestKey -
Test away: Execute requests directly from the documentation
No project configuration needed - use your existing login credentials:
- Generate a token: In Swagger UI, find the
POST /@apostrophecms/login/loginendpoint and execute it with:
{
"username": "your-username",
"password": "your-password"
}-
Copy the token: From the response, copy only the token value (not the full JSON).
- Example: if response is
{"token": "abc123xyz"}, copy onlyabc123xyz
- Example: if response is
-
Authorize: Click "Authorize" → scroll to "BearerAuth" → paste the token value
The token will be automatically sent as Authorization: Bearer {your-token} with each request.
Use this specification to design and prototype before writing code - perfect for parallel frontend/backend development.
When starting a new project or feature:
- Start with the core spec as your foundation
- Manually add your custom endpoints following the same patterns used in the core spec
- Share the spec with your team as the contract between frontend and backend
- Develop in parallel - frontend uses mocks, backend implements to match the spec
Create a fully functional mock server without any backend code:
# Install Prism globally
npm install -g @stoplight/prism-cli
# Mock the core API
prism mock apostrophecms-openapi.yaml
# Or mock your project-specific spec
prism mock my-project-openapi.yaml
# Mock server runs at http://localhost:4010The mock server returns realistic example responses, letting frontend developers build and test their applications before the backend is ready.
Use cases:
- Prototype new features without backend changes
- Frontend development while backend is in progress
- Demo UIs to stakeholders before implementation
- Test frontend error handling and edge cases
Note: The @apostrophecms/openapi-generator generates documentation for existing ApostropheCMS projects - it documents what you've already built. For true API-first design, you'd manually extend this core spec before implementation.
Create a client library in your preferred language (requires Java runtime):
# TypeScript/JavaScript
npm run generate:typescript
# Python
npm run generate:python
# PHP
npm run generate:phpThe generated SDK will be in the examples/ folder, complete with documentation and usage examples.
After generating an SDK, you'll find complete documentation in the generated folder including a README with examples for every endpoint.
# Build the SDK
cd examples/typescript
npm install && npm run build
# Install in your project
npm install /path/to/examples/typescriptBasic usage:
import { Configuration, PagesApi } from 'apostrophecms-client';
const config = new Configuration({
basePath: 'http://localhost:3000/api/v1',
apiKey: process.env.APOSTROPHE_API_KEY
});
const pages = new PagesApi(config);
// Get page tree
const tree = await pages.pageGet();
console.log(tree.data);
// Create a page
const newPage = await pages.pagePost({
title: 'Welcome',
type: 'default-page',
slug: '/welcome'
});See the generated examples/typescript/README.md for complete documentation, including authentication options, error handling, and examples for all endpoints.
apostrophecms-openapi.yaml- Core ApostropheCMS REST API specificationexamples/apostrophecms-piece-examples.yaml- Sample piece types for learning
examples/typescript/- Pre-generated TypeScript SDK with full documentation- Includes comprehensive README with examples for every endpoint
| Command | Purpose |
|---|---|
npm run docs:open |
Open core API documentation |
npm run example-docs:open |
Open example piece documentation |
npm run validate |
Validate OpenAPI specification |
npm run lint |
Lint specification with Spectral |
npm test |
Run validation and linting |
npm run generate:typescript |
Generate TypeScript SDK |
npm run generate:python |
Generate Python SDK |
npm run generate:php |
Generate PHP SDK |
Ensure specification quality:
npm run validate # Check OpenAPI structure
npm run lint # Lint with Spectral
npm test # Run both checksThe specification follows OpenAPI 3.1 standards and uses Spectral for linting.
This repository uses OpenAPI Generator to create client libraries.
# Python
npm run generate:python
# PHP
npm run generate:php
# See full list of supported languages:
# https://openapi-generator.tech/docs/generators/Each generated SDK includes:
- Complete API client with type definitions
- README with usage examples
- Documentation for all endpoints
- Authentication configuration helpers
Check the generated SDK's README for language-specific setup and usage instructions.
We welcome contributions! To contribute:
- Fork the repository and create a feature branch
- Make changes to the OpenAPI specification
- Run
npm testto validate your changes - Submit a pull request with a clear description
Please ensure your changes:
- Follow OpenAPI 3.1 standards
- Include appropriate examples
- Pass validation and linting
- Update documentation as needed
- Discord Community - Get help from other developers
- GitHub Issues - Report bugs or request features
- Professional Support - Enterprise support and consulting
- Specification Version: Follows semantic versioning (current:
1.0.0) - API Compatibility: The
x-apostrophe.cmsVersionfield indicates compatible ApostropheCMS versions - Breaking Changes: Major version updates indicate breaking API changes
Made with ❤️ by the ApostropheCMS team.
Found this useful? Give us a star! ⭐