notion

package module
Version: v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MIT Imports: 10 Imported by: 7

README

go-notion

GitHub tag (latestSemVer) GoReference GitHub Go ReportCard

go-notion is a client for the Notion API, written in Go.

Features

The client supports all (non-deprecated) endpoints available in the Notion API, as of September 4, 2022:

Databases
Pages
Blocks
Users
Search
Comments

Installation

$ go get github.com/dstotijn/go-notion

Usage

To obtain an API key, follow Notion’s getting started guide.

import "github.com/dstotijn/go-notion"

(...)

client := notion.NewClient("secret-api-key")

page, err := client.FindPageByID(context.Background(), "18d35eb5-91f1-4dcb-85b0-c340fd965015")
if err != nil {
    // Handle error...
}

👉 Check out the docs on pkg.go.dev for a complete reference and the examples directory for more example code.

Status

The Notion API itself is out of beta. This library is updated periodically following documented changes from the Notion changelog.

Note: This library will make breaking changes in its code until v1.0 of the module is released. There are no immediate plans for a v1.0 release. I want the design choices to be solidified and battle-tested more before committing to a stable release (and the possible burden of a "v2+" Go module should I want to introduce breaking changes).

License

MIT License

© 2022 David Stotijn

Documentation

Index

Constants

View Source
const (
	RollupFunctionCountAll          RollupFunction = "count_all"
	RollupFunctionCountValues       RollupFunction = "count_values"
	RollupFunctionCountUniqueValues RollupFunction = "count_unique_values"
	RollupFunctionCountEmpty        RollupFunction = "count_empty"
	RollupFunctionCountNotEmpty     RollupFunction = "count_not_empty"
	RollupFunctionPercentEmpty      RollupFunction = "percent_empty"
	RollupFunctionPercentNotEmpty   RollupFunction = "percent_not_empty"
	RollupFunctionSum               RollupFunction = "sum"
	RollupFunctionAverage           RollupFunction = "average"
	RollupFunctionMedian            RollupFunction = "median"
	RollupFunctionMin               RollupFunction = "min"
	RollupFunctionMax               RollupFunction = "max"
	RollupFunctionRange             RollupFunction = "range"
	RollupFunctionShowOriginal      RollupFunction = "show_original"

	RelationTypeSingleProperty RelationType = "single_property"
	RelationTypeDualProperty   RelationType = "dual_property"
)
View Source
const (
	TimestampCreatedTime    = "created_time"
	TimestampLastEditedTime = "last_edited_time"
)
View Source
const (
	// Database property type enums.
	DBPropTypeTitle          DatabasePropertyType = "title"
	DBPropTypeRichText       DatabasePropertyType = "rich_text"
	DBPropTypeNumber         DatabasePropertyType = "number"
	DBPropTypeSelect         DatabasePropertyType = "select"
	DBPropTypeMultiSelect    DatabasePropertyType = "multi_select"
	DBPropTypeDate           DatabasePropertyType = "date"
	DBPropTypePeople         DatabasePropertyType = "people"
	DBPropTypeFiles          DatabasePropertyType = "files"
	DBPropTypeCheckbox       DatabasePropertyType = "checkbox"
	DBPropTypeURL            DatabasePropertyType = "url"
	DBPropTypeEmail          DatabasePropertyType = "email"
	DBPropTypePhoneNumber    DatabasePropertyType = "phone_number"
	DBPropTypeStatus         DatabasePropertyType = "status"
	DBPropTypeFormula        DatabasePropertyType = "formula"
	DBPropTypeRelation       DatabasePropertyType = "relation"
	DBPropTypeRollup         DatabasePropertyType = "rollup"
	DBPropTypeCreatedTime    DatabasePropertyType = "created_time"
	DBPropTypeCreatedBy      DatabasePropertyType = "created_by"
	DBPropTypeLastEditedTime DatabasePropertyType = "last_edited_time"
	DBPropTypeLastEditedBy   DatabasePropertyType = "last_edited_by"

	// Used for paginated property values.
	// See: https://developers.notion.com/reference/property-item-object#paginated-property-values
	DBPropTypePropertyItem DatabasePropertyType = "property_item"

	// Number format enums.
	NumberFormatNumber           NumberFormat = "number"
	NumberFormatNumberWithCommas NumberFormat = "number_with_commas"
	NumberFormatPercent          NumberFormat = "percent"
	NumberFormatDollar           NumberFormat = "dollar"
	NumberFormatEuro             NumberFormat = "euro"
	NumberFormatPound            NumberFormat = "pound"
	NumberFormatPonud            NumberFormat = "yen"
	NumberFormatRuble            NumberFormat = "ruble"
	NumberFormatRupee            NumberFormat = "rupee"
	NumberFormatWon              NumberFormat = "won"
	NumberFormatYuan             NumberFormat = "yuan"
	NumberFormatHongKongDollar   NumberFormat = "hong_kong_dollar"
	NumberFormatNewZealandDollar NumberFormat = "new_zealand_dollar"
	NumberFormatKrona            NumberFormat = "krona"
	NumberFormatNorwegianKrone   NumberFormat = "norwegian_krone"
	NumberFormatMexicanPeso      NumberFormat = "mexican_peso"
	NumberFormatRand             NumberFormat = "rand"
	NumberFormatNewTaiwanDollar  NumberFormat = "new_taiwan_dollar"
	NumberFormatDanishKrone      NumberFormat = "danish_krone"
	NumberFormatZloty            NumberFormat = "zloty"
	NumberFormatBaht             NumberFormat = "baht"
	NumberFormatForint           NumberFormat = "forint"
	NumberFormatKoruna           NumberFormat = "koruna"
	NumberFormatShekel           NumberFormat = "shekel"
	NumberFormatChileanPeso      NumberFormat = "chilean_peso"
	NumberFormatPhilippinePeso   NumberFormat = "philippine_peso"
	NumberFormatDirham           NumberFormat = "dirham"
	NumberFormatColombianPeso    NumberFormat = "colombian_peso"
	NumberFormatRiyal            NumberFormat = "riyal"
	NumberFormatRinggit          NumberFormat = "ringgit"
	NumberFormatLeu              NumberFormat = "leu"

	// Formula result type enums.
	FormulaResultTypeString  FormulaResultType = "string"
	FormulaResultTypeNumber  FormulaResultType = "number"
	FormulaResultTypeBoolean FormulaResultType = "boolean"
	FormulaResultTypeDate    FormulaResultType = "date"

	// Rollup result type enums.
	RollupResultTypeNumber      RollupResultType = "number"
	RollupResultTypeDate        RollupResultType = "date"
	RollupResultTypeArray       RollupResultType = "array"
	RollupResultTypeUnsupported RollupResultType = "unsupported"
	RollupResultTypeIncomplete  RollupResultType = "incomplete"

	// Sort timestamp enums.
	SortTimeStampCreatedTime    SortTimestamp = "created_time"
	SortTimeStampLastEditedTime SortTimestamp = "last_edited_time"

	// Sort direction enums.
	SortDirAsc  SortDirection = "ascending"
	SortDirDesc SortDirection = "descending"
)
View Source
const (
	MentionTypeUser            MentionType = "user"
	MentionTypePage            MentionType = "page"
	MentionTypeDatabase        MentionType = "database"
	MentionTypeDate            MentionType = "date"
	MentionTypeLinkPreview     MentionType = "link_preview"
	MentionTypeTemplateMention MentionType = "template_mention"

	TemplateMentionTypeDate      TemplateMentionType     = "template_mention_date"
	TemplateMentionTypeUser      TemplateMentionType     = "template_mention_user"
	TemplateMentionDateTypeToday TemplateMentionDateType = "today"
	TemplateMentionDateTypeNow   TemplateMentionDateType = "now"
	TemplateMentionUserTypeMe    TemplateMentionUserType = "me"
)
View Source
const DateTimeFormat = "2006-01-02T15:04:05.999Z07:00"

DateTimeFormat is used when calling time.Parse, using RFC3339 with microsecond precision, which is what the Notion API returns in JSON response data.

Variables

View Source
var (
	ErrInvalidJSON        = errors.New("notion: request body could not be decoded as JSON")
	ErrInvalidRequestURL  = errors.New("notion: request URL is not valid")
	ErrInvalidRequest     = errors.New("notion: request is not supported")
	ErrValidation         = errors.New("notion: request body does not match the schema for the expected parameters")
	ErrUnauthorized       = errors.New("notion: bearer token is not valid")
	ErrRestrictedResource = errors.New("notion: client doesn't have permission to perform this operation")
	ErrObjectNotFound     = errors.New("notion: the resource does not exist")
	ErrConflict           = errors.New("notion: the transaction could not be completed, potentially due to a data collision")
	ErrRateLimited        = errors.New("notion: this request exceeds the number of requests allowed")
	ErrInternalServer     = errors.New("notion: an unexpected error occurred")
	ErrServiceUnavailable = errors.New("notion: service is unavailable")
)

See: https://developers.notion.com/reference/errors.

Functions

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns the pointer of a bool value.

func Float64Ptr added in v0.3.0

func Float64Ptr(f float64) *float64

Float64Ptr returns the pointer of a float64 value.

func IntPtr

func IntPtr(i int) *int

IntPtr returns the pointer of an int value.

func StringPtr

func StringPtr(s string) *string

StringPtr returns the pointer of a string value.

func TimePtr

func TimePtr(t time.Time) *time.Time

TimePtr returns the pointer of a time.Time value.

Types

type APIError

type APIError struct {
	Object  string `json:"object"`
	Status  int    `json:"status"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

func (*APIError) Error

func (err *APIError) Error() string

Error implements `error`.

func (*APIError) Unwrap

func (err *APIError) Unwrap() error

type Annotations

type Annotations struct {
	Bold          bool  `json:"bold,omitempty"`
	Italic        bool  `json:"italic,omitempty"`
	Strikethrough bool  `json:"strikethrough,omitempty"`
	Underline     bool  `json:"underline,omitempty"`
	Code          bool  `json:"code,omitempty"`
	Color         Color `json:"color,omitempty"`
}

type BaseUser added in v0.7.0

type BaseUser struct {
	ID string `json:"id"`
}

BaseUser contains the fields that are always returned for user objects. See: https://developers.notion.com/reference/user#where-user-objects-appear-in-the-api

type Block

type Block interface {
	ID() string
	Parent() Parent
	CreatedTime() time.Time
	CreatedBy() BaseUser
	LastEditedBy() BaseUser
	LastEditedTime() time.Time
	HasChildren() bool
	Archived() bool
	json.Marshaler
}

Block represents content on the Notion platform. See: https://developers.notion.com/reference/block

type BlockChildrenResponse

type BlockChildrenResponse struct {
	Results    []Block
	HasMore    bool
	NextCursor *string
}

BlockChildrenResponse contains results (block children) and pagination data returned from a find request.

func (*BlockChildrenResponse) UnmarshalJSON added in v0.7.0

func (resp *BlockChildrenResponse) UnmarshalJSON(b []byte) error

type BlockType

type BlockType string
const (
	BlockTypeParagraph        BlockType = "paragraph"
	BlockTypeHeading1         BlockType = "heading_1"
	BlockTypeHeading2         BlockType = "heading_2"
	BlockTypeHeading3         BlockType = "heading_3"
	BlockTypeBulletedListItem BlockType = "bulleted_list_item"
	BlockTypeNumberedListItem BlockType = "numbered_list_item"
	BlockTypeToDo             BlockType = "to_do"
	BlockTypeToggle           BlockType = "toggle"
	BlockTypeChildPage        BlockType = "child_page"
	BlockTypeChildDatabase    BlockType = "child_database"
	BlockTypeCallout          BlockType = "callout"
	BlockTypeQuote            BlockType = "quote"
	BlockTypeCode             BlockType = "code"
	BlockTypeEmbed            BlockType = "embed"
	BlockTypeImage            BlockType = "image"
	BlockTypeVideo            BlockType = "video"
	BlockTypeFile             BlockType = "file"
	BlockTypePDF              BlockType = "pdf"
	BlockTypeBookmark         BlockType = "bookmark"
	BlockTypeEquation         BlockType = "equation"
	BlockTypeDivider          BlockType = "divider"
	BlockTypeTableOfContents  BlockType = "table_of_contents"
	BlockTypeBreadCrumb       BlockType = "breadcrumb"
	BlockTypeColumnList       BlockType = "column_list"
	BlockTypeColumn           BlockType = "column"
	BlockTypeTable            BlockType = "table"
	BlockTypeTableRow         BlockType = "table_row"
	BlockTypeLinkPreview      BlockType = "link_preview"
	BlockTypeLinkToPage       BlockType = "link_to_page"
	BlockTypeSyncedBlock      BlockType = "synced_block"
	BlockTypeTemplate         BlockType = "template"
	BlockTypeUnsupported      BlockType = "unsupported"
)

type BookmarkBlock added in v0.7.0

type BookmarkBlock struct {
	URL     string     `json:"url"`
	Caption []RichText `json:"caption,omitempty"`
	// contains filtered or unexported fields
}

func (BookmarkBlock) Archived added in v0.7.0

func (b BookmarkBlock) Archived() bool

func (BookmarkBlock) CreatedBy added in v0.7.0

func (b BookmarkBlock) CreatedBy() BaseUser

func (BookmarkBlock) CreatedTime added in v0.7.0

func (b BookmarkBlock) CreatedTime() time.Time

func (BookmarkBlock) HasChildren added in v0.7.0

func (b BookmarkBlock) HasChildren() bool

func (BookmarkBlock) ID added in v0.7.0

func (b BookmarkBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (BookmarkBlock) LastEditedBy added in v0.7.0

func (b BookmarkBlock) LastEditedBy() BaseUser

func (BookmarkBlock) LastEditedTime added in v0.7.0

func (b BookmarkBlock) LastEditedTime() time.Time

func (BookmarkBlock) MarshalJSON added in v0.7.0

func (b BookmarkBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (BookmarkBlock) Parent added in v0.7.0

func (b BookmarkBlock) Parent() Parent

type Bot

type Bot struct {
	Owner BotOwner `json:"owner"`
}

type BotOwner added in v0.5.0

type BotOwner struct {
	Type      BotOwnerType `json:"type"`
	Workspace bool         `json:"workspace"`
	User      *User        `json:"user"`
}

type BotOwnerType added in v0.5.0

type BotOwnerType string
const (
	BotOwnerTypeWorkspace BotOwnerType = "workspace"
	BotOwnerTypeUser      BotOwnerType = "user"
)
type BreadcrumbBlock struct {
	// contains filtered or unexported fields
}
func (b BreadcrumbBlock) Archived() bool
func (b BreadcrumbBlock) CreatedBy() BaseUser
func (b BreadcrumbBlock) CreatedTime() time.Time
func (b BreadcrumbBlock) HasChildren() bool
func (b BreadcrumbBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (b BreadcrumbBlock) LastEditedBy() BaseUser
func (b BreadcrumbBlock) LastEditedTime() time.Time
func (b BreadcrumbBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (b BreadcrumbBlock) Parent() Parent

type BulletedListItemBlock added in v0.7.0

type BulletedListItemBlock struct {
	RichText []RichText `json:"rich_text"`
	Children []Block    `json:"children,omitempty"`
	Color    Color      `json:"color,omitempty"`
	// contains filtered or unexported fields
}

func (BulletedListItemBlock) Archived added in v0.7.0

func (b BulletedListItemBlock) Archived() bool

func (BulletedListItemBlock) CreatedBy added in v0.7.0

func (b BulletedListItemBlock) CreatedBy() BaseUser

func (BulletedListItemBlock) CreatedTime added in v0.7.0

func (b BulletedListItemBlock) CreatedTime() time.Time

func (BulletedListItemBlock) HasChildren added in v0.7.0

func (b BulletedListItemBlock) HasChildren() bool

func (BulletedListItemBlock) ID added in v0.7.0

func (b BulletedListItemBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (BulletedListItemBlock) LastEditedBy added in v0.7.0

func (b BulletedListItemBlock) LastEditedBy() BaseUser

func (BulletedListItemBlock) LastEditedTime added in v0.7.0

func (b BulletedListItemBlock) LastEditedTime() time.Time

func (BulletedListItemBlock) MarshalJSON added in v0.7.0

func (b BulletedListItemBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (BulletedListItemBlock) Parent added in v0.7.0

func (b BulletedListItemBlock) Parent() Parent

type CalloutBlock added in v0.7.0

type CalloutBlock struct {
	RichText []RichText `json:"rich_text"`
	Children []Block    `json:"children,omitempty"`
	Icon     *Icon      `json:"icon,omitempty"`
	Color    Color      `json:"color,omitempty"`
	// contains filtered or unexported fields
}

func (CalloutBlock) Archived added in v0.7.0

func (b CalloutBlock) Archived() bool

func (CalloutBlock) CreatedBy added in v0.7.0

func (b CalloutBlock) CreatedBy() BaseUser

func (CalloutBlock) CreatedTime added in v0.7.0

func (b CalloutBlock) CreatedTime() time.Time

func (CalloutBlock) HasChildren added in v0.7.0

func (b CalloutBlock) HasChildren() bool

func (CalloutBlock) ID added in v0.7.0

func (b CalloutBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (CalloutBlock) LastEditedBy added in v0.7.0

func (b CalloutBlock) LastEditedBy() BaseUser

func (CalloutBlock) LastEditedTime added in v0.7.0

func (b CalloutBlock) LastEditedTime() time.Time

func (CalloutBlock) MarshalJSON added in v0.7.0

func (b CalloutBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (CalloutBlock) Parent added in v0.7.0

func (b CalloutBlock) Parent() Parent

type CheckboxDatabaseQueryFilter

type CheckboxDatabaseQueryFilter struct {
	Equals       *bool `json:"equals,omitempty"`
	DoesNotEqual *bool `json:"does_not_equal,omitempty"`
}

type ChildDatabaseBlock added in v0.7.0

type ChildDatabaseBlock struct {
	Title string `json:"title"`
	// contains filtered or unexported fields
}

func (ChildDatabaseBlock) Archived added in v0.7.0

func (b ChildDatabaseBlock) Archived() bool

func (ChildDatabaseBlock) CreatedBy added in v0.7.0

func (b ChildDatabaseBlock) CreatedBy() BaseUser

func (ChildDatabaseBlock) CreatedTime added in v0.7.0

func (b ChildDatabaseBlock) CreatedTime() time.Time

func (ChildDatabaseBlock) HasChildren added in v0.7.0

func (b ChildDatabaseBlock) HasChildren() bool

func (ChildDatabaseBlock) ID added in v0.7.0

func (b ChildDatabaseBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (ChildDatabaseBlock) LastEditedBy added in v0.7.0

func (b ChildDatabaseBlock) LastEditedBy() BaseUser

func (ChildDatabaseBlock) LastEditedTime added in v0.7.0

func (b ChildDatabaseBlock) LastEditedTime() time.Time

func (ChildDatabaseBlock) MarshalJSON added in v0.7.0

func (b ChildDatabaseBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (ChildDatabaseBlock) Parent added in v0.7.0

func (b ChildDatabaseBlock) Parent() Parent

type ChildPageBlock added in v0.7.0

type ChildPageBlock struct {
	Title string `json:"title"`
	// contains filtered or unexported fields
}

func (ChildPageBlock) Archived added in v0.7.0

func (b ChildPageBlock) Archived() bool

func (ChildPageBlock) CreatedBy added in v0.7.0

func (b ChildPageBlock) CreatedBy() BaseUser

func (ChildPageBlock) CreatedTime added in v0.7.0

func (b ChildPageBlock) CreatedTime() time.Time

func (ChildPageBlock) HasChildren added in v0.7.0

func (b ChildPageBlock) HasChildren() bool

func (ChildPageBlock) ID added in v0.7.0

func (b ChildPageBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (ChildPageBlock) LastEditedBy added in v0.7.0

func (b ChildPageBlock) LastEditedBy() BaseUser

func (ChildPageBlock) LastEditedTime added in v0.7.0

func (b ChildPageBlock) LastEditedTime() time.Time

func (ChildPageBlock) MarshalJSON added in v0.7.0

func (b ChildPageBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (ChildPageBlock) Parent added in v0.7.0

func (b ChildPageBlock) Parent() Parent

type Client

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

Client is used for HTTP requests to the Notion API.

func NewClient

func NewClient(apiKey string, opts ...ClientOption) *Client

NewClient returns a new Client.

func (*Client) AppendBlockChildren

func (c *Client) AppendBlockChildren(ctx context.Context, blockID string, children []Block) (result BlockChildrenResponse, err error)

AppendBlockChildren appends child content (blocks) to an existing block. See: https://developers.notion.com/reference/patch-block-children

func (*Client) CreateComment added in v0.7.0

func (c *Client) CreateComment(ctx context.Context, params CreateCommentParams) (comment Comment, err error)

CreateComment creates a comment in a page or existing discussion thread. See: https://developers.notion.com/reference/create-a-comment

func (*Client) CreateDatabase added in v0.4.0

func (c *Client) CreateDatabase(ctx context.Context, params CreateDatabaseParams) (db Database, err error)

CreateDatabase creates a new database as a child of an existing page. See: https://developers.notion.com/reference/create-a-database

func (*Client) CreatePage

func (c *Client) CreatePage(ctx context.Context, params CreatePageParams) (page Page, err error)

CreatePage creates a new page in the specified database or as a child of an existing page. See: https://developers.notion.com/reference/post-page

func (*Client) DeleteBlock added in v0.5.0

func (c *Client) DeleteBlock(ctx context.Context, blockID string) (Block, error)

DeleteBlock sets `archived: true` on a (page) block object. See: https://developers.notion.com/reference/delete-a-block

func (*Client) FindBlockByID added in v0.5.0

func (c *Client) FindBlockByID(ctx context.Context, blockID string) (Block, error)

FindBlockByID returns a single of block for a given block ID. See: https://developers.notion.com/reference/retrieve-a-block

func (*Client) FindBlockChildrenByID

func (c *Client) FindBlockChildrenByID(ctx context.Context, blockID string, query *PaginationQuery) (result BlockChildrenResponse, err error)

FindBlockChildrenByID returns a list of block children for a given block ID. See: https://developers.notion.com/reference/post-database-query

func (*Client) FindCommentsByBlockID added in v0.7.0

func (c *Client) FindCommentsByBlockID(
	ctx context.Context,
	query FindCommentsByBlockIDQuery,
) (result FindCommentsResponse, err error)

FindCommentsByBlockID returns a list of unresolved comments by parent block ID, and pagination metadata. See: https://developers.notion.com/reference/retrieve-a-comment

func (*Client) FindCurrentUser added in v0.5.0

func (c *Client) FindCurrentUser(ctx context.Context) (user User, err error)

FindCurrentUser fetches the current bot user based on authentication API key. See: https://developers.notion.com/reference/get-self

func (*Client) FindDatabaseByID

func (c *Client) FindDatabaseByID(ctx context.Context, id string) (db Database, err error)

FindDatabaseByID fetches a database by ID. See: https://developers.notion.com/reference/get-database

func (*Client) FindPageByID

func (c *Client) FindPageByID(ctx context.Context, id string) (page Page, err error)

FindPageByID fetches a page by ID. See: https://developers.notion.com/reference/get-page

func (*Client) FindPagePropertyByID added in v0.5.0

func (c *Client) FindPagePropertyByID(ctx context.Context, pageID, propID string, query *PaginationQuery) (result PagePropResponse, err error)

FindPagePropertyByID returns a page property. See: https://developers.notion.com/reference/retrieve-a-page-property

func (*Client) FindUserByID

func (c *Client) FindUserByID(ctx context.Context, id string) (user User, err error)

FindUserByID fetches a user by ID. See: https://developers.notion.com/reference/get-user

func (*Client) ListUsers

func (c *Client) ListUsers(ctx context.Context, query *PaginationQuery) (result ListUsersResponse, err error)

ListUsers returns a list of all users, and pagination metadata. See: https://developers.notion.com/reference/get-users

func (*Client) QueryDatabase

func (c *Client) QueryDatabase(ctx context.Context, id string, query *DatabaseQuery) (result DatabaseQueryResponse, err error)

QueryDatabase returns database contents, with optional filters, sorts and pagination. See: https://developers.notion.com/reference/post-database-query

func (*Client) Search

func (c *Client) Search(ctx context.Context, opts *SearchOpts) (result SearchResponse, err error)

Search fetches all pages and child pages that are shared with the integration. Optionally uses query, filter and pagination options. See: https://developers.notion.com/reference/post-search

func (*Client) UpdateBlock added in v0.5.0

func (c *Client) UpdateBlock(ctx context.Context, blockID string, block Block) (Block, error)

UpdateBlock updates a block. See: https://developers.notion.com/reference/update-a-block

func (*Client) UpdateDatabase added in v0.5.0

func (c *Client) UpdateDatabase(ctx context.Context, databaseID string, params UpdateDatabaseParams) (updatedDB Database, err error)

UpdateDatabase updates a database. See: https://developers.notion.com/reference/update-a-database

func (*Client) UpdatePage added in v0.5.0

func (c *Client) UpdatePage(ctx context.Context, pageID string, params UpdatePageParams) (page Page, err error)

UpdatePage updates a page. See: https://developers.notion.com/reference/patch-page

type ClientOption

type ClientOption func(*Client)

ClientOption is used to override default client behavior.

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient overrides the default http.Client.

type CodeBlock added in v0.7.0

type CodeBlock struct {
	RichText []RichText `json:"rich_text"`
	Children []Block    `json:"children,omitempty"`
	Caption  []RichText `json:"caption,omitempty"`
	Language *string    `json:"language,omitempty"`
	// contains filtered or unexported fields
}

func (CodeBlock) Archived added in v0.7.0

func (b CodeBlock) Archived() bool

func (CodeBlock) CreatedBy added in v0.7.0

func (b CodeBlock) CreatedBy() BaseUser

func (CodeBlock) CreatedTime added in v0.7.0

func (b CodeBlock) CreatedTime() time.Time

func (CodeBlock) HasChildren added in v0.7.0

func (b CodeBlock) HasChildren() bool

func (CodeBlock) ID added in v0.7.0

func (b CodeBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (CodeBlock) LastEditedBy added in v0.7.0

func (b CodeBlock) LastEditedBy() BaseUser

func (CodeBlock) LastEditedTime added in v0.7.0

func (b CodeBlock) LastEditedTime() time.Time

func (CodeBlock) MarshalJSON added in v0.7.0

func (b CodeBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (CodeBlock) Parent added in v0.7.0

func (b CodeBlock) Parent() Parent

type Color

type Color string
const (
	ColorDefault  Color = "default"
	ColorGray     Color = "gray"
	ColorBrown    Color = "brown"
	ColorOrange   Color = "orange"
	ColorYellow   Color = "yellow"
	ColorGreen    Color = "green"
	ColorBlue     Color = "blue"
	ColorPurple   Color = "purple"
	ColorPink     Color = "pink"
	ColorRed      Color = "red"
	ColorGrayBg   Color = "gray_background"
	ColorBrownBg  Color = "brown_background"
	ColorOrangeBg Color = "orange_background"
	ColorYellowBg Color = "yellow_background"
	ColorGreenBg  Color = "green_background"
	ColorBlueBg   Color = "blue_background"
	ColorPurpleBg Color = "purple_background"
	ColorPinkBg   Color = "pink_background"
	ColorRedBg    Color = "red_background"
)

type ColumnBlock added in v0.7.0

type ColumnBlock struct {
	Children []Block `json:"children,omitempty"`
	// contains filtered or unexported fields
}

func (ColumnBlock) Archived added in v0.7.0

func (b ColumnBlock) Archived() bool

func (ColumnBlock) CreatedBy added in v0.7.0

func (b ColumnBlock) CreatedBy() BaseUser

func (ColumnBlock) CreatedTime added in v0.7.0

func (b ColumnBlock) CreatedTime() time.Time

func (ColumnBlock) HasChildren added in v0.7.0

func (b ColumnBlock) HasChildren() bool

func (ColumnBlock) ID added in v0.7.0

func (b ColumnBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (ColumnBlock) LastEditedBy added in v0.7.0

func (b ColumnBlock) LastEditedBy() BaseUser

func (ColumnBlock) LastEditedTime added in v0.7.0

func (b ColumnBlock) LastEditedTime() time.Time

func (ColumnBlock) MarshalJSON added in v0.7.0

func (b ColumnBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (ColumnBlock) Parent added in v0.7.0

func (b ColumnBlock) Parent() Parent

type ColumnListBlock added in v0.7.0

type ColumnListBlock struct {
	Children []ColumnBlock `json:"children,omitempty"`
	// contains filtered or unexported fields
}

func (ColumnListBlock) Archived added in v0.7.0

func (b ColumnListBlock) Archived() bool

func (ColumnListBlock) CreatedBy added in v0.7.0

func (b ColumnListBlock) CreatedBy() BaseUser

func (ColumnListBlock) CreatedTime added in v0.7.0

func (b ColumnListBlock) CreatedTime() time.Time

func (ColumnListBlock) HasChildren added in v0.7.0

func (b ColumnListBlock) HasChildren() bool

func (ColumnListBlock) ID added in v0.7.0

func (b ColumnListBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (ColumnListBlock) LastEditedBy added in v0.7.0

func (b ColumnListBlock) LastEditedBy() BaseUser

func (ColumnListBlock) LastEditedTime added in v0.7.0

func (b ColumnListBlock) LastEditedTime() time.Time

func (ColumnListBlock) MarshalJSON added in v0.7.0

func (b ColumnListBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (ColumnListBlock) Parent added in v0.7.0

func (b ColumnListBlock) Parent() Parent

type Comment added in v0.7.0

type Comment struct {
	ID             string     `json:"id"`
	Parent         Parent     `json:"parent"`
	DiscussionID   string     `json:"discussion_id"`
	RichText       []RichText `json:"rich_text"`
	CreatedTime    time.Time  `json:"created_time"`
	LastEditedTime time.Time  `json:"last_edited_time"`
	CreatedBy      BaseUser   `json:"created_by"`
}

Comment represents a comment on a Notion page or block. See: https://developers.notion.com/reference/comment-object

type Cover added in v0.5.0

type Cover struct {
	Type FileType `json:"type"`

	File     *FileFile     `json:"file,omitempty"`
	External *FileExternal `json:"external,omitempty"`
}

func (Cover) Validate added in v0.5.0

func (cover Cover) Validate() error

type CreateCommentParams added in v0.7.0

type CreateCommentParams struct {
	// Either ParentPageID or DiscussionID must be non-empty. Also cannot be set
	// both at the same time.
	ParentPageID string
	DiscussionID string

	RichText []RichText
}

CreateCommentParams are the params used for creating a comment.

func (CreateCommentParams) MarshalJSON added in v0.7.0

func (p CreateCommentParams) MarshalJSON() ([]byte, error)

func (CreateCommentParams) Validate added in v0.7.0

func (p CreateCommentParams) Validate() error

type CreateDatabaseParams added in v0.4.0

type CreateDatabaseParams struct {
	ParentPageID string
	Title        []RichText
	Description  []RichText
	Properties   DatabaseProperties
	Icon         *Icon
	Cover        *Cover
	IsInline     bool
}

CreateDatabaseParams are the params used for creating a database.

func (CreateDatabaseParams) MarshalJSON added in v0.4.0

func (p CreateDatabaseParams) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (CreateDatabaseParams) Validate added in v0.4.0

func (p CreateDatabaseParams) Validate() error

Validate validates params for creating a database.

type CreatePageParams

type CreatePageParams struct {
	ParentType ParentType
	ParentID   string

	// Either DatabasePageProperties or Title must be not nil.
	DatabasePageProperties *DatabasePageProperties
	Title                  []RichText

	// Optionally, children blocks are added to the page.
	Children []Block

	Icon  *Icon
	Cover *Cover
}

CreatePageParams are the params used for creating a page.

func (CreatePageParams) MarshalJSON

func (p CreatePageParams) MarshalJSON() ([]byte, error)

func (CreatePageParams) Validate

func (p CreatePageParams) Validate() error

type Database

type Database struct {
	ID             string             `json:"id"`
	CreatedTime    time.Time          `json:"created_time"`
	CreatedBy      BaseUser           `json:"created_by"`
	LastEditedTime time.Time          `json:"last_edited_time"`
	LastEditedBy   BaseUser           `json:"last_edited_by"`
	URL            string             `json:"url"`
	Title          []RichText         `json:"title"`
	Description    []RichText         `json:"description"`
	Properties     DatabaseProperties `json:"properties"`
	Parent         Parent             `json:"parent"`
	Icon           *Icon              `json:"icon,omitempty"`
	Cover          *Cover             `json:"cover,omitempty"`
	Archived       bool               `json:"archived"`
	IsInline       bool               `json:"is_inline"`
}

Database is a resource on the Notion platform. See: https://developers.notion.com/reference/database

type DatabasePageProperties

type DatabasePageProperties map[string]DatabasePageProperty

DatabasePageProperties are properties of a page whose parent is a database.

type DatabasePageProperty

type DatabasePageProperty struct {
	ID   string               `json:"id,omitempty"`
	Type DatabasePropertyType `json:"type,omitempty"`
	Name string               `json:"name,omitempty"`

	Title          []RichText      `json:"title,omitempty"`
	RichText       []RichText      `json:"rich_text,omitempty"`
	Number         *float64        `json:"number,omitempty"`
	Select         *SelectOptions  `json:"select,omitempty"`
	MultiSelect    []SelectOptions `json:"multi_select,omitempty"`
	Date           *Date           `json:"date,omitempty"`
	Formula        *FormulaResult  `json:"formula,omitempty"`
	Relation       []Relation      `json:"relation,omitempty"`
	Rollup         *RollupResult   `json:"rollup,omitempty"`
	People         []User          `json:"people,omitempty"`
	Files          []File          `json:"files,omitempty"`
	Checkbox       *bool           `json:"checkbox,omitempty"`
	URL            *string         `json:"url,omitempty"`
	Email          *string         `json:"email,omitempty"`
	PhoneNumber    *string         `json:"phone_number,omitempty"`
	Status         *SelectOptions  `json:"status,omitempty"`
	CreatedTime    *time.Time      `json:"created_time,omitempty"`
	CreatedBy      *User           `json:"created_by,omitempty"`
	LastEditedTime *time.Time      `json:"last_edited_time,omitempty"`
	LastEditedBy   *User           `json:"last_edited_by,omitempty"`
}

func (DatabasePageProperty) Value added in v0.3.0

func (prop DatabasePageProperty) Value() interface{}

Value returns the underlying database page property value, based on its `type` field. When type is unknown/unmapped or doesn't have a value, `nil` is returned.

type DatabaseProperties

type DatabaseProperties map[string]DatabaseProperty

DatabaseProperties is a mapping of properties defined on a database.

type DatabaseProperty

type DatabaseProperty struct {
	ID   string               `json:"id,omitempty"`
	Type DatabasePropertyType `json:"type"`
	Name string               `json:"name,omitempty"`

	Title          *EmptyMetadata `json:"title,omitempty"`
	RichText       *EmptyMetadata `json:"rich_text,omitempty"`
	Date           *EmptyMetadata `json:"date,omitempty"`
	People         *EmptyMetadata `json:"people,omitempty"`
	Files          *EmptyMetadata `json:"files,omitempty"`
	Checkbox       *EmptyMetadata `json:"checkbox,omitempty"`
	URL            *EmptyMetadata `json:"url,omitempty"`
	Email          *EmptyMetadata `json:"email,omitempty"`
	PhoneNumber    *EmptyMetadata `json:"phone_number,omitempty"`
	CreatedTime    *EmptyMetadata `json:"created_time,omitempty"`
	CreatedBy      *EmptyMetadata `json:"created_by,omitempty"`
	LastEditedTime *EmptyMetadata `json:"last_edited_time,omitempty"`
	LastEditedBy   *EmptyMetadata `json:"last_edited_by,omitempty"`

	Number      *NumberMetadata   `json:"number,omitempty"`
	Select      *SelectMetadata   `json:"select,omitempty"`
	MultiSelect *SelectMetadata   `json:"multi_select,omitempty"`
	Formula     *FormulaMetadata  `json:"formula,omitempty"`
	Relation    *RelationMetadata `json:"relation,omitempty"`
	Rollup      *RollupMetadata   `json:"rollup,omitempty"`
	Status      *StatusMetadata   `json:"status,omitempty"`
}

func (DatabaseProperty) Metadata

func (prop DatabaseProperty) Metadata() interface{}

Metadata returns the underlying property metadata, based on its `type` field. When type is unknown/unmapped or doesn't have additional properies, `nil` is returned.

type DatabasePropertyType

type DatabasePropertyType string

type DatabaseQuery

type DatabaseQuery struct {
	Filter      *DatabaseQueryFilter `json:"filter,omitempty"`
	Sorts       []DatabaseQuerySort  `json:"sorts,omitempty"`
	StartCursor string               `json:"start_cursor,omitempty"`
	PageSize    int                  `json:"page_size,omitempty"`
}

DatabaseQuery is used for quering a database.

type DatabaseQueryFilter

type DatabaseQueryFilter struct {
	Property string `json:"property,omitempty"`

	DatabaseQueryPropertyFilter

	Timestamp Timestamp             `json:"timestamp,omitempty"`
	Or        []DatabaseQueryFilter `json:"or,omitempty"`
	And       []DatabaseQueryFilter `json:"and,omitempty"`
}

DatabaseQueryFilter is used to filter database contents. See: https://developers.notion.com/reference/post-database-query#post-database-query-filter

type DatabaseQueryPropertyFilter added in v0.7.0

type DatabaseQueryPropertyFilter struct {
	Title       *TextPropertyFilter `json:"title,omitempty"`
	RichText    *TextPropertyFilter `json:"rich_text,omitempty"`
	URL         *TextPropertyFilter `json:"url,omitempty"`
	Email       *TextPropertyFilter `json:"email,omitempty"`
	PhoneNumber *TextPropertyFilter `json:"phone_number,omitempty"`

	Date           *DatePropertyFilter `json:"date,omitempty"`
	CreatedTime    *DatePropertyFilter `json:"created_time,omitempty"`
	LastEditedTime *DatePropertyFilter `json:"last_edited_time,omitempty"`

	Number      *NumberDatabaseQueryFilter      `json:"number,omitempty"`
	Checkbox    *CheckboxDatabaseQueryFilter    `json:"checkbox,omitempty"`
	Select      *SelectDatabaseQueryFilter      `json:"select,omitempty"`
	MultiSelect *MultiSelectDatabaseQueryFilter `json:"multi_select,omitempty"`
	Status      *StatusDatabaseQueryFilter      `json:"status,omitempty"`
	People      *PeopleDatabaseQueryFilter      `json:"people,omitempty"`
	Files       *FilesDatabaseQueryFilter       `json:"files,omitempty"`
	Relation    *RelationDatabaseQueryFilter    `json:"relation,omitempty"`
	Formula     *FormulaDatabaseQueryFilter     `json:"formula,omitempty"`
	Rollup      *RollupDatabaseQueryFilter      `json:"rollup,omitempty"`

	CreatedBy    *PeopleDatabaseQueryFilter `json:"created_by,omitempty"`
	LastEditedBy *PeopleDatabaseQueryFilter `json:"last_edited_by,omitempty"`
}

type DatabaseQueryResponse

type DatabaseQueryResponse struct {
	Results    []Page  `json:"results"`
	HasMore    bool    `json:"has_more"`
	NextCursor *string `json:"next_cursor"`
}

DatabaseQueryResponse contains the results and pagination data from a query request.

type DatabaseQuerySort

type DatabaseQuerySort struct {
	Property  string        `json:"property,omitempty"`
	Timestamp SortTimestamp `json:"timestamp,omitempty"`
	Direction SortDirection `json:"direction,omitempty"`
}

type Date

type Date struct {
	Start    DateTime  `json:"start"`
	End      *DateTime `json:"end,omitempty"`
	TimeZone *string   `json:"time_zone,omitempty"`
}

type DatePropertyFilter added in v0.7.0

type DatePropertyFilter struct {
	Equals     *time.Time `json:"equals,omitempty"`
	Before     *time.Time `json:"before,omitempty"`
	After      *time.Time `json:"after,omitempty"`
	OnOrBefore *time.Time `json:"on_or_before,omitempty"`
	OnOrAfter  *time.Time `json:"on_or_after,omitempty"`
	IsEmpty    bool       `json:"is_empty,omitempty"`
	IsNotEmpty bool       `json:"is_not_empty,omitempty"`
	PastWeek   *struct{}  `json:"past_week,omitempty"`
	PastMonth  *struct{}  `json:"past_month,omitempty"`
	PastYear   *struct{}  `json:"past_year,omitempty"`
	NextWeek   *struct{}  `json:"next_week,omitempty"`
	NextMonth  *struct{}  `json:"next_month,omitempty"`
	NextYear   *struct{}  `json:"next_year,omitempty"`
}

type DateTime added in v0.2.0

type DateTime struct {
	time.Time
	// contains filtered or unexported fields
}

DateTime represents a Notion date property with optional time.

func NewDateTime added in v0.2.0

func NewDateTime(t time.Time, hasTime bool) DateTime

NewDateTime returns a new DateTime. If `haseTime` is true, time is included when encoding to JSON.

func ParseDateTime added in v0.2.0

func ParseDateTime(value string) (DateTime, error)

ParseDateTime parses an RFC3339 formatted string with optional time.

func (DateTime) Equal added in v0.2.0

func (dt DateTime) Equal(value DateTime) bool

Equal returns true if both DateTime values have equal underlying time.Time and hasTime fields.

func (*DateTime) HasTime added in v0.2.0

func (dt *DateTime) HasTime() bool

HasTime returns true if the datetime was parsed from a string that included time.

func (DateTime) MarshalJSON added in v0.2.0

func (dt DateTime) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler. It returns an RFC399 formatted string, using microsecond precision ()

func (*DateTime) UnmarshalJSON added in v0.2.0

func (dt *DateTime) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type DividerBlock added in v0.7.0

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

func (DividerBlock) Archived added in v0.7.0

func (b DividerBlock) Archived() bool

func (DividerBlock) CreatedBy added in v0.7.0

func (b DividerBlock) CreatedBy() BaseUser

func (DividerBlock) CreatedTime added in v0.7.0

func (b DividerBlock) CreatedTime() time.Time

func (DividerBlock) HasChildren added in v0.7.0

func (b DividerBlock) HasChildren() bool

func (DividerBlock) ID added in v0.7.0

func (b DividerBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (DividerBlock) LastEditedBy added in v0.7.0

func (b DividerBlock) LastEditedBy() BaseUser

func (DividerBlock) LastEditedTime added in v0.7.0

func (b DividerBlock) LastEditedTime() time.Time

func (DividerBlock) MarshalJSON added in v0.7.0

func (b DividerBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (DividerBlock) Parent added in v0.7.0

func (b DividerBlock) Parent() Parent

type DualPropertyRelation added in v0.7.0

type DualPropertyRelation struct {
	SyncedPropID   string `json:"synced_property_id,omitempty"`
	SyncedPropName string `json:"synced_property_name,omitempty"`
}

type EmbedBlock added in v0.7.0

type EmbedBlock struct {
	URL string `json:"url"`
	// contains filtered or unexported fields
}

func (EmbedBlock) Archived added in v0.7.0

func (b EmbedBlock) Archived() bool

func (EmbedBlock) CreatedBy added in v0.7.0

func (b EmbedBlock) CreatedBy() BaseUser

func (EmbedBlock) CreatedTime added in v0.7.0

func (b EmbedBlock) CreatedTime() time.Time

func (EmbedBlock) HasChildren added in v0.7.0

func (b EmbedBlock) HasChildren() bool

func (EmbedBlock) ID added in v0.7.0

func (b EmbedBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (EmbedBlock) LastEditedBy added in v0.7.0

func (b EmbedBlock) LastEditedBy() BaseUser

func (EmbedBlock) LastEditedTime added in v0.7.0

func (b EmbedBlock) LastEditedTime() time.Time

func (EmbedBlock) MarshalJSON added in v0.7.0

func (b EmbedBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (EmbedBlock) Parent added in v0.7.0

func (b EmbedBlock) Parent() Parent

type EmptyMetadata added in v0.4.0

type EmptyMetadata struct{}

Database property metadata types.

type Equation

type Equation struct {
	Expression string `json:"expression"`
}

type EquationBlock added in v0.7.0

type EquationBlock struct {
	Expression string `json:"expression"`
	// contains filtered or unexported fields
}

func (EquationBlock) Archived added in v0.7.0

func (b EquationBlock) Archived() bool

func (EquationBlock) CreatedBy added in v0.7.0

func (b EquationBlock) CreatedBy() BaseUser

func (EquationBlock) CreatedTime added in v0.7.0

func (b EquationBlock) CreatedTime() time.Time

func (EquationBlock) HasChildren added in v0.7.0

func (b EquationBlock) HasChildren() bool

func (EquationBlock) ID added in v0.7.0

func (b EquationBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (EquationBlock) LastEditedBy added in v0.7.0

func (b EquationBlock) LastEditedBy() BaseUser

func (EquationBlock) LastEditedTime added in v0.7.0

func (b EquationBlock) LastEditedTime() time.Time

func (EquationBlock) MarshalJSON added in v0.7.0

func (b EquationBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (EquationBlock) Parent added in v0.7.0

func (b EquationBlock) Parent() Parent

type File added in v0.3.0

type File struct {
	Name string   `json:"name"`
	Type FileType `json:"type"`

	File     *FileFile     `json:"file,omitempty"`
	External *FileExternal `json:"external,omitempty"`
}

type FileBlock added in v0.5.0

type FileBlock struct {
	Type     FileType      `json:"type"`
	File     *FileFile     `json:"file,omitempty"`
	External *FileExternal `json:"external,omitempty"`
	Caption  []RichText    `json:"caption,omitempty"`
	// contains filtered or unexported fields
}

func (FileBlock) Archived added in v0.7.0

func (b FileBlock) Archived() bool

func (FileBlock) CreatedBy added in v0.7.0

func (b FileBlock) CreatedBy() BaseUser

func (FileBlock) CreatedTime added in v0.7.0

func (b FileBlock) CreatedTime() time.Time

func (FileBlock) HasChildren added in v0.7.0

func (b FileBlock) HasChildren() bool

func (FileBlock) ID added in v0.7.0

func (b FileBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (FileBlock) LastEditedBy added in v0.7.0

func (b FileBlock) LastEditedBy() BaseUser

func (FileBlock) LastEditedTime added in v0.7.0

func (b FileBlock) LastEditedTime() time.Time

func (FileBlock) MarshalJSON added in v0.7.0

func (b FileBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (FileBlock) Parent added in v0.7.0

func (b FileBlock) Parent() Parent

type FileExternal added in v0.5.0

type FileExternal struct {
	URL string `json:"url"`
}

type FileFile added in v0.5.0

type FileFile struct {
	URL        string   `json:"url"`
	ExpiryTime DateTime `json:"expiry_time"`
}

type FileType added in v0.5.0

type FileType string
const (
	FileTypeFile     FileType = "file"
	FileTypeExternal FileType = "external"
)

type FilesDatabaseQueryFilter

type FilesDatabaseQueryFilter struct {
	IsEmpty    bool `json:"is_empty,omitempty"`
	IsNotEmpty bool `json:"is_not_empty,omitempty"`
}

type FindCommentsByBlockIDQuery added in v0.7.0

type FindCommentsByBlockIDQuery struct {
	BlockID     string
	StartCursor string
	PageSize    int
}

FindCommentsByBlockIDQuery is used when listing comments.

type FindCommentsResponse added in v0.7.0

type FindCommentsResponse struct {
	Results    []Comment `json:"results"`
	HasMore    bool      `json:"has_more"`
	NextCursor *string   `json:"next_cursor"`
}

FindCommentsResponse contains results (comments) and pagination data returned from a list request.

type FormulaDatabaseQueryFilter

type FormulaDatabaseQueryFilter struct {
	String   *TextPropertyFilter          `json:"string,omitempty"`
	Checkbox *CheckboxDatabaseQueryFilter `json:"checkbox,omitempty"`
	Number   *NumberDatabaseQueryFilter   `json:"number,omitempty"`
	Date     *DatePropertyFilter          `json:"date,omitempty"`
}

type FormulaMetadata

type FormulaMetadata struct {
	Expression string `json:"expression"`
}

Database property metadata types.

type FormulaResult added in v0.3.0

type FormulaResult struct {
	Type FormulaResultType `json:"type"`

	String  *string  `json:"string,omitempty"`
	Number  *float64 `json:"number,omitempty"`
	Boolean *bool    `json:"boolean,omitempty"`
	Date    *Date    `json:"date,omitempty"`
}

func (FormulaResult) Value added in v0.3.0

func (f FormulaResult) Value() interface{}

Value returns the underlying result value of an evaluated formula.

type FormulaResultType added in v0.3.0

type FormulaResultType string

type Heading1Block added in v0.7.0

type Heading1Block struct {
	RichText     []RichText `json:"rich_text"`
	Children     []Block    `json:"children,omitempty"`
	Color        Color      `json:"color,omitempty"`
	IsToggleable bool       `json:"is_toggleable"`
	// contains filtered or unexported fields
}

func (Heading1Block) Archived added in v0.7.0

func (b Heading1Block) Archived() bool

func (Heading1Block) CreatedBy added in v0.7.0

func (b Heading1Block) CreatedBy() BaseUser

func (Heading1Block) CreatedTime added in v0.7.0

func (b Heading1Block) CreatedTime() time.Time

func (Heading1Block) HasChildren added in v0.7.0

func (b Heading1Block) HasChildren() bool

func (Heading1Block) ID added in v0.7.0

func (b Heading1Block) ID() string

ID returns the identifier (UUIDv4) for the block.

func (Heading1Block) LastEditedBy added in v0.7.0

func (b Heading1Block) LastEditedBy() BaseUser

func (Heading1Block) LastEditedTime added in v0.7.0

func (b Heading1Block) LastEditedTime() time.Time

func (Heading1Block) MarshalJSON added in v0.7.0

func (b Heading1Block) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Heading1Block) Parent added in v0.7.0

func (b Heading1Block) Parent() Parent

type Heading2Block added in v0.7.0

type Heading2Block struct {
	RichText     []RichText `json:"rich_text"`
	Children     []Block    `json:"children,omitempty"`
	Color        Color      `json:"color,omitempty"`
	IsToggleable bool       `json:"is_toggleable"`
	// contains filtered or unexported fields
}

func (Heading2Block) Archived added in v0.7.0

func (b Heading2Block) Archived() bool

func (Heading2Block) CreatedBy added in v0.7.0

func (b Heading2Block) CreatedBy() BaseUser

func (Heading2Block) CreatedTime added in v0.7.0

func (b Heading2Block) CreatedTime() time.Time

func (Heading2Block) HasChildren added in v0.7.0

func (b Heading2Block) HasChildren() bool

func (Heading2Block) ID added in v0.7.0

func (b Heading2Block) ID() string

ID returns the identifier (UUIDv4) for the block.

func (Heading2Block) LastEditedBy added in v0.7.0

func (b Heading2Block) LastEditedBy() BaseUser

func (Heading2Block) LastEditedTime added in v0.7.0

func (b Heading2Block) LastEditedTime() time.Time

func (Heading2Block) MarshalJSON added in v0.7.0

func (b Heading2Block) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Heading2Block) Parent added in v0.7.0

func (b Heading2Block) Parent() Parent

type Heading3Block added in v0.7.0

type Heading3Block struct {
	RichText     []RichText `json:"rich_text"`
	Children     []Block    `json:"children,omitempty"`
	Color        Color      `json:"color,omitempty"`
	IsToggleable bool       `json:"is_toggleable"`
	// contains filtered or unexported fields
}

func (Heading3Block) Archived added in v0.7.0

func (b Heading3Block) Archived() bool

func (Heading3Block) CreatedBy added in v0.7.0

func (b Heading3Block) CreatedBy() BaseUser

func (Heading3Block) CreatedTime added in v0.7.0

func (b Heading3Block) CreatedTime() time.Time

func (Heading3Block) HasChildren added in v0.7.0

func (b Heading3Block) HasChildren() bool

func (Heading3Block) ID added in v0.7.0

func (b Heading3Block) ID() string

ID returns the identifier (UUIDv4) for the block.

func (Heading3Block) LastEditedBy added in v0.7.0

func (b Heading3Block) LastEditedBy() BaseUser

func (Heading3Block) LastEditedTime added in v0.7.0

func (b Heading3Block) LastEditedTime() time.Time

func (Heading3Block) MarshalJSON added in v0.7.0

func (b Heading3Block) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Heading3Block) Parent added in v0.7.0

func (b Heading3Block) Parent() Parent

type ID

type ID struct {
	ID string `json:"id"`
}

type Icon added in v0.5.0

type Icon struct {
	Type IconType `json:"type"`

	Emoji    *string       `json:"emoji,omitempty"`
	File     *FileFile     `json:"file,omitempty"`
	External *FileExternal `json:"external,omitempty"`
}

Icon has one non-nil Emoji or External field, denoted by the corresponding IconType.

func (Icon) Validate added in v0.5.0

func (icon Icon) Validate() error

type IconType added in v0.5.0

type IconType string
const (
	IconTypeEmoji    IconType = "emoji"
	IconTypeFile     IconType = "file"
	IconTypeExternal IconType = "external"
)

type ImageBlock added in v0.7.0

type ImageBlock struct {
	Type     FileType      `json:"type"`
	File     *FileFile     `json:"file,omitempty"`
	External *FileExternal `json:"external,omitempty"`
	Caption  []RichText    `json:"caption,omitempty"`
	// contains filtered or unexported fields
}

func (ImageBlock) Archived added in v0.7.0

func (b ImageBlock) Archived() bool

func (ImageBlock) CreatedBy added in v0.7.0

func (b ImageBlock) CreatedBy() BaseUser

func (ImageBlock) CreatedTime added in v0.7.0

func (b ImageBlock) CreatedTime() time.Time

func (ImageBlock) HasChildren added in v0.7.0

func (b ImageBlock) HasChildren() bool

func (ImageBlock) ID added in v0.7.0

func (b ImageBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (ImageBlock) LastEditedBy added in v0.7.0

func (b ImageBlock) LastEditedBy() BaseUser

func (ImageBlock) LastEditedTime added in v0.7.0

func (b ImageBlock) LastEditedTime() time.Time

func (ImageBlock) MarshalJSON added in v0.7.0

func (b ImageBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (ImageBlock) Parent added in v0.7.0

func (b ImageBlock) Parent() Parent
type Link struct {
	URL string `json:"url"`
}

type LinkPreview added in v0.5.0

type LinkPreview struct {
	URL string `json:"url"`
}

type LinkPreviewBlock added in v0.7.0

type LinkPreviewBlock struct {
	URL string `json:"url"`
	// contains filtered or unexported fields
}

func (LinkPreviewBlock) Archived added in v0.7.0

func (b LinkPreviewBlock) Archived() bool

func (LinkPreviewBlock) CreatedBy added in v0.7.0

func (b LinkPreviewBlock) CreatedBy() BaseUser

func (LinkPreviewBlock) CreatedTime added in v0.7.0

func (b LinkPreviewBlock) CreatedTime() time.Time

func (LinkPreviewBlock) HasChildren added in v0.7.0

func (b LinkPreviewBlock) HasChildren() bool

func (LinkPreviewBlock) ID added in v0.7.0

func (b LinkPreviewBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (LinkPreviewBlock) LastEditedBy added in v0.7.0

func (b LinkPreviewBlock) LastEditedBy() BaseUser

func (LinkPreviewBlock) LastEditedTime added in v0.7.0

func (b LinkPreviewBlock) LastEditedTime() time.Time

func (LinkPreviewBlock) MarshalJSON added in v0.7.0

func (b LinkPreviewBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (LinkPreviewBlock) Parent added in v0.7.0

func (b LinkPreviewBlock) Parent() Parent

type LinkToPageBlock added in v0.7.0

type LinkToPageBlock struct {
	Type       LinkToPageType `json:"type"`
	PageID     string         `json:"page_id,omitempty"`
	DatabaseID string         `json:"database_id,omitempty"`
	// contains filtered or unexported fields
}

func (LinkToPageBlock) Archived added in v0.7.0

func (b LinkToPageBlock) Archived() bool

func (LinkToPageBlock) CreatedBy added in v0.7.0

func (b LinkToPageBlock) CreatedBy() BaseUser

func (LinkToPageBlock) CreatedTime added in v0.7.0

func (b LinkToPageBlock) CreatedTime() time.Time

func (LinkToPageBlock) HasChildren added in v0.7.0

func (b LinkToPageBlock) HasChildren() bool

func (LinkToPageBlock) ID added in v0.7.0

func (b LinkToPageBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (LinkToPageBlock) LastEditedBy added in v0.7.0

func (b LinkToPageBlock) LastEditedBy() BaseUser

func (LinkToPageBlock) LastEditedTime added in v0.7.0

func (b LinkToPageBlock) LastEditedTime() time.Time

func (LinkToPageBlock) MarshalJSON added in v0.7.0

func (b LinkToPageBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (LinkToPageBlock) Parent added in v0.7.0

func (b LinkToPageBlock) Parent() Parent

type LinkToPageType added in v0.5.0

type LinkToPageType string
const (
	LinkToPageTypePageID     LinkToPageType = "page_id"
	LinkToPageTypeDatabaseID LinkToPageType = "database_id"
)

type ListUsersResponse

type ListUsersResponse struct {
	Results    []User  `json:"results"`
	HasMore    bool    `json:"has_more"`
	NextCursor *string `json:"next_cursor"`
}

ListUsersResponse contains results (users) and pagination data returned from a list request.

type Mention

type Mention struct {
	Type MentionType `json:"type"`

	User            *User            `json:"user,omitempty"`
	Page            *ID              `json:"page,omitempty"`
	Database        *ID              `json:"database,omitempty"`
	Date            *Date            `json:"date,omitempty"`
	LinkPreview     *LinkPreview     `json:"link_preview,omitempty"`
	TemplateMention *TemplateMention `json:"template_mention,omitempty"`
}

type MentionType

type MentionType string

type MultiSelectDatabaseQueryFilter

type MultiSelectDatabaseQueryFilter struct {
	Contains       string `json:"contains,omitempty"`
	DoesNotContain string `json:"does_not_contain,omitempty"`
	IsEmpty        bool   `json:"is_empty,omitempty"`
	IsNotEmpty     bool   `json:"is_not_empty,omitempty"`
}

type NumberDatabaseQueryFilter

type NumberDatabaseQueryFilter struct {
	Equals               *int `json:"equals,omitempty"`
	DoesNotEqual         *int `json:"does_not_equal,omitempty"`
	GreaterThan          *int `json:"greater_than,omitempty"`
	LessThan             *int `json:"less_than,omitempty"`
	GreaterThanOrEqualTo *int `json:"greater_than_or_equal_to,omitempty"`
	LessThanOrEqualTo    *int `json:"less_than_or_equal_to,omitempty"`
	IsEmpty              bool `json:"is_empty,omitempty"`
	IsNotEmpty           bool `json:"is_not_empty,omitempty"`
}

type NumberFormat added in v0.1.1

type NumberFormat string

type NumberMetadata

type NumberMetadata struct {
	Format NumberFormat `json:"format"`
}

Database property metadata types.

type NumberedListItemBlock added in v0.7.0

type NumberedListItemBlock struct {
	RichText []RichText `json:"rich_text"`
	Children []Block    `json:"children,omitempty"`
	Color    Color      `json:"color,omitempty"`
	// contains filtered or unexported fields
}

func (NumberedListItemBlock) Archived added in v0.7.0

func (b NumberedListItemBlock) Archived() bool

func (NumberedListItemBlock) CreatedBy added in v0.7.0

func (b NumberedListItemBlock) CreatedBy() BaseUser

func (NumberedListItemBlock) CreatedTime added in v0.7.0

func (b NumberedListItemBlock) CreatedTime() time.Time

func (NumberedListItemBlock) HasChildren added in v0.7.0

func (b NumberedListItemBlock) HasChildren() bool

func (NumberedListItemBlock) ID added in v0.7.0

func (b NumberedListItemBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (NumberedListItemBlock) LastEditedBy added in v0.7.0

func (b NumberedListItemBlock) LastEditedBy() BaseUser

func (NumberedListItemBlock) LastEditedTime added in v0.7.0

func (b NumberedListItemBlock) LastEditedTime() time.Time

func (NumberedListItemBlock) MarshalJSON added in v0.7.0

func (b NumberedListItemBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (NumberedListItemBlock) Parent added in v0.7.0

func (b NumberedListItemBlock) Parent() Parent

type PDFBlock added in v0.7.0

type PDFBlock struct {
	Type     FileType      `json:"type"`
	File     *FileFile     `json:"file,omitempty"`
	External *FileExternal `json:"external,omitempty"`
	Caption  []RichText    `json:"caption,omitempty"`
	// contains filtered or unexported fields
}

func (PDFBlock) Archived added in v0.7.0

func (b PDFBlock) Archived() bool

func (PDFBlock) CreatedBy added in v0.7.0

func (b PDFBlock) CreatedBy() BaseUser

func (PDFBlock) CreatedTime added in v0.7.0

func (b PDFBlock) CreatedTime() time.Time

func (PDFBlock) HasChildren added in v0.7.0

func (b PDFBlock) HasChildren() bool

func (PDFBlock) ID added in v0.7.0

func (b PDFBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (PDFBlock) LastEditedBy added in v0.7.0

func (b PDFBlock) LastEditedBy() BaseUser

func (PDFBlock) LastEditedTime added in v0.7.0

func (b PDFBlock) LastEditedTime() time.Time

func (PDFBlock) MarshalJSON added in v0.7.0

func (b PDFBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (PDFBlock) Parent added in v0.7.0

func (b PDFBlock) Parent() Parent

type Page

type Page struct {
	ID             string    `json:"id"`
	CreatedTime    time.Time `json:"created_time"`
	CreatedBy      *BaseUser `json:"created_by,omitempty"`
	LastEditedTime time.Time `json:"last_edited_time"`
	LastEditedBy   *BaseUser `json:"last_edited_by,omitempty"`
	Parent         Parent    `json:"parent"`
	Archived       bool      `json:"archived"`
	URL            string    `json:"url"`
	Icon           *Icon     `json:"icon,omitempty"`
	Cover          *Cover    `json:"cover,omitempty"`

	// Properties differ between parent type.
	// See the `UnmarshalJSON` method.
	Properties interface{} `json:"properties"`
}

Page is a resource on the Notion platform. Its parent is either a workspace, another page, or a database. See: https://developers.notion.com/reference/page

func (*Page) UnmarshalJSON

func (p *Page) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

Pages get a different Properties type based on the parent of the page. If parent type is `workspace` or `page_id`, PageProperties is used. Else if parent type is `database_id`, DatabasePageProperties is used.

type PagePropItem added in v0.5.0

type PagePropItem struct {
	Type DatabasePropertyType `json:"type"`

	Title          RichText      `json:"title"`
	RichText       RichText      `json:"rich_text"`
	Number         float64       `json:"number"`
	Select         SelectOptions `json:"select"`
	MultiSelect    SelectOptions `json:"multi_select"`
	Date           Date          `json:"date"`
	Formula        FormulaResult `json:"formula"`
	Relation       Relation      `json:"relation"`
	Rollup         RollupResult  `json:"rollup"`
	People         User          `json:"people"`
	Files          File          `json:"files"`
	Checkbox       bool          `json:"checkbox"`
	URL            string        `json:"url"`
	Email          string        `json:"email"`
	PhoneNumber    string        `json:"phone_number"`
	CreatedTime    time.Time     `json:"created_time"`
	CreatedBy      User          `json:"created_by"`
	LastEditedTime time.Time     `json:"last_edited_time"`
	LastEditedBy   User          `json:"last_edited_by"`
}

PagePropItem is used for a *single* property object value, e.g. for a `rich_text` property, a single value of an array of rich text elements. This type is used when fetching single properties.

type PagePropListItem added in v0.7.0

type PagePropListItem struct {
	ID      string               `json:"id"`
	Type    DatabasePropertyType `json:"type"`
	NextURL string               `json:"next_url"`
	Rollup  RollupResult         `json:"rollup"`
}

PagePropListItem describes the property returned in a paginated list response (e.g. `type` is `title`, `rich_text`, `relation` or `people`). See: https://developers.notion.com/reference/property-item-object#paginated-property-values

type PagePropResponse added in v0.5.0

type PagePropResponse struct {
	PagePropItem

	Results      []PagePropItem   `json:"results"`
	HasMore      bool             `json:"has_more"`
	NextCursor   string           `json:"next_cursor"`
	PropertyItem PagePropListItem `json:"property_item"`
}

PagePropResponse contains a single database page property item or a list of items. For rollup props with an aggregation, both a `results` array and a `rollup` field (inside `page_property`) is included. See: https://developers.notion.com/reference/retrieve-a-page-property#rollup-properties

type PageProperties

type PageProperties struct {
	Title PageTitle `json:"title"`
}

PageProperties are properties of a page whose parent is a page or a workspace.

type PageTitle

type PageTitle struct {
	Title []RichText `json:"title"`
}

type PaginationQuery

type PaginationQuery struct {
	StartCursor string
	PageSize    int
}

type ParagraphBlock added in v0.7.0

type ParagraphBlock struct {
	RichText []RichText `json:"rich_text"`
	Children []Block    `json:"children,omitempty"`
	Color    Color      `json:"color,omitempty"`
	// contains filtered or unexported fields
}

func (ParagraphBlock) Archived added in v0.7.0

func (b ParagraphBlock) Archived() bool

func (ParagraphBlock) CreatedBy added in v0.7.0

func (b ParagraphBlock) CreatedBy() BaseUser

func (ParagraphBlock) CreatedTime added in v0.7.0

func (b ParagraphBlock) CreatedTime() time.Time

func (ParagraphBlock) HasChildren added in v0.7.0

func (b ParagraphBlock) HasChildren() bool

func (ParagraphBlock) ID added in v0.7.0

func (b ParagraphBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (ParagraphBlock) LastEditedBy added in v0.7.0

func (b ParagraphBlock) LastEditedBy() BaseUser

func (ParagraphBlock) LastEditedTime added in v0.7.0

func (b ParagraphBlock) LastEditedTime() time.Time

func (ParagraphBlock) MarshalJSON added in v0.7.0

func (b ParagraphBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (ParagraphBlock) Parent added in v0.7.0

func (b ParagraphBlock) Parent() Parent

type Parent added in v0.4.0

type Parent struct {
	Type ParentType `json:"type,omitempty"`

	BlockID    string `json:"block_id,omitempty"`
	PageID     string `json:"page_id,omitempty"`
	DatabaseID string `json:"database_id,omitempty"`
	Workspace  bool   `json:"workspace,omitempty"`
}

type ParentType

type ParentType string
const (
	ParentTypeDatabase  ParentType = "database_id"
	ParentTypePage      ParentType = "page_id"
	ParentTypeBlock     ParentType = "block_id"
	ParentTypeWorkspace ParentType = "workspace"
)

type People added in v0.3.0

type People struct {
	People []User `json:"people"`
}

type PeopleDatabaseQueryFilter

type PeopleDatabaseQueryFilter struct {
	Contains       string `json:"contains,omitempty"`
	DoesNotContain string `json:"does_not_contain,omitempty"`
	IsEmpty        bool   `json:"is_empty,omitempty"`
	IsNotEmpty     bool   `json:"is_not_empty,omitempty"`
}

type Person

type Person struct {
	Email string `json:"email"`
}

type QuoteBlock added in v0.7.0

type QuoteBlock struct {
	RichText []RichText `json:"rich_text"`
	Children []Block    `json:"children,omitempty"`
	Color    Color      `json:"color,omitempty"`
	// contains filtered or unexported fields
}

func (QuoteBlock) Archived added in v0.7.0

func (b QuoteBlock) Archived() bool

func (QuoteBlock) CreatedBy added in v0.7.0

func (b QuoteBlock) CreatedBy() BaseUser

func (QuoteBlock) CreatedTime added in v0.7.0

func (b QuoteBlock) CreatedTime() time.Time

func (QuoteBlock) HasChildren added in v0.7.0

func (b QuoteBlock) HasChildren() bool

func (QuoteBlock) ID added in v0.7.0

func (b QuoteBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (QuoteBlock) LastEditedBy added in v0.7.0

func (b QuoteBlock) LastEditedBy() BaseUser

func (QuoteBlock) LastEditedTime added in v0.7.0

func (b QuoteBlock) LastEditedTime() time.Time

func (QuoteBlock) MarshalJSON added in v0.7.0

func (b QuoteBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (QuoteBlock) Parent added in v0.7.0

func (b QuoteBlock) Parent() Parent

type Relation added in v0.3.0

type Relation struct {
	ID string `json:"id"`
}

type RelationDatabaseQueryFilter

type RelationDatabaseQueryFilter struct {
	Contains       string `json:"contains,omitempty"`
	DoesNotContain string `json:"does_not_contain,omitempty"`
	IsEmpty        bool   `json:"is_empty,omitempty"`
	IsNotEmpty     bool   `json:"is_not_empty,omitempty"`
}

type RelationMetadata

type RelationMetadata struct {
	DatabaseID string       `json:"database_id,omitempty"`
	Type       RelationType `json:"type,omitempty"`

	SingleProperty *struct{}             `json:"single_property,omitempty"`
	DualProperty   *DualPropertyRelation `json:"dual_property,omitempty"`
}

Database property metadata types.

type RelationType added in v0.7.0

type RelationType string

type RichText

type RichText struct {
	Type        RichTextType `json:"type,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`

	PlainText string    `json:"plain_text,omitempty"`
	HRef      *string   `json:"href,omitempty"`
	Text      *Text     `json:"text,omitempty"`
	Mention   *Mention  `json:"mention,omitempty"`
	Equation  *Equation `json:"equation,omitempty"`
}

type RichTextType

type RichTextType string
const (
	RichTextTypeText     RichTextType = "text"
	RichTextTypeMention  RichTextType = "mention"
	RichTextTypeEquation RichTextType = "equation"
)

type RollupDatabaseQueryFilter added in v0.7.0

type RollupDatabaseQueryFilter struct {
	Any    *DatabaseQueryPropertyFilter `json:"any,omitempty"`
	Every  *DatabaseQueryPropertyFilter `json:"every,omitempty"`
	None   *DatabaseQueryPropertyFilter `json:"none,omitempty"`
	Number *NumberDatabaseQueryFilter   `json:"number,omitempty"`
	Date   *DatePropertyFilter          `json:"date,omitempty"`
}

type RollupFunction added in v0.5.0

type RollupFunction string

type RollupMetadata

type RollupMetadata struct {
	RelationPropName string         `json:"relation_property_name,omitempty"`
	RelationPropID   string         `json:"relation_property_id,omitempty"`
	RollupPropName   string         `json:"rollup_property_name,omitempty"`
	RollupPropID     string         `json:"rollup_property_id,omitempty"`
	Function         RollupFunction `json:"function,omitempty"`
}

Database property metadata types.

type RollupResult added in v0.3.0

type RollupResult struct {
	Type RollupResultType `json:"type"`

	Number *float64               `json:"number,omitempty"`
	Date   *Date                  `json:"date,omitempty"`
	Array  []DatabasePageProperty `json:"array,omitempty"`
}

func (RollupResult) Value added in v0.3.0

func (r RollupResult) Value() interface{}

Value returns the underlying result value of an evaluated rollup.

type RollupResultType added in v0.3.0

type RollupResultType string

type SearchFilter

type SearchFilter struct {
	Value    string `json:"value"`
	Property string `json:"property"`
}

type SearchOpts

type SearchOpts struct {
	Query       string        `json:"query,omitempty"`
	Sort        *SearchSort   `json:"sort,omitempty"`
	Filter      *SearchFilter `json:"filter,omitempty"`
	StartCursor string        `json:"start_cursor,omitempty"`
	PageSize    int           `json:"page_size,omitempty"`
}

type SearchResponse

type SearchResponse struct {
	// Results are either pages or databases. See `SearchResponse.UnmarshalJSON`.
	Results    SearchResults `json:"results"`
	HasMore    bool          `json:"has_more"`
	NextCursor *string       `json:"next_cursor"`
}

type SearchResults

type SearchResults []interface{}

func (*SearchResults) UnmarshalJSON

func (sr *SearchResults) UnmarshalJSON(b []byte) error

type SearchSort

type SearchSort struct {
	Direction SortDirection       `json:"direction,omitempty"`
	Timestamp SearchSortTimestamp `json:"timestamp"`
}

type SearchSortTimestamp added in v0.3.3

type SearchSortTimestamp string
const SearchSortTimestampLastEditedTime SearchSortTimestamp = "last_edited_time"

type SelectDatabaseQueryFilter

type SelectDatabaseQueryFilter struct {
	Equals       string `json:"equals,omitempty"`
	DoesNotEqual string `json:"does_not_equal,omitempty"`
	IsEmpty      bool   `json:"is_empty,omitempty"`
	IsNotEmpty   bool   `json:"is_not_empty,omitempty"`
}

type SelectMetadata

type SelectMetadata struct {
	Options []SelectOptions `json:"options"`
}

Database property metadata types.

type SelectOptions

type SelectOptions struct {
	ID    string `json:"id,omitempty"`
	Name  string `json:"name,omitempty"`
	Color Color  `json:"color,omitempty"`
}

type SortDirection

type SortDirection string

type SortTimestamp

type SortTimestamp string

type StatusDatabaseQueryFilter added in v0.7.0

type StatusDatabaseQueryFilter struct {
	Equals       string `json:"equals,omitempty"`
	DoesNotEqual string `json:"does_not_equal,omitempty"`
	IsEmpty      bool   `json:"is_empty,omitempty"`
	IsNotEmpty   bool   `json:"is_not_empty,omitempty"`
}

type StatusGroup added in v0.7.0

type StatusGroup struct {
	ID        string   `json:"id,omitempty"`
	Name      string   `json:"name,omitempty"`
	Color     Color    `json:"color,omitempty"`
	OptionIDs []string `json:"option_ids,omitempty"`
}

type StatusMetadata added in v0.7.0

type StatusMetadata struct {
	Options []SelectOptions `json:"options"`
	Groups  []StatusGroup   `json:"groups"`
}

Database property metadata types.

type SyncedBlock added in v0.5.0

type SyncedBlock struct {
	SyncedFrom *SyncedFrom `json:"synced_from"`
	Children   []Block     `json:"children,omitempty"`
	// contains filtered or unexported fields
}

func (SyncedBlock) Archived added in v0.7.0

func (b SyncedBlock) Archived() bool

func (SyncedBlock) CreatedBy added in v0.7.0

func (b SyncedBlock) CreatedBy() BaseUser

func (SyncedBlock) CreatedTime added in v0.7.0

func (b SyncedBlock) CreatedTime() time.Time

func (SyncedBlock) HasChildren added in v0.7.0

func (b SyncedBlock) HasChildren() bool

func (SyncedBlock) ID added in v0.7.0

func (b SyncedBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (SyncedBlock) LastEditedBy added in v0.7.0

func (b SyncedBlock) LastEditedBy() BaseUser

func (SyncedBlock) LastEditedTime added in v0.7.0

func (b SyncedBlock) LastEditedTime() time.Time

func (SyncedBlock) MarshalJSON added in v0.7.0

func (b SyncedBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (SyncedBlock) Parent added in v0.7.0

func (b SyncedBlock) Parent() Parent

type SyncedFrom added in v0.5.0

type SyncedFrom struct {
	Type    SyncedFromType `json:"type"`
	BlockID string         `json:"block_id"`
}

type SyncedFromType added in v0.5.0

type SyncedFromType string
const SyncedFromTypeBlockID SyncedFromType = "block_id"

type TableBlock added in v0.7.0

type TableBlock struct {
	TableWidth      int     `json:"table_width"`
	HasColumnHeader bool    `json:"has_column_header"`
	HasRowHeader    bool    `json:"has_row_header"`
	Children        []Block `json:"children,omitempty"`
	// contains filtered or unexported fields
}

func (TableBlock) Archived added in v0.7.0

func (b TableBlock) Archived() bool

func (TableBlock) CreatedBy added in v0.7.0

func (b TableBlock) CreatedBy() BaseUser

func (TableBlock) CreatedTime added in v0.7.0

func (b TableBlock) CreatedTime() time.Time

func (TableBlock) HasChildren added in v0.7.0

func (b TableBlock) HasChildren() bool

func (TableBlock) ID added in v0.7.0

func (b TableBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (TableBlock) LastEditedBy added in v0.7.0

func (b TableBlock) LastEditedBy() BaseUser

func (TableBlock) LastEditedTime added in v0.7.0

func (b TableBlock) LastEditedTime() time.Time

func (TableBlock) MarshalJSON added in v0.7.0

func (b TableBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (TableBlock) Parent added in v0.7.0

func (b TableBlock) Parent() Parent

type TableOfContentsBlock added in v0.7.0

type TableOfContentsBlock struct {
	Color Color `json:"color,omitempty"`
	// contains filtered or unexported fields
}

func (TableOfContentsBlock) Archived added in v0.7.0

func (b TableOfContentsBlock) Archived() bool

func (TableOfContentsBlock) CreatedBy added in v0.7.0

func (b TableOfContentsBlock) CreatedBy() BaseUser

func (TableOfContentsBlock) CreatedTime added in v0.7.0

func (b TableOfContentsBlock) CreatedTime() time.Time

func (TableOfContentsBlock) HasChildren added in v0.7.0

func (b TableOfContentsBlock) HasChildren() bool

func (TableOfContentsBlock) ID added in v0.7.0

func (b TableOfContentsBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (TableOfContentsBlock) LastEditedBy added in v0.7.0

func (b TableOfContentsBlock) LastEditedBy() BaseUser

func (TableOfContentsBlock) LastEditedTime added in v0.7.0

func (b TableOfContentsBlock) LastEditedTime() time.Time

func (TableOfContentsBlock) MarshalJSON added in v0.7.0

func (b TableOfContentsBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (TableOfContentsBlock) Parent added in v0.7.0

func (b TableOfContentsBlock) Parent() Parent

type TableRowBlock added in v0.7.0

type TableRowBlock struct {
	Cells [][]RichText `json:"cells"`
	// contains filtered or unexported fields
}

func (TableRowBlock) Archived added in v0.7.0

func (b TableRowBlock) Archived() bool

func (TableRowBlock) CreatedBy added in v0.7.0

func (b TableRowBlock) CreatedBy() BaseUser

func (TableRowBlock) CreatedTime added in v0.7.0

func (b TableRowBlock) CreatedTime() time.Time

func (TableRowBlock) HasChildren added in v0.7.0

func (b TableRowBlock) HasChildren() bool

func (TableRowBlock) ID added in v0.7.0

func (b TableRowBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (TableRowBlock) LastEditedBy added in v0.7.0

func (b TableRowBlock) LastEditedBy() BaseUser

func (TableRowBlock) LastEditedTime added in v0.7.0

func (b TableRowBlock) LastEditedTime() time.Time

func (TableRowBlock) MarshalJSON added in v0.7.0

func (b TableRowBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (TableRowBlock) Parent added in v0.7.0

func (b TableRowBlock) Parent() Parent

type TemplateBlock added in v0.7.0

type TemplateBlock struct {
	RichText []RichText `json:"rich_text"`
	Children []Block    `json:"children,omitempty"`
	// contains filtered or unexported fields
}

func (TemplateBlock) Archived added in v0.7.0

func (b TemplateBlock) Archived() bool

func (TemplateBlock) CreatedBy added in v0.7.0

func (b TemplateBlock) CreatedBy() BaseUser

func (TemplateBlock) CreatedTime added in v0.7.0

func (b TemplateBlock) CreatedTime() time.Time

func (TemplateBlock) HasChildren added in v0.7.0

func (b TemplateBlock) HasChildren() bool

func (TemplateBlock) ID added in v0.7.0

func (b TemplateBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (TemplateBlock) LastEditedBy added in v0.7.0

func (b TemplateBlock) LastEditedBy() BaseUser

func (TemplateBlock) LastEditedTime added in v0.7.0

func (b TemplateBlock) LastEditedTime() time.Time

func (TemplateBlock) MarshalJSON added in v0.7.0

func (b TemplateBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (TemplateBlock) Parent added in v0.7.0

func (b TemplateBlock) Parent() Parent

type TemplateMention added in v0.7.0

type TemplateMention struct {
	Type TemplateMentionType `json:"type"`

	TemplateMentionDate *TemplateMentionDateType `json:"template_mention_date,omitempty"`
	TemplateMentionUser *TemplateMentionUserType `json:"template_mention_user,omitempty"`
}

type TemplateMentionDateType added in v0.7.0

type TemplateMentionDateType string

type TemplateMentionType added in v0.7.0

type TemplateMentionType string

type TemplateMentionUserType added in v0.7.0

type TemplateMentionUserType string

type Text

type Text struct {
	Content string `json:"content"`
	Link    *Link  `json:"link,omitempty"`
}

type TextPropertyFilter added in v0.7.0

type TextPropertyFilter struct {
	Equals         string `json:"equals,omitempty"`
	DoesNotEqual   string `json:"does_not_equal,omitempty"`
	Contains       string `json:"contains,omitempty"`
	DoesNotContain string `json:"does_not_contain,omitempty"`
	StartsWith     string `json:"starts_with,omitempty"`
	EndsWith       string `json:"ends_with,omitempty"`
	IsEmpty        bool   `json:"is_empty,omitempty"`
	IsNotEmpty     bool   `json:"is_not_empty,omitempty"`
}

type Timestamp added in v0.7.0

type Timestamp string

type ToDoBlock added in v0.7.0

type ToDoBlock struct {
	RichText []RichText `json:"rich_text"`
	Children []Block    `json:"children,omitempty"`
	Checked  *bool      `json:"checked,omitempty"`
	Color    Color      `json:"color,omitempty"`
	// contains filtered or unexported fields
}

func (ToDoBlock) Archived added in v0.7.0

func (b ToDoBlock) Archived() bool

func (ToDoBlock) CreatedBy added in v0.7.0

func (b ToDoBlock) CreatedBy() BaseUser

func (ToDoBlock) CreatedTime added in v0.7.0

func (b ToDoBlock) CreatedTime() time.Time

func (ToDoBlock) HasChildren added in v0.7.0

func (b ToDoBlock) HasChildren() bool

func (ToDoBlock) ID added in v0.7.0

func (b ToDoBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (ToDoBlock) LastEditedBy added in v0.7.0

func (b ToDoBlock) LastEditedBy() BaseUser

func (ToDoBlock) LastEditedTime added in v0.7.0

func (b ToDoBlock) LastEditedTime() time.Time

func (ToDoBlock) MarshalJSON added in v0.7.0

func (b ToDoBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (ToDoBlock) Parent added in v0.7.0

func (b ToDoBlock) Parent() Parent

type ToggleBlock added in v0.7.0

type ToggleBlock struct {
	RichText []RichText `json:"rich_text"`
	Children []Block    `json:"children,omitempty"`
	Color    Color      `json:"color,omitempty"`
	// contains filtered or unexported fields
}

func (ToggleBlock) Archived added in v0.7.0

func (b ToggleBlock) Archived() bool

func (ToggleBlock) CreatedBy added in v0.7.0

func (b ToggleBlock) CreatedBy() BaseUser

func (ToggleBlock) CreatedTime added in v0.7.0

func (b ToggleBlock) CreatedTime() time.Time

func (ToggleBlock) HasChildren added in v0.7.0

func (b ToggleBlock) HasChildren() bool

func (ToggleBlock) ID added in v0.7.0

func (b ToggleBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (ToggleBlock) LastEditedBy added in v0.7.0

func (b ToggleBlock) LastEditedBy() BaseUser

func (ToggleBlock) LastEditedTime added in v0.7.0

func (b ToggleBlock) LastEditedTime() time.Time

func (ToggleBlock) MarshalJSON added in v0.7.0

func (b ToggleBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (ToggleBlock) Parent added in v0.7.0

func (b ToggleBlock) Parent() Parent

type UpdateDatabaseParams added in v0.5.0

type UpdateDatabaseParams struct {
	Title       []RichText                   `json:"title,omitempty"`
	Description []RichText                   `json:"description,omitempty"`
	Properties  map[string]*DatabaseProperty `json:"properties,omitempty"`
	Icon        *Icon                        `json:"icon,omitempty"`
	Cover       *Cover                       `json:"cover,omitempty"`
	Archived    *bool                        `json:"archived,omitempty"`
	IsInline    *bool                        `json:"is_inline,omitempty"`
}

UpdateDatabaseParams are the params used for updating a database.

func (UpdateDatabaseParams) Validate added in v0.5.0

func (p UpdateDatabaseParams) Validate() error

Validate validates params for updating a database.

type UpdatePageParams

type UpdatePageParams struct {
	DatabasePageProperties DatabasePageProperties `json:"properties,omitempty"`
	Archived               *bool                  `json:"archived,omitempty"`
	Icon                   *Icon                  `json:"icon,omitempty"`
	Cover                  *Cover                 `json:"cover,omitempty"`
}

UpdatePageParams is used for updating a page. At least one field should have a non-empty value.

func (UpdatePageParams) Validate

func (p UpdatePageParams) Validate() error

type User

type User struct {
	BaseUser

	Type      UserType `json:"type"`
	Name      string   `json:"name"`
	AvatarURL string   `json:"avatar_url"`

	Person *Person `json:"person"`
	Bot    *Bot    `json:"bot"`
}

type UserType added in v0.5.0

type UserType string
const (
	UserTypePerson UserType = "person"
	UserTypeBot    UserType = "bot"
)

type VideoBlock added in v0.7.0

type VideoBlock struct {
	Type     FileType      `json:"type"`
	File     *FileFile     `json:"file,omitempty"`
	External *FileExternal `json:"external,omitempty"`
	Caption  []RichText    `json:"caption,omitempty"`
	// contains filtered or unexported fields
}

func (VideoBlock) Archived added in v0.7.0

func (b VideoBlock) Archived() bool

func (VideoBlock) CreatedBy added in v0.7.0

func (b VideoBlock) CreatedBy() BaseUser

func (VideoBlock) CreatedTime added in v0.7.0

func (b VideoBlock) CreatedTime() time.Time

func (VideoBlock) HasChildren added in v0.7.0

func (b VideoBlock) HasChildren() bool

func (VideoBlock) ID added in v0.7.0

func (b VideoBlock) ID() string

ID returns the identifier (UUIDv4) for the block.

func (VideoBlock) LastEditedBy added in v0.7.0

func (b VideoBlock) LastEditedBy() BaseUser

func (VideoBlock) LastEditedTime added in v0.7.0

func (b VideoBlock) LastEditedTime() time.Time

func (VideoBlock) MarshalJSON added in v0.7.0

func (b VideoBlock) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (VideoBlock) Parent added in v0.7.0

func (b VideoBlock) Parent() Parent

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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