Categorygithub.com/mattheath/notionapi
modulepackage
0.0.0-20200102215314-a430ef1491bc
Repository: https://github.com/mattheath/notionapi.git
Documentation: pkg.go.dev

# README

About notionapi

This is an unofficial, Go API for https://notion.so. Mostly for reading, limited write capabilities.

It allows you to retrieve content of a Notion page in structured format.

You can then e.g. convert that format to HTML.

It's used in https://presstige.io/

Documentation:

You can learn how I reverse-engineered the Notion API in order to write this library.

Real-life usage

I use this API to publish my blog and series of programming books from content stored in Notion.

Notion serves as a CMS (Content Management System). I write and edit pages in Notion.

I use custom Go program to download Notion pages using this this library and converts pages to HTML. It then publishes the result to Netlify.

You can see the code at https://github.com/kjk/blog and https://github.com/essentialbooks/books/

Implementations for other languages

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Dump writes a simple representation of Page to w.
DumpToString returns a simple representation of Page as a string.
ExtractNoDashIDFromNotionURL tries to extract notion page id from notion URL, e.g.
ForEachBlock traverses the tree of blocks and calls cb on every block in depth-first order.
FormatDate provides default formatting for Date TODO: add time zone, maybe.
GetFileContentType tries to figure out the content type of the file using http detection.
GetUserNameByID returns a full user name given user id it's a helper function.
IsErrPageNotFound returns true if err is an instance of ErrPageNotFound.
IsValidDashID returns true if id looks like a valid Notion dash id.
IsValidNoDashID returns true if id looks like a valid Notion no dash id.
Logf is for debug logging, will log using LogFunc (if set).
MaybePanic will panic if PanicOnFailures is true.
Now returns now in micro seconds as expected by the notion API.
ParseTextSpans parses content from JSON into an easier to use form.
SafeName returns a file-system safe name.
TextSpansToString returns flattened content of inline blocks, without formatting.
ToDashID convert id in format bb760e2dd6794b64b2a903005b21870a to bb760e2d-d679-4b64-b2a9-03005b21870a If id is not in that format, we leave it untouched.
ToNoDashID converts 2131b10c-ebf6-4938-a127-7089ff02dbe4 to 2131b10cebf64938a1277089ff02dbe4.

# Constants

AttrBold represents bold block.
AttrCode represents code block.
AttrComment represents a comment block.
AttrDate represents a date.
AttrHighlight represents text high-light.
AttrItalic represents italic block.
AttrLink represnts a link (url).
AtttrPage represents a link to a Notion page.
AttrStrikeThrought represents strikethrough block.
AttrUser represents an id of a user.
BlockAudio is audio embed (e.g.
BlockBookmark is a bookmark block.
BlockBreadcrumb is breadcrumb block.
BlockBulletedList is a bulleted list block.
BlockCallout is a callout.
BlockCode is a code block.
BlockCodepen is embedded codepen block.
BlockCollectionView is a collection view block for inline collections.
BlockCollectionViewPage is a page that is a collection.
BlockColumn is a child of TypeColumnList.
BlockColumnList is for multi-column.
BlockComment is a comment block.
BlockDivider is a divider block.
BlockDrive is embedded Google Drive file.
BlockEmbed is a generic embed link.
BlockEquation is TeX equation block.
BlockFactory represents a factory block.
BlockFigma represents figma embed.
BlockFile is an embedded file.
BlockGist is embedded gist block.
BlockHeader is a header block.
BlockImage is an image block.
BlockMaps is embedded Google Map block.
BlockNumberedList is a numbered list block.
BlockPage is a notion Page.
BlockPDF is an embedded pdf file.
BlockQuote is a quote block.
BlockSubHeader is a header block.
BlockSubSubHeader.
BlockTableOfContents is table of contents.
BlockText is a text block.
BlockTodo is a todo block.
BlockToggle is a toggle block.
BlockTweet is embedded gist block.
BlockVideo is youtube video embed.
CollectionViewTypeTable is a lists block.
TODO: those are probably CollectionViewType CollectionViewTypeTable is a table block.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
for Schema.Type.
Command Types.
Command Types.
Command Types.
Command Types.
DateTypeDate represents a date in Date.Type.
DateTypeDateTime represents a datetime in Date.Type.
No description provided by the author
No description provided by the author
No description provided by the author
PermissionTypePublic describes permissions for public.
PermissionTypeUser describes permissions for a user.
value of Permission.Type.
RoleEditor represents an editor.
RoleReader represents a reader.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
those are Record.Type and determine the type of Record.Value.
No description provided by the author
TextSpanSpecial is what Notion uses for text to represent @user and @date blocks.

# Variables

TODO: maybe a logger io.Writer instead? LogFunc allows intercepting debug logs.
PanicOnFailures will force panics on unexpected situations.

# Structs

AggregateQuery describes an aggregate query.
AggregationResult represents result of aggregation.
Block describes a block.
Client is client for invoking Notion API.
Collection describes a collection.
CollectionColumnOption describes options for ColumnTypeMultiSelect collection column.
CollectionFormat describes format of a collection.
CollectionPageProperty describes properties of a collection.
CollectionView represents a collection view.
No description provided by the author
ColumnInfo describes a schema for a given cell (column).
ColumnSchema describes a info of a collection column.
Comment describes a single comment in a discussion.
Date represents a date.
Discussion represents a discussion.
DownloadFileResponse is a result of DownloadFile().
No description provided by the author
No description provided by the author
ErrPageNotFound is returned by Client.DownloadPage if page cannot be found.
FormatBookmark describes format for BlockBookmark.
FormatBulletedList describes format for BlockBulletedList.
FormatCallout describes format for BlockCallout.
FormatCode describes format for BlockCode.
No description provided by the author
No description provided by the author
FormatColumn describes format for BlockColumn.
No description provided by the author
FormatEmbed describes format for BlockEmbed.
No description provided by the author
FormatHeader describes format for BlockHeader, BlockSubHeader, BlockSubSubHeader.
FormatImage describes format for BlockImage.
No description provided by the author
FormatNumberedList describes format for BlockNumberedList.
FormatPage describes format for BlockPage.
No description provided by the author
FormatTable describes format for BlockTable.
No description provided by the author
FormatText describes format for BlockText.
FormatToggle describes format for BlockToggle.
FormatVideo describes fromat form BlockVideo.
No description provided by the author
GetRecordValuesResponse represents response to /api/v3/getRecordValues api Note: it depends on Table type in request.
GetSignedFileUrlsResponse is a response of GetSignedFileUrls().
GetUploadFileUrlResponse is a response to POST /api/v3/getUploadFileUrl.
LoadPageChunkResponse is a response to /api/v3/loadPageChunk api.
No description provided by the author
Operation describes a single operation sent.
Page describes a single Notion page.
Permission represents user permissions o.
Query describes a query.
QueryCollectionResponse is json response for /api/v3/queryCollection.
QueryCollectionResult is part of response for /api/v3/queryCollection.
QueryFilter describes the filtering of a query.
QuerySort describes sorting of a query.
Record represents a polymorphic record.
RecordMap contains a collections of blocks, a space, users, and collections.
RecordRequest represents argument to GetRecordValues.
Reminder represents a date reminder.
Space describes Notion workspace.
SpacePermissionGroups represesnts group permissions for space.
SpacePermissions represents permissions for space.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TableProperty describes property of a table.
No description provided by the author
TableView represents a view of a table (Notion calls it a Collection View) Meant to be a representation that is easier to work with.
TextSpan describes a text with attributes.
User represents a Notion user.

# Type aliases

TextAttr describes attributes of a span of text First element is name of the attribute (e.g.