0.15.2 • Published 9 days ago

@litencatt/notion-cli v0.15.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 days ago

notion-cli

This is a Notion CLI tool written by TypeScript. And some commands can be executed in interactive mode.

Features

  • Support for multiple output formats including csv and JSON
  • Support interactive mode for CRUD operation.

Quick Start

Retrieves a page object using the ID specified.

$ export NOTION_TOKEN=secret_xxx...
$ notion-cli page retrieve <PAGE_ID>

Using docker image:

$ docker run -e NOTION_TOKEN=secret_xxx... ghcr.io/litencatt/notion-cli page retrieve <PAGE_ID>

# -it flag is required to run interactive mode using docker
$ docker run -it -e NOTION_TOKEN=secret_xxx... ghcr.io/litencatt/notion-cli db retrieve

Multiple output formats

oclif ux.table supported output formats are table, csv, json, yaml. And notion-cli supports output raw json response with --raw.

default: table

Output columns are only title, object, id, url now.

$ notion-cli page retireve c77dbaf240174ea1ac1e93a87269f3ea
 Title      Object Id                                   Url
 ────────── ────── ──────────────────────────────────── ─────────────────────────────────────────────────────────────────
 Page title page   c77dbaf2-4017-4ea1-ac1e-93a87269f3ea https://www.notion.so/Page-title-c77dbaf240174ea1ac1e93a87269f3ea

csv

$ notion-cli page retrieve c77dbaf240174ea1ac1e93a87269f3ea --output csv
Title,Object,Id,Url
Page title,page,c77dbaf2-4017-4ea1-ac1e-93a87269f3ea,https://www.notion.so/Page-title-c77dbaf240174ea1ac1e93a87269f3ea

json

$ notion-cli page retrieve c77dbaf240174ea1ac1e93a87269f3ea --output json
[
  {
    "title": "Page title",
    "object": "page",
    "id": "c77dbaf2-4017-4ea1-ac1e-93a87269f3ea",
    "url": "https://www.notion.so/Page-title-c77dbaf240174ea1ac1e93a87269f3ea"
  }
]

yaml

$ notion-cli page retrieve c77dbaf240174ea1ac1e93a87269f3ea --output yaml
- title: Page title
  object: page
  id: c77dbaf2-4017-4ea1-ac1e-93a87269f3ea
  url: 'https://www.notion.so/Page-title-c77dbaf240174ea1ac1e93a87269f3ea'

Raw json

This flag returns the raw json response from the Notion API, so you can get all the data for a given resource. You can also process the response using jq or other tools.

$ notion-cli page retrieve c77dbaf240174ea1ac1e93a87269f3ea --raw | head
{
  "object": "page",
  "id": "c77dbaf2-4017-4ea1-ac1e-93a87269f3ea",
  "created_time": "2023-05-07T09:08:00.000Z",
  "last_edited_time": "2023-08-15T01:08:00.000Z",
  "created_by": {
    "object": "user",
    "id": "3555ae80-4588-4514-bb6b-2ece534157de"
  },
  "last_edited_by": {
...

Interactive mode in db command

  1. Start interactive mode execute db command without args
  2. Select a database from list
  3. Build filter conditions
    • And then you can choose whether to save the conditions to a json file or not.
  4. Query to db with the filter conditions
  5. Saved json files can be reused by passing them as flags at the next execution.

interactive-mode

Install

npm:

$ npm install -g @litencatt/notion-cli

docker:

$ docker pull ghcr.io/litencatt/notion-cli

Commands

Supported API and functions

EndpointAPISupportmulti-format*interactive mode
AuthenticationCreate a token   
BlocksAppend a block childrenoo 
BlocksRetrieve a blockoo 
BlocksRetrieve a block childrenoo 
BlocksUpdate a blockoo 
BlocksDelete a blockoo 
PagesCreate a pageoo 
PagesRetrieve a pageoo 
PagesUpdate a pageoo 
DatabaseCreate a databaseooo
DatabaseRetrieve a databaseooo
DatabaseUpdate a databaseooo
DatabaseQuery a databaseooo
UsersList all usersoo 
UsersRetrieve a useroo 
UsersRetrieve your token's bot useroo 
CommentsCreate a comment   
CommentsRetrieve a comment   
SearchSearch by titleoo

* multi-format NOT supported commands output only raw json response

0.15.2

9 days ago

0.15.1

29 days ago

0.14.5

4 months ago

0.14.6

4 months ago

0.15.0

4 months ago

0.14.2

4 months ago

0.14.3

4 months ago

0.14.4

4 months ago

0.10.0

9 months ago

0.11.0

9 months ago

0.10.1

9 months ago

0.12.0

9 months ago

0.11.1

9 months ago

0.10.2

9 months ago

0.13.0

9 months ago

0.11.2

9 months ago

0.14.0

9 months ago

0.13.1

9 months ago

0.14.1

9 months ago

0.13.2

9 months ago

0.13.3

9 months ago

0.13.4

9 months ago

0.13.5

9 months ago

0.5.0

1 year ago

0.4.3

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago