notion

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlocksToMarkdown

func BlocksToMarkdown(blocks []notionBlock) string

BlocksToMarkdown converts a slice of Notion blocks to a markdown string.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Notion API client.

func New

func New(baseURL, token string) *Client

New creates a Notion client with the given base URL and integration token.

func (*Client) GetPage

func (c *Client) GetPage(ctx context.Context, pageID string) (string, error)

GetPage fetches a page's content and returns it as markdown.

func (*Client) ListDatabases

func (c *Client) ListDatabases(ctx context.Context) ([]DatabaseEntry, error)

ListDatabases lists all databases shared with the integration.

func (*Client) QueryDatabase

func (c *Client) QueryDatabase(ctx context.Context, dbID string) ([]DatabaseRow, error)

QueryDatabase queries a Notion database and returns its rows.

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string) ([]SearchResult, error)

Search searches the Notion workspace for pages and databases matching the query.

func (*Client) SetHTTPDoer

func (c *Client) SetHTTPDoer(doer apiclient.HTTPDoer)

SetHTTPDoer replaces the HTTP client used for API requests.

type Config

type Config struct {
	Name        string `mapstructure:"name"`
	URL         string `mapstructure:"url"`
	Token       string `mapstructure:"token"`
	Description string `mapstructure:"description"`
}

Config holds the configuration for a single Notion instance.

func LoadConfigs

func LoadConfigs(dir string) ([]Config, error)

LoadConfigs reads a .humanconfig YAML file from dir and returns the list of configured Notion instances. Returns nil and no error if the file does not exist.

type DatabaseEntry

type DatabaseEntry struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	URL   string `json:"url"`
}

DatabaseEntry is a database listing entry for CLI output.

type DatabaseRow

type DatabaseRow struct {
	ID         string            `json:"id"`
	URL        string            `json:"url"`
	Properties map[string]string `json:"properties"`
}

DatabaseRow is a single row from a database query for CLI output.

type Instance

type Instance struct {
	Name        string
	URL         string
	Description string
	Client      *Client
}

Instance represents a configured Notion workspace ready for use.

func LoadInstances

func LoadInstances(dir string) ([]Instance, error)

LoadInstances reads config, applies env overrides, creates clients, and returns ready-to-use Notion instances.

type SearchResult

type SearchResult struct {
	ID    string `json:"id"`
	Title string `json:"title"`
	URL   string `json:"url"`
	Type  string `json:"type"`
}

SearchResult is a search result for CLI output.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL