A command-line interface for managing Wiki.js content via GraphQL API.
- List all pages
- Display page tree structure
- Search pages by keyword
- Fetch a single page by ID or path
- Create new pages from Markdown files
- Go 1.21+
- A running Wiki.js instance with GraphQL API enabled
- An API token with sufficient permissions
go build -o wiki.js-cli .Or run directly:
go run main.go <command> [flags]Create a .env file with your Wiki.js credentials:
GRAPHQL_ENDPOINT=http://your-wiki-js-host/graphql
TOKEN=your-api-token-hereLoad the env file with the --env flag:
./wiki.js-cli --env .env pages| Flag | Description | Default |
|---|---|---|
--json |
Output in JSON format | false |
--env |
Path to .env file |
"" |
--locale |
Locale for queries | "zh" |
List all pages in the Wiki.js instance.
./wiki.js-cli --env .env pages
./wiki.js-cli --env .env --json pagesDisplay the hierarchical tree structure of pages.
./wiki.js-cli --env .env tree
./wiki.js-cli --env .env tree -p 0
./wiki.js-cli --env .env --json tree| Flag | Description | Default |
|---|---|---|
-p, --parent |
Parent node ID | 0 |
Search pages by keyword.
./wiki.js-cli --env .env search -k "hello"
./wiki.js-cli --env .env --json search -k "hello"| Flag | Description | Default |
|---|---|---|
-k, --keyword |
Search keyword (required) | — |
Retrieve a single page by ID or path.
./wiki.js-cli --env .env page --id 1
./wiki.js-cli --env .env page --path "home"
./wiki.js-cli --env .env --json page --id 1| Flag | Description | Default |
|---|---|---|
--id |
Page ID | 0 |
--path |
Page path | "" |
Create a new page from a Markdown file.
./wiki.js-cli --env .env create --title "My Page" --path "docs/my-page" --locale en --file ./content.md
./wiki.js-cli --env .env create --title "My Page" --path "docs/my-page" --locale en --file ./content.md --description "A test page"| Flag | Description | Required | Default |
|---|---|---|---|
--title |
Page title | Yes | — |
--path |
Page URL path | Yes | — |
--locale |
Page locale | Yes | — |
--file |
Content file path | Yes | — |
--description |
Page description | No | "" |
--publish |
Publish immediately | No | true |
--private |
Make page private | No | false |
wiki.js-cli/
├── cmd/ # CLI commands (Cobra)
│ ├── root.go # Root command & global flags
│ ├── pages.go # List all pages
│ ├── page.go # Fetch single page
│ ├── tree.go # Display page tree
│ ├── search.go # Search pages
│ └── create.go # Create a new page
├── internal/
│ └── wiki.js/
│ └── wikijs.go # Wiki.js GraphQL client
├── main.go # Entry point
├── .env # Environment configuration
└── go.mod # Go module definition
MIT