### Initialize Notion API Client Source: https://pkg.go.dev/github.com/jomei/notionapi Import the library and initialize the client with your integration token. Ensure you have obtained an integration token by following the Getting Started Guide. ```go import "github.com/jomei/notionapi" client := notionapi.NewClient("your_integration_token") ``` -------------------------------- ### Install notionapi Package Source: https://pkg.go.dev/github.com/jomei/notionapi Use this command to add the notionapi package to your Go project. ```bash go get github.com/jomei/notionapi ``` -------------------------------- ### GET /users Source: https://pkg.go.dev/github.com/jomei/notionapi Lists all users in the workspace with optional pagination. ```APIDOC ## GET /users ### Description Returns a paginated list of all users in the workspace. ### Method GET ### Endpoint /users ### Parameters #### Query Parameters - **pagination** (Pagination) - Optional - Pagination configuration for the request. ### Response #### Success Response (200) - **UsersListResponse** (object) - A list of users and pagination metadata. ``` -------------------------------- ### GET /users Source: https://pkg.go.dev/github.com/jomei/notionapi Returns a paginated list of Users for the workspace. ```APIDOC ## GET /users ### Description Returns a paginated list of Users for the workspace. The response may contain fewer than page_size of results. ### Method GET ### Endpoint /users ### Parameters #### Query Parameters - **page_size** (integer) - Optional - The number of results to return per page. - **next_cursor** (string) - Optional - The cursor for the next page of results. ### Response #### Success Response (200) - **Object** (string) - The object type, should be "list". - **Results** (array) - An array of User objects. - **NextCursor** (string) - The cursor for the next page of results, or null if there are no more pages. - **HasMore** (boolean) - Indicates if there are more pages of results. #### Response Example ```json { "object": "list", "results": [ { "object": "user", "id": "a-valid-user-id-1", "type": "person", "name": "Jane Doe", "avatar_url": "https://example.com/avatar.png" }, { "object": "user", "id": "a-valid-user-id-2", "type": "bot", "name": "My Integration Bot", "avatar_url": "https://example.com/bot_avatar.png", "bot": { "owner": {"workspace": true}, "workspace_icon": "https://example.com/workspace_icon.png", "workspace_id": "a-workspace-id", "workspace_name": "My Workspace" } } ], "next_cursor": "some-cursor-string", "has_more": true } ``` ``` -------------------------------- ### Define UserService Interface Source: https://pkg.go.dev/github.com/jomei/notionapi Interface for interacting with Notion user endpoints including listing, retrieving, and getting the current user. ```go type UserService interface { List(context.Context, *Pagination) (*UsersListResponse, error) Get(context.Context, UserID) (*User, error) Me(context.Context) (*User, error) } ``` -------------------------------- ### GET /users/me Source: https://pkg.go.dev/github.com/jomei/notionapi Retrieves the current authenticated user. ```APIDOC ## GET /users/me ### Description Retrieves the user object for the currently authenticated user. ### Method GET ### Endpoint /users/me ### Response #### Success Response (200) - **User** (object) - The user object of the authenticated user. ``` -------------------------------- ### GET /users/me Source: https://pkg.go.dev/github.com/jomei/notionapi Retrieves the bot User associated with the API token. ```APIDOC ## GET /users/me ### Description Retrieves the bot User associated with the API token provided in the authorization header. The bot will have an owner field with information about the person who authorized the integration. ### Method GET ### Endpoint /users/me ### Response #### Success Response (200) - **Object** (string) - The object type, should be "user". - **ID** (string) - The bot user's unique identifier. - **Type** (string) - The user type, should be "bot". - **Name** (string) - The bot's name. - **AvatarURL** (string) - The URL of the bot's avatar. - **Owner** (object) - Information about the user who authorized the integration. Can be `{ "workspace": true }` or a User object. - **WorkspaceIcon** (string) - The URL of the workspace icon. - **WorkspaceId** (string) - The workspace's unique identifier. - **WorkspaceName** (string) - The name of the workspace. #### Response Example ```json { "object": "user", "id": "bot-user-id", "type": "bot", "name": "My Integration Bot", "avatar_url": "https://example.com/bot_avatar.png", "owner": { "workspace": true }, "workspace_icon": "https://example.com/workspace_icon.png", "workspace_id": "a-workspace-id", "workspace_name": "My Workspace" } ``` ``` -------------------------------- ### GET /databases/{database_id} Source: https://pkg.go.dev/github.com/jomei/notionapi Retrieves a database object by its ID. ```APIDOC ## GET /databases/{database_id} ### Description Retrieves a database object by its ID. ### Method GET ### Endpoint /databases/{database_id} ### Parameters #### Path Parameters - **database_id** (DatabaseID) - Required - The unique identifier of the database. ``` -------------------------------- ### GET /databases/{id} Source: https://pkg.go.dev/github.com/jomei/notionapi Retrieves a database object by its unique identifier. ```APIDOC ## GET /databases/{id} ### Description Retrieves a database object by its unique identifier. ### Method GET ### Endpoint /databases/{id} ### Parameters #### Path Parameters - **id** (DatabaseID) - Required - The unique identifier of the database. ``` -------------------------------- ### ToggleBlock Methods Source: https://pkg.go.dev/github.com/jomei/notionapi Provides a method to get the string representation of the rich text within a ToggleBlock. ```APIDOC ## ToggleBlock Methods ### GetRichTextString #### Description Retrieves the plain text content of the rich text within the ToggleBlock. #### Method `func (b ToggleBlock) GetRichTextString() string` ``` -------------------------------- ### Retrieve a Notion Page Source: https://pkg.go.dev/github.com/jomei/notionapi Call the Get method on the client's Page object to retrieve a specific page using its ID. Handle potential errors during the API call. ```go page, err := client.Page.Get(context.Background(), "your_page_id") if err != nil { // Handle the error } ``` -------------------------------- ### POST /databases/{database_id}/query Source: https://pkg.go.dev/github.com/jomei/notionapi Gets a list of pages contained in the database, filtered and ordered according to the request criteria. ```APIDOC ## POST /databases/{database_id}/query ### Description Gets a list of pages contained in the database, filtered and ordered according to the filter conditions and sort criteria provided in the request. ### Method POST ### Endpoint /databases/{database_id}/query ### Parameters #### Path Parameters - **database_id** (DatabaseID) - Required - The unique identifier of the database. #### Request Body - **Filter** (Filter) - Optional - Limits which pages are returned. - **Sorts** ([]SortObject) - Optional - Orders the results. - **StartCursor** (Cursor) - Optional - Pagination cursor. - **PageSize** (int) - Optional - Number of items to return (Max 100). ### Response #### Success Response (200) - **Object** (ObjectType) - The object type. - **Results** ([]Page) - The list of pages. - **HasMore** (bool) - Whether there are more pages. - **NextCursor** (Cursor) - Cursor for the next page. ``` -------------------------------- ### Client Initialization Source: https://pkg.go.dev/github.com/jomei/notionapi Initializes a new Notion API client with a token and optional configuration settings. ```APIDOC ## NewClient ### Description Creates a new instance of the Notion API client. ### Parameters - **token** (Token) - Required - The API token for authentication. - **opts** (...ClientOption) - Optional - Configuration options for the client. ### Response - **Client** (struct) - The initialized Notion API client. ``` -------------------------------- ### Implement PDF block methods Source: https://pkg.go.dev/github.com/jomei/notionapi Methods for retrieving metadata from a PDF block. ```go func (b *PdfBlock) GetExpiryTime() *time.Time ``` ```go func (b PdfBlock) GetRichTextString() string ``` ```go func (b *PdfBlock) GetURL() string ``` -------------------------------- ### Implement People property methods Source: https://pkg.go.dev/github.com/jomei/notionapi Methods for accessing PeopleProperty and PeoplePropertyConfig fields. ```go func (p PeopleProperty) GetID() string ``` ```go func (p PeopleProperty) GetType() PropertyType ``` ```go func (p PeoplePropertyConfig) GetID() PropertyID ``` ```go func (p PeoplePropertyConfig) GetType() PropertyConfigType ``` -------------------------------- ### Create a new page Source: https://pkg.go.dev/github.com/jomei/notionapi Creates a new page as a child of an existing page or database. ```go func (pc *PageClient) Create(ctx context.Context, requestBody *PageCreateRequest) (*Page, error) ``` -------------------------------- ### POST /v1/databases Source: https://pkg.go.dev/github.com/jomei/notionapi Creates a new database in Notion. ```APIDOC ## POST /v1/databases ### Description Creates a new database within the Notion workspace. ### Method POST ### Endpoint /v1/databases ### Parameters #### Request Body - **requestBody** (DatabaseCreateRequest) - Required - The configuration for the new database. ### Response #### Success Response (200) - **database** (Database) - The created database object. ``` -------------------------------- ### GET /users/{user_id} Source: https://pkg.go.dev/github.com/jomei/notionapi Retrieves a specific User by their unique ID. ```APIDOC ## GET /users/{user_id} ### Description Retrieves a User using the ID specified. ### Method GET ### Endpoint /users/{user_id} ### Parameters #### Path Parameters - **user_id** (string) - Required - The unique identifier of the user to retrieve. ### Response #### Success Response (200) - **Object** (string) - The object type, should be "user". - **ID** (string) - The user's unique identifier. - **Type** (string) - The type of user (e.g., "person", "bot"). - **Name** (string) - The user's name. - **AvatarURL** (string) - The URL of the user's avatar. - **Person** (object) - Contains details if the user is a person. - **Bot** (object) - Contains details if the user is a bot. #### Response Example ```json { "object": "user", "id": "a-valid-user-id", "type": "person", "name": "Jane Doe", "avatar_url": "https://example.com/avatar.png", "person": { "email": "jane.doe@example.com" }, "bot": null } ``` ``` -------------------------------- ### GET /users/{id} Source: https://pkg.go.dev/github.com/jomei/notionapi Retrieves a specific user by their unique ID. ```APIDOC ## GET /users/{id} ### Description Retrieves a user object for the specified user ID. ### Method GET ### Endpoint /users/{id} ### Parameters #### Path Parameters - **id** (UserID) - Required - The unique identifier of the user. ### Response #### Success Response (200) - **User** (object) - The user object containing user details. ``` -------------------------------- ### Go: SearchClient Do Method Source: https://pkg.go.dev/github.com/jomei/notionapi Executes a search request against the Notion API. Requires a context and a SearchRequest, returning a SearchResponse or an error. Useful for searching pages or databases with optional filtering. ```go func (sc *SearchClient) Do(ctx context.Context, request *SearchRequest) (*SearchResponse, error) ``` -------------------------------- ### Audio Struct and GetURL Method Source: https://pkg.go.dev/github.com/jomei/notionapi Defines the structure for audio content in Notion, including captions and file references. The GetURL method retrieves the appropriate file URL. ```go type Audio struct { Caption []RichText `json:"caption,omitempty"` Type FileType `json:"type"` File *FileObject `json:"file,omitempty"` External *FileObject `json:"external,omitempty"` } func (i Audio) GetURL() string ``` -------------------------------- ### NewClient Function Source: https://pkg.go.dev/github.com/jomei/notionapi Constructor function for creating a new Notion API client. It takes a Token and optional ClientOptions for configuration. ```go func NewClient(token Token, opts ...ClientOption) *Client ``` -------------------------------- ### GET /comments Source: https://pkg.go.dev/github.com/jomei/notionapi Retrieves a list of unresolved comments associated with a specific block or page. ```APIDOC ## GET /comments ### Description Retrieves a list of un-resolved Comment objects from a page or block. ### Method GET ### Query Parameters - **block_id** (BlockID) - Required - The ID of the block or page to retrieve comments from. - **pagination** (Pagination) - Optional - Pagination parameters for the request. ### Response #### Success Response (200) - **results** ([]Comment) - A list of comment objects. - **has_more** (bool) - Indicates if there are more results. - **next_cursor** (Cursor) - The cursor for the next page of results. ``` -------------------------------- ### ImageBlock Methods Source: https://pkg.go.dev/github.com/jomei/notionapi Methods for interacting with ImageBlock, including retrieving expiry time, rich text, and URLs. ```go func (b *ImageBlock) GetExpiryTime() *time.Time ``` ```go func (b ImageBlock) GetRichTextString() string ``` ```go func (b *ImageBlock) GetURL() string ``` -------------------------------- ### Implement Phone Number property methods Source: https://pkg.go.dev/github.com/jomei/notionapi Methods for accessing PhoneNumberProperty and PhoneNumberPropertyConfig fields. ```go func (p PhoneNumberProperty) GetID() string ``` ```go func (p PhoneNumberProperty) GetType() PropertyType ``` ```go func (p PhoneNumberPropertyConfig) GetID() PropertyID ``` ```go func (p PhoneNumberPropertyConfig) GetType() PropertyConfigType ``` -------------------------------- ### ToDoBlock Methods Source: https://pkg.go.dev/github.com/jomei/notionapi Provides a method to get the string representation of the rich text within a ToDoBlock. ```APIDOC ## ToDoBlock Methods ### GetRichTextString #### Description Retrieves the plain text content of the rich text within the ToDoBlock. #### Method `func (t ToDoBlock) GetRichTextString() string` ``` -------------------------------- ### Define VerificationPropertyConfig Structures Source: https://pkg.go.dev/github.com/jomei/notionapi Configuration structures for verification properties. ```go type VerificationPropertyConfig struct { ID PropertyID `json:"id,omitempty"` Type PropertyConfigType `json:"type,omitempty"` Verification Verification `json:"verification"` } ``` ```go func (p VerificationPropertyConfig) GetID() PropertyID ``` ```go func (p VerificationPropertyConfig) GetType() PropertyConfigType ``` -------------------------------- ### Go: RollupProperty GetType Method Source: https://pkg.go.dev/github.com/jomei/notionapi Retrieves the property type for a RollupProperty. No specific setup required. ```go func (p RollupProperty) GetType() PropertyType ``` -------------------------------- ### Client Configuration Options Source: https://pkg.go.dev/github.com/jomei/notionapi Functions used to configure the behavior of the Notion API client. ```APIDOC ## Client Configuration ### WithHTTPClient Overrides the default http.Client. ### WithOAuthAppCredentials Sets the OAuth app ID and secret for token retrieval. ### WithRetry Overrides the default number of max retry attempts on 429 errors. ### WithVersion Overrides the default Notion API version. ``` -------------------------------- ### Define Verification Structures Source: https://pkg.go.dev/github.com/jomei/notionapi Structures for handling page verification state and metadata. ```go type Verification struct { State VerificationState `json:"state"` VerifiedBy *User `json:"verified_by,omitempty"` Date *DateObject `json:"date,omitempty"` } ``` ```go type VerificationProperty struct { ID ObjectID `json:"id,omitempty"` Type PropertyType `json:"type,omitempty"` Verification Verification `json:"verification"` } ``` -------------------------------- ### WithHTTPClient Option Source: https://pkg.go.dev/github.com/jomei/notionapi Client option to override the default http.Client used by the Notion API client. ```go func WithHTTPClient(client *http.Client) ClientOption ``` -------------------------------- ### WithVersion Option Source: https://pkg.go.dev/github.com/jomei/notionapi Client option to override the Notion API version used by the client. ```go func WithVersion(version string) ClientOption ``` -------------------------------- ### GET /api/v1/pages/{page_id} Source: https://pkg.go.dev/github.com/jomei/notionapi Retrieves a Page object using the specified ID. Responses contain page properties, not page content. ```APIDOC ## GET /api/v1/pages/{page_id} ### Description Retrieves a Page object using the ID specified. Responses contains page properties, not page content. To fetch page content, use the Retrieve block children endpoint. Page properties are limited to up to 25 references per page property. To retrieve data related to properties that have more than 25 references, use the Retrieve a page property endpoint. See https://developers.notion.com/reference/get-page ### Method GET ### Endpoint /api/v1/pages/{page_id} ### Parameters #### Path Parameters - **page_id** (PageID) - Required - The ID of the page to retrieve. ### Response #### Success Response (200) - **Page** (Page) - The requested page object. #### Response Example ```json { "object": "page", "id": "page_id_to_retrieve", "created_time": "2023-10-27T10:00:00.000Z", "last_edited_time": "2023-10-27T10:00:00.000Z", "parent": { "type": "page_id", "page_id": "parent_page_id" }, "archived": false, "properties": { "title": { "title": [ { "type": "text", "text": { "content": "Example Page Title" }, "annotations": { "bold": false, "italic": false, "strikethrough": false, "underline": false, "code": false }, "color": "default" } ] } }, "url": "https://www.notion.so/your_workspace/page_id_to_retrieve" } ``` ``` -------------------------------- ### Go: SelectPropertyConfig Structure Source: https://pkg.go.dev/github.com/jomei/notionapi Defines the configuration for a Select property, including its ID, type, and available select options. Added in v1.2.0. ```go type SelectPropertyConfig struct { ID PropertyID `json:"id,omitempty"` Type PropertyConfigType `json:"type"` Select Select `json:"select"` } ``` -------------------------------- ### Phone Number Property Source: https://pkg.go.dev/github.com/jomei/notionapi Represents a 'Phone Number' property in Notion, storing a single phone number. Includes methods to get the property ID and type. ```APIDOC ## Phone Number Property ### Description Represents a 'Phone Number' property in Notion, storing a single phone number. ### Type Definition ```go type PhoneNumberProperty struct { ID ObjectID `json:"id,omitempty"` Type PropertyType `json:"type,omitempty"` PhoneNumber string `json:"phone_number"` } ``` ### Methods - **GetID()** (string): Returns the ID of the Phone Number property. - **GetType()** (PropertyType): Returns the type of the property. ``` -------------------------------- ### Mention Types and Methods Source: https://pkg.go.dev/github.com/jomei/notionapi Definitions for Mention structures and associated types. ```go type Mention struct { Type MentionType `json:"type,omitempty"` Database *DatabaseMention `json:"database,omitempty"` Page *PageMention `json:"page,omitempty"` User *User `json:"user,omitempty"` Date *DateObject `json:"date,omitempty"` TemplateMention *TemplateMention `json:"template_mention,omitempty"` } ``` ```go type MentionType string ``` ```go const ( MentionTypeDatabase MentionType = "database" MentionTypePage MentionType = "page" MentionTypeUser MentionType = "user" MentionTypeDate MentionType = "date" MentionTypeTemplateMention MentionType = "template_mention" ) ``` ```go func (mType MentionType) String() string ``` -------------------------------- ### PDF Block Source: https://pkg.go.dev/github.com/jomei/notionapi Represents a PDF block within Notion, including its caption, file type, and associated file objects. Provides methods to get expiry time and URL. ```APIDOC ## PDF Block ### Description Represents a PDF block in Notion. It includes a caption, file type, and can reference either an internal file or an external file. ### Type Definition ```go type Pdf struct { Caption []RichText `json:"caption,omitempty"` Type FileType `json:"type,omitempty"` File *FileObject `json:"file,omitempty"` External *FileObject `json:"external,omitempty"` } type PdfBlock struct { BasicBlock Pdf Pdf `json:"pdf"` } ``` ### Methods - **GetExpiryTime()** (*time.Time): Implements the DownloadableFileBlock interface for PdfBlock. - **GetRichTextString()** (string): Returns the rich text string representation of the PDF block. - **GetURL()** (string): Implements the DownloadableFileBlock interface for PdfBlock, returning the URL of the PDF. ``` -------------------------------- ### Update a page Source: https://pkg.go.dev/github.com/jomei/notionapi Updates the properties, icon, cover, or archive status of a page. ```go func (pc *PageClient) Update(ctx context.Context, id PageID, request *PageUpdateRequest) (*Page, error) ``` -------------------------------- ### Go: SearchRequest Structure Source: https://pkg.go.dev/github.com/jomei/notionapi Represents a request to search within Notion, including query text, sorting, filtering, pagination, and page size. Supports searching by title, ordering by last edited time, and filtering by object type ('page' or 'database'). ```go type SearchRequest struct { // The text that the API compares page and database titles against. Query string `json:"query,omitempty"` // A set of criteria, direction and timestamp keys, that orders the results. // The only supported timestamp value is "last_edited_time". Supported // direction values are "ascending" and "descending". If sort is not provided, // then the most recently edited results are returned first. Sort *SortObject `json:"sort,omitempty"` // A set of criteria, value and property keys, that limits the results to // either only pages or only databases. Possible value values are "page" or // "database". The only supported property value is "object". Filter SearchFilter `json:"filter,omitempty"` // A cursor value returned in a previous response that If supplied, limits the // response to results starting after the cursor. If not supplied, then the // first page of results is returned. Refer to pagination for more details. StartCursor Cursor `json:"start_cursor,omitempty"` // The number of items from the full list to include in the response. Maximum: 100. PageSize int `json:"page_size,omitempty"` } ``` -------------------------------- ### Define Pagination structures Source: https://pkg.go.dev/github.com/jomei/notionapi Structures and methods for handling API pagination. ```go type Pagination struct { StartCursor Cursor PageSize int } ``` ```go func (p *Pagination) ToQuery() map[string]string ``` -------------------------------- ### Define PageClient struct Source: https://pkg.go.dev/github.com/jomei/notionapi Internal structure for the PageClient. ```go type PageClient struct { // contains filtered or unexported fields } ``` -------------------------------- ### Go: SearchService Interface Source: https://pkg.go.dev/github.com/jomei/notionapi Defines the interface for search operations, requiring a Do method that accepts a context and SearchRequest, returning a SearchResponse and an error. ```go type SearchService interface { Do(context.Context, *SearchRequest) (*SearchResponse, error) } ``` -------------------------------- ### Define VerificationState Constants Source: https://pkg.go.dev/github.com/jomei/notionapi Type definition and constants for verification status. ```go type VerificationState string ``` ```go const ( VerificationStateVerified VerificationState = "verified" VerificationStateUnverified VerificationState = "unverified" ) ``` ```go func (vs VerificationState) String() string ``` -------------------------------- ### Go: SearchClient Structure Source: https://pkg.go.dev/github.com/jomei/notionapi Represents a client for performing search operations in Notion. Contains unexported fields. ```go type SearchClient struct { // contains filtered or unexported fields } ``` -------------------------------- ### POST /databases Source: https://pkg.go.dev/github.com/jomei/notionapi Creates a new database as a subpage in the specified parent page with a defined property schema. ```APIDOC ## POST /databases ### Description Creates a database as a subpage in the specified parent page, with the specified properties schema. Currently, the parent of a new database must be a Notion page. ### Method POST ### Endpoint /databases ### Request Body - **requestBody** (DatabaseCreateRequest) - Required - The configuration for the new database. ### Response #### Success Response (200) - **Database** (Database) - The created database object. ### Reference https://developers.notion.com/reference/create-a-database ``` -------------------------------- ### Define Video Block Structures Source: https://pkg.go.dev/github.com/jomei/notionapi Structures for representing video content blocks in Notion. ```go type Video struct { Caption []RichText `json:"caption,omitempty"` Type FileType `json:"type"` File *FileObject `json:"file,omitempty"` External *FileObject `json:"external,omitempty"` } ``` ```go type VideoBlock struct { BasicBlock Video Video `json:"video"` } ``` ```go func (b VideoBlock) GetRichTextString() string ``` -------------------------------- ### Link and LinkPreview Structures Source: https://pkg.go.dev/github.com/jomei/notionapi Definitions for Link and LinkPreview related blocks. ```go type Link struct { Url string `json:"url,omitempty"` } ``` ```go type LinkPreview struct { URL string `json:"url"` } ``` ```go type LinkPreviewBlock struct { BasicBlock LinkPreview LinkPreview `json:"link_preview"` } ``` ```go func (b LinkPreviewBlock) GetRichTextString() string ``` -------------------------------- ### Go: SelectProperty Structure Source: https://pkg.go.dev/github.com/jomei/notionapi Represents a Select property in Notion, including its ID, type, and the selected option. ```go type SelectProperty struct { ID ObjectID `json:"id,omitempty"` Type PropertyType `json:"type,omitempty"` Select Option `json:"select"` } ``` -------------------------------- ### Define PDF block structures Source: https://pkg.go.dev/github.com/jomei/notionapi Structures for representing PDF files and PDF blocks in Notion. ```go type Pdf struct { Caption []RichText `json:"caption,omitempty"` Type FileType `json:"type,omitempty"` File *FileObject `json:"file,omitempty"` External *FileObject `json:"external,omitempty"` } ``` ```go type PdfBlock struct { BasicBlock Pdf Pdf `json:"pdf"` } ``` -------------------------------- ### Go: Select Structure Source: https://pkg.go.dev/github.com/jomei/notionapi Represents a select option within Notion, containing a list of available options. ```go type Select struct { Options []Option `json:"options"` } ``` -------------------------------- ### Define Parent structure Source: https://pkg.go.dev/github.com/jomei/notionapi Represents the location of a page, database, or block within the Notion workspace. ```go type Parent struct { Type ParentType `json:"type,omitempty"` PageID PageID `json:"page_id,omitempty"` DatabaseID DatabaseID `json:"database_id,omitempty"` BlockID BlockID `json:"block_id,omitempty"` Workspace bool `json:"workspace,omitempty"` } ``` -------------------------------- ### VerificationProperty Methods Source: https://pkg.go.dev/github.com/jomei/notionapi Methods to retrieve the ID and type of a verification property. ```go func (p VerificationProperty) GetID() string ``` ```go func (p VerificationProperty) GetType() PropertyType ``` -------------------------------- ### Image and Icon Objects Source: https://pkg.go.dev/github.com/jomei/notionapi Structures for handling image and icon assets in Notion. ```APIDOC ## Image and Icon Objects ### Description Defines structures for images and icons, supporting both internal file objects and external URLs. ### Fields - **type** (FileType) - The type of the file (file or external). - **file** (FileObject) - Internal file object details. - **external** (FileObject) - External URL details. - **caption** (Array) - (Image only) The caption for the image. ### Methods - **GetURL()** (string) - Returns the resolved URL for the image or icon. ``` -------------------------------- ### Retrieve a page Source: https://pkg.go.dev/github.com/jomei/notionapi Retrieves a Page object using the specified ID. ```go func (pc *PageClient) Get(ctx context.Context, id PageID) (*Page, error) ``` -------------------------------- ### LinkToPage and ListItem Structures Source: https://pkg.go.dev/github.com/jomei/notionapi Definitions for LinkToPage and ListItem block types. ```go type LinkToPage struct { Type BlockType `json:"type"` PageID PageID `json:"page_id,omitempty"` DatabaseID DatabaseID `json:"database_id,omitempty"` } ``` ```go type LinkToPageBlock struct { BasicBlock LinkToPage LinkToPage `json:"link_to_page"` } ``` ```go type ListItem struct { RichText []RichText `json:"rich_text"` Children Blocks `json:"children,omitempty"` Color string `json:"color,omitempty"` } ``` -------------------------------- ### Token String Method Source: https://pkg.go.dev/github.com/jomei/notionapi Provides a string representation of the Token. ```APIDOC ## Token String Method ### String #### Description Returns the string value of the Token. #### Method `func (it Token) String() string` ``` -------------------------------- ### Define Property interfaces Source: https://pkg.go.dev/github.com/jomei/notionapi Interfaces for generic property and property configuration types. ```go type Property interface { GetID() string GetType() PropertyType } ``` ```go type PropertyConfig interface { GetType() PropertyConfigType GetID() PropertyID } ``` -------------------------------- ### Define PageCreateRequest struct Source: https://pkg.go.dev/github.com/jomei/notionapi Request body structure for creating a new page. ```go type PageCreateRequest struct { // The parent page or database where the new page is inserted, represented as // a JSON object with a page_id or database_id key, and the corresponding ID. Parent Parent `json:"parent"` // The values of the page’s properties. If the parent is a database, then the // schema must match the parent database’s properties. If the parent is a page, // then the only valid object key is title. Properties Properties `json:"properties"` // The content to be rendered on the new page, represented as an array of // block objects. Children []Block `json:"children,omitempty"` // The icon of the new page. Either an emoji object or an external file object. Icon *Icon `json:"icon,omitempty"` // The cover image of the new page, represented as a file object. Cover *Image `json:"cover,omitempty"` } ``` -------------------------------- ### FilesPropertyConfig Methods Source: https://pkg.go.dev/github.com/jomei/notionapi Methods for FilesPropertyConfig to retrieve its ID and Type. ```APIDOC ## FilesPropertyConfig Methods ### GetID Retrieves the ID of the FilesPropertyConfig. ### Method ``` func (FilesPropertyConfig) GetID() PropertyID ``` ### GetType Retrieves the type of the FilesPropertyConfig. ### Method ``` func (FilesPropertyConfig) GetType() PropertyConfigType ``` ``` -------------------------------- ### Define UserType Constants Source: https://pkg.go.dev/github.com/jomei/notionapi Type definition and constants for identifying user types as either person or bot. ```go type UserType string ``` ```go const ( UserTypePerson UserType = "person" UserTypeBot UserType = "bot" ) ``` -------------------------------- ### Page Struct Definition Source: https://pkg.go.dev/github.com/jomei/notionapi Represents a Notion page, containing its properties, metadata, and parent information. See https://developers.notion.com/reference/page. ```go type Page struct { Object ObjectType `json:"object"` ID ObjectID `json:"id"` CreatedTime time.Time `json:"created_time"` LastEditedTime time.Time `json:"last_edited_time"` CreatedBy User `json:"created_by,omitempty"` LastEditedBy User `json:"last_edited_by,omitempty"` Archived bool `json:"archived"` Properties Properties `json:"properties"` Parent Parent `json:"parent"` URL string `json:"url"` PublicURL string `json:"public_url"` Icon *Icon `json:"icon,omitempty"` Cover *Image `json:"cover,omitempty"` } ``` -------------------------------- ### Define Client Type Source: https://pkg.go.dev/github.com/jomei/notionapi Defines the main Client struct for interacting with the Notion API. It holds the authentication token and service clients for various API endpoints. ```go type Client struct { Token Token Database DatabaseService Block BlockService Page PageService User UserService Search SearchService Comment CommentService Authentication AuthenticationService // contains filtered or unexported fields } ``` -------------------------------- ### Define Parent types Source: https://pkg.go.dev/github.com/jomei/notionapi Defines the possible parent types and their associated constants. ```go type ParentType string ``` ```go const ( ParentTypeDatabaseID ParentType = "database_id" ParentTypePageID ParentType = "page_id" ParentTypeWorkspace ParentType = "workspace" ParentTypeBlockID ParentType = "block_id" ) ``` -------------------------------- ### POST /api/v1/pages Source: https://pkg.go.dev/github.com/jomei/notionapi Creates a new page as a child of an existing page or database. Supports adding content during creation or appending later. ```APIDOC ## POST /api/v1/pages ### Description Creates a new page that is a child of an existing page or database. If the new page is a child of an existing page, title is the only valid property in the properties body param. If the new page is a child of an existing database, the keys of the properties object body param must match the parent database's properties. This endpoint can be used to create a new page with or without content using the children option. To add content to a page after creating it, use the Append block children endpoint. Returns a new page object. See https://developers.notion.com/reference/post-page ### Method POST ### Endpoint /api/v1/pages ### Parameters #### Request Body - **parent** (Parent) - Required - The parent page or database where the new page is inserted, represented as a JSON object with a page_id or database_id key, and the corresponding ID. - **properties** (Properties) - Required - The values of the page’s properties. If the parent is a database, then the schema must match the parent database’s properties. If the parent is a page, then the only valid object key is title. - **children** ([]Block) - Optional - The content to be rendered on the new page, represented as an array of block objects. - **icon** (Icon) - Optional - The icon of the new page. Either an emoji object or an external file object. - **cover** (Image) - Optional - The cover image of the new page, represented as a file object. ### Request Example ```json { "parent": { "page_id": "your_page_id" }, "properties": { "title": { "title": [ { "text": { "content": "My New Page" } } ] } }, "children": [ { "object": "block", "type": "paragraph", "paragraph": { "rich_text": [ { "type": "text", "text": { "content": "This is the first paragraph." } } ] } } ] } ``` ### Response #### Success Response (200) - **Page** (Page) - The newly created page object. #### Response Example ```json { "object": "page", "id": "generated_page_id", "created_time": "2023-10-27T10:00:00.000Z", "last_edited_time": "2023-10-27T10:00:00.000Z", "parent": { "type": "page_id", "page_id": "your_page_id" }, "archived": false, "properties": { "title": { "title": [ { "type": "text", "text": { "content": "My New Page" }, "annotations": { "bold": false, "italic": false, "strikethrough": false, "underline": false, "code": false }, "color": "default" } ] } }, "url": "https://www.notion.so/your_workspace/generated_page_id" } ``` ``` -------------------------------- ### String Method for ObjectType Source: https://pkg.go.dev/github.com/jomei/notionapi Converts an ObjectType to its string representation. ```go func (ot ObjectType) String() string ``` -------------------------------- ### Define UsersListResponse Structure Source: https://pkg.go.dev/github.com/jomei/notionapi Structure representing a paginated response containing a list of users. ```go type UsersListResponse struct { Object ObjectType `json:"object"` Results []User `json:"results"` HasMore bool `json:"has_more"` NextCursor Cursor `json:"next_cursor"` } ``` -------------------------------- ### TitlePropertyConfig Methods Source: https://pkg.go.dev/github.com/jomei/notionapi Provides methods for retrieving the ID and type of a TitlePropertyConfig. ```APIDOC ## TitlePropertyConfig Methods ### GetID #### Description Retrieves the unique identifier for the TitlePropertyConfig. #### Method `func (p TitlePropertyConfig) GetID() PropertyID` ### GetType #### Description Retrieves the type of the TitlePropertyConfig. #### Method `func (p TitlePropertyConfig) GetType() PropertyConfigType` ``` -------------------------------- ### Define ClientOption Type Source: https://pkg.go.dev/github.com/jomei/notionapi Defines a function type for configuring the Notion API client. This allows for functional options pattern. ```go type ClientOption func(*Client) ``` -------------------------------- ### GetObject Method for Page Source: https://pkg.go.dev/github.com/jomei/notionapi Retrieves the ObjectType for a Page. ```go func (p *Page) GetObject() ObjectType ``` -------------------------------- ### ImageBlock Methods Source: https://pkg.go.dev/github.com/jomei/notionapi Methods for interacting with ImageBlock objects in the Notion API. ```APIDOC ## ImageBlock Methods ### Description Provides access to expiry time and URL for image blocks. ### Methods - **GetExpiryTime()**: Returns the expiry time of the image. - **GetURL()**: Returns the URL of the image. ``` -------------------------------- ### FileBlock Methods Source: https://pkg.go.dev/github.com/jomei/notionapi Methods associated with the FileBlock type, including retrieving expiry times and URLs. ```APIDOC ## FileBlock Methods ### GetExpiryTime Retrieves the expiry time for a downloadable file block. ### Method ``` func (*FileBlock) GetExpiryTime() *time.Time ``` ### GetRichTextString Retrieves the rich text string representation of the file block. ### Method ``` func (FileBlock) GetRichTextString() string ``` ### GetURL Retrieves the URL for a downloadable file block. ### Method ``` func (*FileBlock) GetURL() string ``` ``` -------------------------------- ### String Method for ObjectID Source: https://pkg.go.dev/github.com/jomei/notionapi Converts an ObjectID to its string representation. ```go func (oID ObjectID) String() string ``` -------------------------------- ### WithRetry Option Source: https://pkg.go.dev/github.com/jomei/notionapi Client option to configure the maximum number of retry attempts for 429 errors. Added in v1.10.0. ```go func WithRetry(retries int) ClientOption ``` -------------------------------- ### Option Struct Definition Source: https://pkg.go.dev/github.com/jomei/notionapi Defines a single option within a select or multi-select property. ```go type Option struct { ID PropertyID `json:"id,omitempty"` Name string `json:"name"` Color Color `json:"color,omitempty"` } ``` -------------------------------- ### Define PageMention struct Source: https://pkg.go.dev/github.com/jomei/notionapi Structure representing a mention of a page. ```go type PageMention struct { ID ObjectID `json:"id"` } ``` -------------------------------- ### ToDo Structure Source: https://pkg.go.dev/github.com/jomei/notionapi Represents a To-do item within Notion, including its text, children, checked status, and color. ```APIDOC ## ToDo Structure ### Description Defines the structure for a To-do item, which can contain rich text, child blocks, and a checked status. ### Fields - **RichText** ([]RichText) - An array of RichText objects representing the to-do item's text. - **Children** (Blocks) - Optional. A list of child blocks nested under this to-do item. - **Checked** (bool) - Indicates whether the to-do item is checked (completed). - **Color** (string) - Optional. The color of the to-do item. ``` -------------------------------- ### Object Interface Definition Source: https://pkg.go.dev/github.com/jomei/notionapi Defines the Object interface, requiring a GetObject method. ```go type Object interface { GetObject() ObjectType } ``` -------------------------------- ### Define Phone Number property structures Source: https://pkg.go.dev/github.com/jomei/notionapi Structures for phone number properties and their configurations. ```go type PhoneNumberProperty struct { ID ObjectID `json:"id,omitempty"` Type PropertyType `json:"type,omitempty"` PhoneNumber string `json:"phone_number"` } ``` ```go type PhoneNumberPropertyConfig struct { ID PropertyID `json:"id,omitempty"` Type PropertyConfigType `json:"type"` PhoneNumber struct{} `json:"phone_number"` } ``` -------------------------------- ### NumberPropertyConfig Struct Definition Source: https://pkg.go.dev/github.com/jomei/notionapi Defines the configuration structure for a Number property. Added in v1.2.0. ```go type NumberPropertyConfig struct { ID PropertyID `json:"id,omitempty"` Type PropertyConfigType `json:"type"` Number NumberFormat `json:"number"` } ``` -------------------------------- ### Authentication API Source: https://pkg.go.dev/github.com/jomei/notionapi APIs related to authentication, including creating access tokens. ```APIDOC ## POST /oauth/token ### Description Creates an access token that a third-party service can use to authenticate with Notion. ### Method POST ### Endpoint /oauth/token ### Request Body - **grant_type** (string) - Required - The grant type for the request, typically "authorization_code". - **code** (string) - Required - The authorization code obtained from the authorization flow. - **redirect_uri** (string) - Required - The redirect URI used in the authorization request. - **client_id** (string) - Required - The client ID of your integration. - **client_secret** (string) - Required - The client secret of your integration. ### Response #### Success Response (200) - **access_token** (string) - The access token for authenticating API requests. - **bot_id** (string) - The ID of the bot associated with the access token. - **duplicated_template_id** (string) - The ID of the duplicated template, if applicable. - **error** (string) - An error code if the request failed. - **error_description** (string) - A description of the error. - **expires_in** (integer) - The number of seconds until the access token expires. - **internal_integration_token** (string) - The internal integration token, if applicable. - **links** (object) - Links related to the token. - **self** (string) - The URL for the token. - **new_feature_access_token** (string) - The new feature access token, if applicable. - **owner** (object) - Information about the owner of the token. - **object** (string) - The object type (e.g., "user", "workspace"). - **id** (string) - The ID of the owner. - **scope** (array) - An array of strings representing the scopes granted to the token. - **state** (string) - The state parameter from the authorization request, if provided. - **token_type** (string) - The type of token, typically "bearer". ``` -------------------------------- ### File and DownloadableFileBlock Types Source: https://pkg.go.dev/github.com/jomei/notionapi Details on the File type and the DownloadableFileBlock interface. ```APIDOC ## DownloadableFileBlock Interface ### Description Interface for blocks that can be downloaded, such as Pdf, FileBlock, and Image. ### Method `GetURL`, `GetExpiryTime` ### Endpoint N/A (Interface definition) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ## File Type ### Description Represents a file, which can be hosted externally or uploaded directly. ### Method N/A (Type definition) ### Endpoint N/A (Type definition) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ## FileBlock Type ### Description Represents a file block within a Notion page. ### Method N/A (Type definition) ### Endpoint N/A (Type definition) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Define Paragraph block structures Source: https://pkg.go.dev/github.com/jomei/notionapi Structures for representing paragraph blocks in Notion. ```go type Paragraph struct { RichText []RichText `json:"rich_text"` Children Blocks `json:"children,omitempty"` Color string `json:"color,omitempty"` } ``` ```go type ParagraphBlock struct { BasicBlock Paragraph Paragraph `json:"paragraph"` } ``` ```go func (p ParagraphBlock) GetRichTextString() string ``` -------------------------------- ### UsersListResponse Structure Source: https://pkg.go.dev/github.com/jomei/notionapi Represents the response structure for listing users. ```APIDOC ## UsersListResponse ### Description Structure for the response when listing users. ### Fields - **Object** (ObjectType): The type of the object, expected to be 'user_list'. - **Results** ([]User): A list of User objects. - **HasMore** (bool): Indicates if there are more users to retrieve. - **NextCursor** (Cursor): A cursor for fetching the next page of results. ### Type Definition ```go type UsersListResponse struct { Object ObjectType `json:"object"` Results []User `json:"results"` HasMore bool `json:"has_more"` NextCursor Cursor `json:"next_cursor"` } ``` ```