Skip to content

A Go SDK for interacting with the Anytype API to manage spaces, objects, and perform searches. This library provides a feature-rich, fluent interface to integrate Anytype functionality into your Go applications.

License

Notifications You must be signed in to change notification settings

epheo/anytype-go

Repository files navigation

Anytype-Go SDK

Go Report Card GoDoc License: Apache 2.0

Go SDK for the Anytype local API. Compatible with API version 2025-11-08.

Installation

go get github.com/epheo/anytype-go
import (
    "github.com/epheo/anytype-go"
    _ "github.com/epheo/anytype-go/client"
)

Authentication

client := anytype.NewClient(
    anytype.WithBaseURL("http://localhost:31009"),
)

// Initiate challenge — Anytype app will display a verification code
auth, _ := client.Auth().CreateChallenge(ctx, "MyApp")

// User enters the code
var code string
fmt.Scanln(&code)

// Exchange for API key
token, _ := client.Auth().CreateApiKey(ctx, auth.ChallengeID, code)

// Create authenticated client
client = anytype.NewClient(
    anytype.WithBaseURL("http://localhost:31009"),
    anytype.WithAppKey(token.ApiKey),
)

Usage

The SDK uses a fluent interface that mirrors the resource hierarchy:

// Spaces
spaces, _ := client.Spaces().List(ctx)
space, _ := client.Space(spaceID).Get(ctx)

// Objects
objects, _ := client.Space(spaceID).Objects().List(ctx)
object, _ := client.Space(spaceID).Object(objectID).Get(ctx)
markdown, _ := client.Space(spaceID).Object(objectID).Get(ctx, anytype.WithFormat("md"))

// Types and templates
types, _ := client.Space(spaceID).Types().List(ctx)
templates, _ := client.Space(spaceID).Type(typeKey).Templates().List(ctx)

// Lists and views
views, _ := client.Space(spaceID).List(listID).Views().List(ctx)
_ = client.Space(spaceID).List(listID).Objects().Add(ctx, []string{objectID})

// Properties and tags
props, _ := client.Space(spaceID).Properties().List(ctx)
tags, _ := client.Space(spaceID).Property(propID).Tags().List(ctx)

// Members
members, _ := client.Space(spaceID).Members().List(ctx)

// Search (within a space or globally)
results, _ := client.Space(spaceID).Search(ctx, anytype.SearchRequest{
    Query: "meeting notes",
    Types: []string{"page"},
    Sort:  &anytype.SortOptions{
        Property:  anytype.SortPropertyLastModifiedDate,
        Direction: anytype.SortDirectionDesc,
    },
})
globalResults, _ := client.Search().Search(ctx, anytype.SearchRequest{Query: "notes"})

See examples/usage_examples.go for complete working examples and GoDoc for the full API reference.

Testing SDK coverage

go test -v ./tests_api_coverage/... # API coverage tests

License

Apache License 2.0 - see LICENSE.

About

A Go SDK for interacting with the Anytype API to manage spaces, objects, and perform searches. This library provides a feature-rich, fluent interface to integrate Anytype functionality into your Go applications.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors