@growi/sdk-typescript
is a TypeScript SDK automatically generated from the official GROWI OpenAPI specifications using orval. It supports both GROWI API v1 and v3, enabling type-safe API operations.
- π’ Official SDK by the GROWI Development Team
- π Automatic code generation from OpenAPI specifications
- π‘οΈ Type-safe API operations with TypeScript
- π axios-based HTTP client
- π Support for GROWI API v1 and v3
- π― Node.js 18+ support
This SDK is generated from GROWI's official OpenAPI specifications and supports the specifications obtained from the following endpoints:
- API v1: https://docs.growi.org/openapi-spec-apiv1.json
- API v3: https://docs.growi.org/openapi-spec-apiv3.json
The SDK's compatibility depends on the compatibility of GROWI's API specifications. When new API versions are released, the SDK will be automatically updated.
You can install it using npm, yarn, or pnpm:
# npm
npm install @growi/sdk-typescript
# yarn
yarn add @growi/sdk-typescript
# pnpm
pnpm add @growi/sdk-typescript
import { AXIOS_DEFAULT } from '@growi/sdk-typescript';
// Set the base URL of your GROWI instance
AXIOS_DEFAULT.setBaseURL('https://your-growi-instance.com');
// Set authentication token (if needed)
AXIOS_DEFAULT.setAuthorizationHeader('your-api-token');
import apiv3 from '@growi/sdk-typescript/v3';
// Get page list
try {
const pages = await apiv3.getPagesList();
console.log(pages);
} catch (error) {
console.error('Failed to fetch pages:', error);
}
// Get recent pages
try {
const recentPages = await apiv3.getPagesRecent();
console.log(recentPages);
} catch (error) {
console.error('Failed to fetch recent pages:', error);
}
// Using with parameters
const pagesWithParams = await apiv3.getPagesList({
limit: 20,
offset: 0
});
import apiv1 from '@growi/sdk-typescript/v1';
// Search pages
try {
const searchResult = await apiv1.searchPages({ q: 'search term' });
console.log(searchResult);
} catch (error) {
console.error('Failed to search pages:', error);
}
// Get comments
try {
const comments = await apiv1.getComments({ page_id: 'your-page-id' });
console.log(comments);
} catch (error) {
console.error('Failed to fetch comments:', error);
}
src/
βββ utils/
β βββ axios-instance.ts # Axios instance factory
βββ generated/ # Codes generated by Orval
β βββ v1/ # API v1 client
β β βββ index.ts
β β βββ index.schemas.ts
β βββ v3/ # API v3 client
β βββ index.ts
β βββ index.schemas.ts
- API v3: Contains new features and improved API endpoints. We recommend using v3 whenever possible.
- API v1: Use when you need features not available in v3 or for legacy compatibility.
All API requests and responses are type-safe:
// Utilize auto-generated type definitions
import type {
Page,
PageInfo,
Comment,
SyncStatus
} from '@growi/sdk-typescript/v3';
// TypeScript's type checking detects errors at compile time
const pageInfo: PageInfo = {
path: '/test',
// Other required properties...
};
This project automatically generates code from GROWI's official OpenAPI specifications:
- Code generation command:
pnpm run generate:api
- Configuration file:
orval.config.ts
- Automatic updates: GitHub Actions periodically checks for specification updates
- Clone the repository:
git clone https://github.com/weseek/growi-sdk-typescript.git
cd growi-sdk-typescript
- Install dependencies:
pnpm install
- Generate API client:
pnpm run generate:api
The following workflows are automatically executed by GitHub Actions:
- Specification update detection: GitHub Actions periodically checks for changes in OpenAPI specifications
- Automatic code generation: When changes are detected, new client code is automatically generated
- Diff review: Review the generated code differences and check for breaking changes
- Pull request creation: Automatically create pull requests when changes are found
- Coding standards: Uses Biome
- Linting:
pnpm run lint
- Build:
pnpm run build
- Report Issues: Report bugs and feature requests on GitHub Issues
- Pull Requests:
- Fork and create a branch
- Implement changes
- Add tests (if applicable)
- Create a pull request
This project is released under the MIT License.
This SDK is under development. APIs may change without notice. Please thoroughly test before using in production environments.