Notion CLI Go is a command-line interface tool written in Go to manage tasks in Notion.so. This tool is a new iteration based on the original Python project, now built in Go for improved performance and portability. This project is a work in progress, some of the features mentioned below are aspirational and not yet implemented.
To install the project, you'll need to clone the repository and build the Go application. Here are the basic instructions:
git clone https://github.com/kris-hansen/notion-cli-go
cd notion-cli-go
go build
go install .Before running the notioncli tool, you need to set the following environment variables:
NOTION_API_KEY: Your Notion Official API key.NOTION_PAGE_ID: The URL for the page (ex: https://notion.so/my-page/{pageID}). Here are some tips for finding your page ID. You will also need to share this page as an integration to expose it to the cli tool. Keep in mind that the page ID in the URL will have the title asTitle-<PageID>and the title portion will need to be removed.LOCAL_TIMEZONE: Your local timezone (ex: 'America/New_York').
For the NOTION_API_KEY, visit Notion's integration page and create a new integration. Remember to share your task page with the integration.
Your .env file can either be located in your working directory or in ~/.config/notioncli/.env - for convenience there is a sample env file named .env.example
You can interact with the tool using the built binary:
./notioncli [command]list: List all to-do tasks on the Notion page.add <task>: Add a new to-do task to the Notion page.check <number>: Mark a task as complete.uncheck <number>: Mark a task as incomplete.delete <number>: Delete a to-do task from the Notion page.
The blocks subcommand allows you to work with all Notion block types:
# List all blocks
notioncli blocks list
# List only specific block types
notioncli blocks list --type heading_1
# Add different block types
notioncli blocks add "Hello world" # paragraph (default)
notioncli blocks add "Section Title" -t heading_1 # heading
notioncli blocks add "Buy milk" -t to_do # to-do item
notioncli blocks add "Important note" -t callout # callout
notioncli blocks add "" -t divider # divider
# Delete any block by index
notioncli blocks delete 5Supported block types:
paragraph- Regular textheading_1,heading_2,heading_3- Headingsbulleted_list_item,numbered_list_item- List itemsto_do- Checkbox itemstoggle- Collapsible contentquote- Block quotescallout- Highlighted calloutsdivider- Horizontal dividerscode- Code blocks
completion: Generate the autocompletion script for your shellhelp: Show help information.
Currently, the tool only supports a single Notion page at a time.
Currently some of the utility package block functions have test coverage. Invoke the tests with:
go test -v ./...This project is licensed under the Apache License 2.0. See the LICENSE file for details.
