Documentation
¶
Overview ¶
Package anytype provides a Go SDK for interacting with the Anytype API.
Index ¶
- Constants
- func RegisterClientConstructor(constructor clientConstructor)
- type AuthClient
- type Block
- type BlockClient
- type Client
- type ClientOption
- type ClientOptions
- type CreateBlockRequest
- type CreateObjectRequest
- type CreateSpaceRequest
- type CreateSpaceResponse
- type DisplayCodeResponse
- type ExportResult
- type File
- type Icon
- type IconFormat
- type ListClient
- type ListContext
- type ListFilter
- type ListSort
- type ListView
- type Member
- type MemberClient
- type MemberContext
- type MemberListResponse
- type MemberResponse
- type MemberRole
- type MemberStatus
- type Object
- type ObjectClient
- type ObjectContext
- type ObjectListClient
- type ObjectListContext
- type ObjectListResponse
- type ObjectResponse
- type ObjectViewClient
- type Property
- type PropertyClient
- type PropertyDefinition
- type PropertyOption
- type PropertyUpdateRequest
- type Relation
- type SearchClient
- type SearchRequest
- type SearchResponse
- type SortDirection
- type SortOptions
- type SortProperty
- type Space
- type SpaceClient
- type SpaceContext
- type SpaceListResponse
- type SpaceResponse
- type Tag
- type Template
- type TemplateClient
- type TemplateContext
- type TemplateResponse
- type Text
- type TokenResponse
- type Type
- type TypeClient
- type TypeContext
- type TypeResponse
- type UpdateBlockRequest
- type UpdateObjectRequest
- type UpdateSpaceRequest
- type VersionInfo
- type ViewClient
- type ViewContext
- type ViewListResponse
Constants ¶
const ( // Member roles MemberRoleViewer MemberRole = "viewer" MemberRoleEditor MemberRole = "editor" MemberRoleOwner MemberRole = "owner" // Member statuses MemberStatusJoining MemberStatus = "joining" MemberStatusActive MemberStatus = "active" MemberStatusRemoved MemberStatus = "removed" MemberStatusDeclined MemberStatus = "declined" MemberStatusRemoving MemberStatus = "removing" MemberStatusCanceled MemberStatus = "canceled" )
const ( // Sort properties SortPropertyCreatedDate SortProperty = "created_date" SortPropertyLastModifiedDate SortProperty = "last_modified_date" SortPropertyLastOpenedDate SortProperty = "last_opened_date" SortPropertyName SortProperty = "name" // Sort directions SortDirectionAsc SortDirection = "asc" SortDirectionDesc SortDirection = "desc" )
const ( // Version is the current version of the anytype-go SDK. // This follows Semantic Versioning (https://semver.org/): // MAJOR.MINOR.PATCH where: // - MAJOR version changes with incompatible API changes // - MINOR version adds functionality in a backwards compatible manner // - PATCH version makes backwards compatible bug fixes Version = "0.3.2" )
Version information
Variables ¶
This section is empty.
Functions ¶
func RegisterClientConstructor ¶
func RegisterClientConstructor(constructor clientConstructor)
RegisterClientConstructor registers a constructor function for creating Client instances
Types ¶
type AuthClient ¶
type AuthClient interface {
// DisplayCode initiates a secure authentication flow
DisplayCode(ctx context.Context, appName string) (*DisplayCodeResponse, error)
// GetToken completes the authentication flow by providing a code
GetToken(ctx context.Context, challengeID string, code string) (*TokenResponse, error)
}
AuthClient provides operations for authentication
type Block ¶
type Block struct {
ID string
Text *Text
File *File
Property *Property
ChildrenIDs []string `json:"children_ids"`
Align string
VerticalAlign string `json:"vertical_align"`
BackgroundColor string `json:"background_color"`
}
Block represents a content block within an object
type BlockClient ¶
type BlockClient interface {
// List returns all blocks in the object
List(ctx context.Context) ([]Block, error)
// Get retrieves a specific block by ID
Get(ctx context.Context, blockID string) (*Block, error)
// Create creates a new block in the object
Create(ctx context.Context, request CreateBlockRequest) (*Block, error)
// Update updates a block in the object
Update(ctx context.Context, blockID string, request UpdateBlockRequest) error
// Delete deletes a block from the object
Delete(ctx context.Context, blockID string) error
}
BlockClient provides operations on blocks within an object
type Client ¶
type Client interface {
// Auth returns an AuthClient for authentication operations
Auth() AuthClient
// Spaces returns a SpaceClient for working with spaces
Spaces() SpaceClient
// Space returns a specific SpaceContext for working with a given space
Space(spaceID string) SpaceContext
// Search returns a SearchClient for global search operations
Search() SearchClient
}
Client is the main interface for interacting with the Anytype API
func NewClient ¶
func NewClient(opts ...ClientOption) Client
NewClient creates a new Anytype API client with the given options
type ClientOption ¶
type ClientOption func(*ClientOptions)
ClientOption is a function type that modifies ClientOptions
func WithAppKey ¶
func WithAppKey(appKey string) ClientOption
WithAppKey sets the app key for authentication
func WithBaseURL ¶
func WithBaseURL(url string) ClientOption
WithBaseURL sets the base URL for API requests
func WithSessionToken ¶
func WithSessionToken(token string) ClientOption
WithSessionToken sets the session token for authentication
type ClientOptions ¶
ClientOptions contains configuration options for the Anytype client
type CreateBlockRequest ¶
type CreateBlockRequest struct {
Text *Text
File *File
Property *Property
ParentID string `json:"parent_id"`
TargetPosition int `json:"target_position"`
}
CreateBlockRequest contains parameters for creating a new block
type CreateObjectRequest ¶
type CreateObjectRequest struct {
TypeKey string `json:"type_key"`
Name string
Description string
Body string
Icon *Icon
TemplateID string `json:"template_id,omitempty"`
Source string // Only applicable for bookmarks
}
CreateObjectRequest contains parameters for creating a new object
type CreateSpaceRequest ¶
type CreateSpaceRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Icon *Icon `json:"icon,omitempty"`
}
CreateSpaceRequest represents the request body for creating a new space
type CreateSpaceResponse ¶
type CreateSpaceResponse struct {
Space Space `json:"space"`
}
CreateSpaceResponse represents the response from Create space
type DisplayCodeResponse ¶
type DisplayCodeResponse struct {
ChallengeID string `json:"challenge_id"`
}
DisplayCodeResponse represents the response from the display_code endpoint
type ExportResult ¶
type ExportResult struct {
Markdown string `json:"markdown,omitempty"`
}
ExportResult represents the result of an object export operation
type File ¶
type File struct {
Name string
Hash string
Mime string
Size int64
Type string
State string
Style string
AddedAt int64 `json:"added_at"`
TargetObjectID string `json:"target_object_id"`
}
File represents a file reference
type Icon ¶
type Icon struct {
Format IconFormat `json:"format,omitempty"` // Type of icon: emoji, file, or icon
Emoji string `json:"emoji,omitempty"` // The emoji character if format is emoji
File string `json:"file,omitempty"` // The file URL if format is file
Name string `json:"name,omitempty"` // The name of the icon if format is icon
Color string `json:"color,omitempty"` // The color of the icon
}
Icon represents an object icon
type IconFormat ¶
type IconFormat string
IconFormat represents the type of icon
const ( // IconFormatEmoji represents an emoji icon IconFormatEmoji IconFormat = "emoji" // IconFormatFile represents a file icon IconFormatFile IconFormat = "file" // IconFormatIcon represents a named icon IconFormatIcon IconFormat = "icon" )
type ListClient ¶
type ListClient interface {
// Add is used for adding objects to any list
Add(ctx context.Context, objectIDs []string) error
}
ListClient provides operations on lists within a space
type ListContext ¶
type ListContext interface {
// Views returns a ViewClient for this list
Views() ViewClient
// View returns a ViewContext for a specific view in this list
View(viewID string) ViewContext
// Objects returns an ObjectListClient for this list
Objects() ObjectListClient
// Object returns an ObjectListContext for a specific object in this list
Object(objectID string) ObjectListContext
}
ListContext provides operations on a specific list
type ListFilter ¶
type ListFilter struct {
ID string `json:"id"`
PropertyKey string `json:"property_key"`
Format string `json:"format"`
Condition string `json:"condition"`
Value string `json:"value"`
}
ListFilter represents a filter applied to a list view
type ListSort ¶
type ListSort struct {
ID string `json:"id"`
PropertyKey string `json:"property_key"`
Format string `json:"format"`
SortType string `json:"sort_type"`
}
ListSort represents a sort applied to a list view
type ListView ¶
type ListView struct {
ID string `json:"id"`
Name string `json:"name"`
Layout string `json:"layout"`
Filters []ListFilter `json:"filters,omitempty"`
Sorts []ListSort `json:"sorts,omitempty"`
}
ListView represents a view configuration for a list
type Member ¶
type Member struct {
ID string `json:"id"`
Name string `json:"name"`
GlobalName string `json:"global_name"`
Identity string `json:"identity"`
Role string `json:"role"`
Status string `json:"status"`
Icon *Icon `json:"icon,omitempty"`
}
Member represents a member of a space
type MemberClient ¶
type MemberClient interface {
// List retrieves all members of the space
List(ctx context.Context) (*MemberListResponse, error)
}
MemberClient provides operations on space members
type MemberContext ¶
type MemberContext interface {
// Get retrieves details about this member
Get(ctx context.Context) (*MemberResponse, error)
}
MemberContext provides operations on a specific member
type MemberListResponse ¶
type MemberListResponse struct {
Data []Member `json:"data"`
}
MemberListResponse represents the response from List members
type MemberResponse ¶
type MemberResponse struct {
Member Member `json:"member"`
}
MemberResponse represents the response from Get member
type Object ¶
type Object struct {
ID string
Name string
SpaceID string `json:"space_id"`
TypeKey string
Layout string
Archived bool
Icon *Icon
Snippet string
Properties []Property
Type *Type `json:"type,omitempty"`
}
Object represents an Anytype object
type ObjectClient ¶
type ObjectClient interface {
// List returns all objects in the space
List(ctx context.Context, opts ...options.ListOption) ([]Object, error)
// Create creates a new object in the space
Create(ctx context.Context, request CreateObjectRequest) (*ObjectResponse, error)
}
ObjectClient provides operations on objects within a space
type ObjectContext ¶
type ObjectContext interface {
// Get retrieves the object
Get(ctx context.Context) (*ObjectResponse, error)
// Delete deletes the object
Delete(ctx context.Context) (*ObjectResponse, error)
// Export exports the object in the specified format
Export(ctx context.Context, format string) (*ExportResult, error)
}
ObjectContext provides operations on a specific object
type ObjectListClient ¶
type ObjectListClient interface {
// List returns all objects in the list
List(ctx context.Context) (*ObjectListResponse, error)
// Add adds objects to the list
Add(ctx context.Context, objectIDs []string) error
}
ObjectListClient provides operations on objects within a list
type ObjectListContext ¶
type ObjectListContext interface {
// Remove removes the object from the list
Remove(ctx context.Context) error
}
ObjectListContext provides operations on a specific object within a list
type ObjectListResponse ¶
type ObjectListResponse struct {
Data []Object `json:"data"`
Pagination struct {
Limit int `json:"limit"`
Offset int `json:"offset"`
Total int `json:"total"`
HasMore bool `json:"has_more"`
} `json:"pagination"`
}
ObjectListResponse represents the paginated response for objects in a list
type ObjectResponse ¶
type ObjectResponse struct {
Object *Object `json:"object"`
}
ObjectResponse wraps an Object in a response according to the API specification
type ObjectViewClient ¶
type ObjectViewClient interface {
// List returns all objects in the view
List(ctx context.Context) (*ObjectListResponse, error)
}
ObjectViewClient provides operations on objects within a view
type Property ¶
type Property struct {
ID string
Format string
Text string
Number float64
Checkbox bool
Date string
URL string
Email string
Phone string
File []string
Select *Tag `json:"select"`
MultiSelect []Tag `json:"multi_select"`
ObjectLinks []string `json:"object"`
Relations []Relation
Key string
Name string
Required bool
}
Property represents an object property
type PropertyClient ¶
type PropertyClient interface {
// Get retrieves a specific property value
Get(ctx context.Context, key string) (*Property, error)
// Set sets a property value
Set(ctx context.Context, key string, value interface{}) error
// Delete removes a property
Delete(ctx context.Context, key string) error
// List returns all properties of the object
List(ctx context.Context) ([]Property, error)
}
PropertyClient provides operations on properties of an object
type PropertyDefinition ¶
type PropertyDefinition struct {
Key string
Name string
Format string
Required bool
Options []PropertyOption
}
PropertyDefinition defines a property that can be used with a type
type PropertyOption ¶
PropertyOption represents an option for select/multi-select properties
type PropertyUpdateRequest ¶
type PropertyUpdateRequest struct {
Key string
Value interface{}
}
PropertyUpdateRequest contains parameters for updating a property
type SearchClient ¶
type SearchClient interface {
// Search searches for objects across all spaces
Search(ctx context.Context, request SearchRequest) (*SearchResponse, error)
}
SearchClient provides global search operations across all spaces
type SearchRequest ¶
type SearchRequest struct {
Query string `json:"query"`
Types []string `json:"types,omitempty"` // Object type keys or IDs to filter by
Sort *SortOptions `json:"sort,omitempty"` // Use pointer so it's omitted when nil
}
SearchRequest represents a search query
type SearchResponse ¶
type SearchResponse struct {
Data []Object `json:"data"`
}
SearchResponse represents the response from a search operation
type SortDirection ¶
type SortDirection string
SortDirection represents the direction to sort search results
type SortOptions ¶
type SortOptions struct {
Property SortProperty `json:"property"`
Direction SortDirection `json:"direction"`
}
SortOptions represents sorting options for search results
type SortProperty ¶
type SortProperty string
SortProperty represents the property to sort search results by
type Space ¶
type Space struct {
ID string
Name string
Description string
Icon *Icon
HomeID string `json:"home_id"`
ArchiveID string `json:"archive_id"`
ProfileID string `json:"profile_id"`
CreatedAt int64 `json:"created_at"`
LastOpenedAt int64 `json:"last_opened_at"`
}
Space represents an Anytype workspace/space
type SpaceClient ¶
type SpaceClient interface {
// List returns all spaces accessible to the user
List(ctx context.Context) (*SpaceListResponse, error)
// Create creates a new space
Create(ctx context.Context, request CreateSpaceRequest) (*CreateSpaceResponse, error)
}
SpaceClient provides operations on spaces
type SpaceContext ¶
type SpaceContext interface {
// Get retrieves information about this space
Get(ctx context.Context) (*SpaceResponse, error)
// Objects returns an ObjectClient for this space
Objects() ObjectClient
// Object returns an ObjectContext for a specific object in this space
Object(objectID string) ObjectContext
// Types returns a TypeClient for this space
Types() TypeClient
// Type returns a TypeContext for a specific type in this space
Type(typeID string) TypeContext
// Search searches for objects within this space
Search(ctx context.Context, request SearchRequest) (*SearchResponse, error)
// Lists returns a ListClient for this space
Lists() ListClient
// List returns a ListContext for a specific list in this space
List(listID string) ListContext
// Members returns a MemberClient for this space
Members() MemberClient
// Member returns a MemberContext for a specific member in this space
Member(memberID string) MemberContext
}
SpaceContext provides operations within a specific space
type SpaceListResponse ¶
type SpaceListResponse struct {
Data []Space `json:"data"`
}
SpaceListResponse represents the response from List spaces
type SpaceResponse ¶
type SpaceResponse struct {
Space Space `json:"space"`
}
SpaceResponse represents the response from Get space
type Template ¶
type Template struct {
ID string `json:"id"`
Name string `json:"name"`
Icon *Icon `json:"icon,omitempty"`
Archived bool `json:"archived"`
}
Template represents a template for creating objects
type TemplateClient ¶
type TemplateClient interface {
// List retrieves all templates for a type
List(ctx context.Context) ([]Template, error)
// Get retrieves a specific template by ID
Get(ctx context.Context, templateID string) (*Template, error)
}
TemplateClient provides operations on templates for a specific type
type TemplateContext ¶
type TemplateContext interface {
// Get retrieves details of this specific template
Get(ctx context.Context) (*TemplateResponse, error)
}
TemplateContext provides operations on a specific template
type TemplateResponse ¶
type TemplateResponse struct {
Template Template `json:"template"`
}
TemplateResponse represents the response from a Get call on a template
type TokenResponse ¶
type TokenResponse struct {
AppKey string `json:"app_key"`
SessionToken string `json:"session_token"`
}
TokenResponse represents the response from the token endpoint
type Type ¶
type Type struct {
Key string
Name string
Description string
Icon *Icon
Layout string
RecommendedLayout string `json:"recommended_layout"`
IsArchived bool `json:"is_archived"`
IsHidden bool `json:"is_hidden"`
// Available property definitions for this type
PropertyDefinitions []PropertyDefinition `json:"property_definitions"`
}
Type represents an object type in Anytype
type TypeClient ¶
type TypeClient interface {
// List returns all available object types in the space
List(ctx context.Context) ([]Type, error)
// Get retrieves details of a specific type by key
Get(ctx context.Context, typeKey string) (*Type, error)
// GetKeyByName looks up a type key by its name
GetKeyByName(ctx context.Context, name string) (string, error)
// Type returns a TypeContext for a specific type in this space
Type(typeID string) TypeContext
}
TypeClient provides operations on object types within a space
type TypeContext ¶
type TypeContext interface {
// Get retrieves details of this specific type
Get(ctx context.Context) (*TypeResponse, error)
// Templates returns a TemplateClient for this type
Templates() TemplateClient
// Template returns a TemplateContext for a specific template of this type
Template(templateID string) TemplateContext
}
TypeContext provides operations on a specific object type
type TypeResponse ¶
type TypeResponse struct {
Type Type `json:"type"`
}
TypeResponse represents the response from a Get call on a type
type UpdateBlockRequest ¶
type UpdateBlockRequest struct {
Text *Text
File *File
Property *Property
Align string
VerticalAlign string `json:"vertical_align"`
BackgroundColor string `json:"background_color"`
}
UpdateBlockRequest contains parameters for updating a block
type UpdateObjectRequest ¶
type UpdateObjectRequest struct {
Name string
Description string
Icon *Icon
Properties []PropertyUpdateRequest
}
UpdateObjectRequest contains parameters for updating an object
type UpdateSpaceRequest ¶
type UpdateSpaceRequest struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Icon *Icon `json:"icon,omitempty"`
}
UpdateSpaceRequest represents the request body for updating a space
type VersionInfo ¶
type VersionInfo struct {
// Version is the semantic version of the SDK
Version string `json:"version"`
// APIVersion is the Anytype API version this client works with
APIVersion string `json:"api_version"`
}
VersionInfo holds detailed version information
func GetVersionInfo ¶
func GetVersionInfo() VersionInfo
GetVersionInfo returns version information for the SDK
type ViewClient ¶
type ViewClient interface {
// List retrieves all views for the list
List(ctx context.Context) (*ViewListResponse, error)
}
ViewClient provides operations on views within a list
type ViewContext ¶
type ViewContext interface {
// Objects returns an ObjectViewClient for this view
Objects() ObjectViewClient
}
ViewContext provides operations on a specific view
type ViewListResponse ¶
type ViewListResponse struct {
Data []ListView `json:"data"`
Pagination struct {
Limit int `json:"limit"`
Offset int `json:"offset"`
Total int `json:"total"`
HasMore bool `json:"has_more"`
} `json:"pagination"`
}
ViewListResponse represents the paginated response for list views
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
filepath: /home/epheo/dev/anytype-go/pkg/anytype/client/auth.go
|
filepath: /home/epheo/dev/anytype-go/pkg/anytype/client/auth.go |
|
Package middleware provides HTTP middleware components for the anytype client
|
Package middleware provides HTTP middleware components for the anytype client |
|
filepath: /home/epheo/dev/anytype-go/pkg/anytype/options/list.go
|
filepath: /home/epheo/dev/anytype-go/pkg/anytype/options/list.go |