rmclient

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package rmclient provides a client for interacting with the reMarkable cloud API.

Index

Constants

View Source
const (
	DocumentType   = "DocumentType"
	CollectionType = "CollectionType"
)

DocumentType constants

View Source
const (
	FileTypeNotebook = "notebook"
	FileTypePDF      = "pdf"
	FileTypeEPUB     = "epub"
)

FileType constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps the reMarkable cloud API for document synchronization

func NewClient

func NewClient(cfg *Config) (*Client, error)

NewClient creates a new reMarkable API client

func (*Client) Authenticate

func (c *Client) Authenticate() error

Authenticate authenticates with the reMarkable cloud API If a token exists, it will be loaded. Otherwise, manual device registration is required.

func (*Client) Close

func (c *Client) Close() error

Close closes the client and cleans up resources

func (*Client) DownloadDocument

func (c *Client) DownloadDocument(id, outputPath string) error

DownloadDocument downloads a document to the specified path

func (*Client) GetDocumentMetadata

func (c *Client) GetDocumentMetadata(id string) (*Document, error)

GetDocumentMetadata retrieves metadata for a specific document from the API Returns a Document with full information from the reMarkable cloud

func (*Client) GetFolderPath

func (c *Client) GetFolderPath(documentID string) (string, error)

GetFolderPath returns the full folder path for a document by traversing its parent chain Returns an empty string if the document is in the root folder Returns an error if the document is not found or if there's a circular reference

func (*Client) GetTokenMonitor added in v1.2.0

func (c *Client) GetTokenMonitor() *TokenMonitor

GetTokenMonitor returns the token monitor if enabled

func (*Client) IsAuthenticated

func (c *Client) IsAuthenticated() bool

IsAuthenticated returns true if the client has a valid authentication token

func (*Client) ListDocuments

func (c *Client) ListDocuments(labels []string) ([]Document, error)

ListDocuments lists all documents, optionally filtered by labels Returns a list of Document objects representing documents in the reMarkable cloud

func (*Client) SetToken

func (c *Client) SetToken(token string) error

SetToken manually sets the authentication token (useful for testing or manual configuration)

type Collection

type Collection struct {
	// ID is the unique identifier for this collection
	ID string

	// Name is the user-visible name of the collection
	Name string

	// Parent is the ID of the parent collection (empty string for root)
	Parent string

	// Type is always "CollectionType"
	Type string

	// ModifiedClient is when the collection was last modified
	ModifiedClient time.Time

	// Documents contains the documents in this collection
	Documents []Document

	// SubCollections contains nested collections
	SubCollections []Collection
}

Collection represents a reMarkable collection (folder)

type Config

type Config struct {
	// TokenPath is the path to store the authentication token
	TokenPath string

	// Logger is the logger instance to use
	Logger *logger.Logger

	// EnableTokenMonitoring enables token renewal tracking
	EnableTokenMonitoring bool

	// TokenStatsFile is the path to save token statistics (optional)
	TokenStatsFile string
}

Config holds configuration for the reMarkable client

type Content

type Content struct {
	// ExtraMetadata contains additional metadata
	ExtraMetadata ExtraMetadata `json:"extraMetadata"`

	// FileType is the type of file (e.g., "notebook", "pdf")
	FileType string `json:"fileType"`

	// FontName is the font name for text
	FontName string `json:"fontName"`

	// LastOpenedPage is the page number that was last opened
	LastOpenedPage int `json:"lastOpenedPage"`

	// LineHeight is the line height for text
	LineHeight int `json:"lineHeight"`

	// Margins is the page margins
	Margins int `json:"margins"`

	// Orientation is the page orientation (portrait/landscape)
	Orientation string `json:"orientation"`

	// PageCount is the number of pages
	PageCount int `json:"pageCount"`

	// Pages contains the page UUIDs
	Pages []string `json:"pages"`

	// TextScale is the text scaling factor
	TextScale int `json:"textScale"`

	// Transform contains transformation data
	Transform Transform `json:"transform"`
}

Content represents the .content file structure

type Document

type Document struct {
	// ID is the unique identifier for this document
	ID string

	// Version is the document version number
	Version int

	// Name is the user-visible name of the document
	Name string

	// ModifiedClient is when the document was last modified on the client
	ModifiedClient time.Time

	// Type is the document type (DocumentType or CollectionType)
	Type string

	// CurrentPage is the currently viewed page (for documents)
	CurrentPage int

	// Parent is the ID of the parent collection (empty string for root)
	Parent string

	// Tags is the list of tags applied to this document
	Tags []string
}

Document represents a reMarkable document or notebook

type ExtraMetadata

type ExtraMetadata struct {
	// LastBrushColor is the color of the last brush used
	LastBrushColor string `json:"LastBrushColor"`

	// LastBrushThicknessScale is the thickness scale of the last brush
	LastBrushThicknessScale string `json:"LastBrushThicknessScale"`

	// LastColor is the last color used
	LastColor string `json:"LastColor"`

	// LastEraserThicknessScale is the thickness scale of the last eraser
	LastEraserThicknessScale string `json:"LastEraserThicknessScale"`

	// LastEraserTool is the last eraser tool used
	LastEraserTool string `json:"LastEraserTool"`

	// LastPen is the last pen used
	LastPen string `json:"LastPen"`

	// LastPenColor is the color of the last pen
	LastPenColor string `json:"LastPenColor"`

	// LastPenThicknessScale is the thickness scale of the last pen
	LastPenThicknessScale string `json:"LastPenThicknessScale"`

	// LastPencil is the last pencil used
	LastPencil string `json:"LastPencil"`

	// LastPencilColor is the color of the last pencil
	LastPencilColor string `json:"LastPencilColor"`

	// LastPencilThicknessScale is the thickness scale of the last pencil
	LastPencilThicknessScale string `json:"LastPencilThicknessScale"`

	// LastTool is the last tool used
	LastTool string `json:"LastTool"`

	// ThicknessScale is the general thickness scale
	ThicknessScale string `json:"ThicknessScale"`
}

ExtraMetadata contains additional document metadata

type Metadata

type Metadata struct {
	// Deleted indicates if the document has been deleted
	Deleted bool `json:"deleted"`

	// LastModified is when the metadata was last modified
	LastModified string `json:"lastModified"`

	// LastOpened is when the document was last opened
	LastOpened string `json:"lastOpened"`

	// LastOpenedPage is the page number that was last opened
	LastOpenedPage int `json:"lastOpenedPage"`

	// MetadataModified indicates if metadata has been modified
	MetadataModified bool `json:"metadatamodified"`

	// Modified indicates if the document has been modified
	Modified bool `json:"modified"`

	// Parent is the ID of the parent collection
	Parent string `json:"parent"`

	// Pinned indicates if the document is pinned
	Pinned bool `json:"pinned"`

	// Synced indicates if the document has been synced
	Synced bool `json:"synced"`

	// Type is the document type ("DocumentType" or "CollectionType")
	Type string `json:"type"`

	// Version is the metadata version
	Version int `json:"version"`

	// VisibleName is the user-visible name
	VisibleName string `json:"visibleName"`
}

Metadata represents document metadata from .metadata files

type TokenMonitor added in v1.2.0

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

TokenMonitor tracks token renewal events and provides statistics

func NewTokenMonitor added in v1.2.0

func NewTokenMonitor(log *logger.Logger, statsFile string) *TokenMonitor

NewTokenMonitor creates a new token monitor

func (*TokenMonitor) GetStatistics added in v1.2.0

func (tm *TokenMonitor) GetStatistics() TokenStatistics

GetStatistics returns current token statistics

func (*TokenMonitor) PrintSummary added in v1.2.0

func (tm *TokenMonitor) PrintSummary()

PrintSummary prints a human-readable summary of token statistics

func (*TokenMonitor) RecordRenewal added in v1.2.0

func (tm *TokenMonitor) RecordRenewal(tokenType string, validFor time.Duration)

RecordRenewal records a token renewal event

type TokenRenewalEvent added in v1.2.0

type TokenRenewalEvent struct {
	Timestamp     time.Time `json:"timestamp"`
	TokenType     string    `json:"token_type"` // "user" or "device"
	ValidFor      string    `json:"valid_for"`
	TimeSinceLast string    `json:"time_since_last,omitempty"`
}

TokenRenewalEvent represents a single token renewal event

type TokenStatistics added in v1.2.0

type TokenStatistics struct {
	StartTime       time.Time           `json:"start_time"`
	LastUpdate      time.Time           `json:"last_update"`
	RenewalCount    int                 `json:"renewal_count"`
	RenewalEvents   []TokenRenewalEvent `json:"renewal_events"`
	AverageInterval string              `json:"average_interval,omitempty"`
}

TokenStatistics holds aggregated token statistics

type Transform

type Transform struct {
	// M11, M12, M13 are transformation matrix elements
	M11 float64 `json:"m11"`
	M12 float64 `json:"m12"`
	M13 float64 `json:"m13"`

	// M21, M22, M23 are transformation matrix elements
	M21 float64 `json:"m21"`
	M22 float64 `json:"m22"`
	M23 float64 `json:"m23"`

	// M31, M32, M33 are transformation matrix elements
	M31 float64 `json:"m31"`
	M32 float64 `json:"m32"`
	M33 float64 `json:"m33"`
}

Transform contains transformation data for pages

Jump to

Keyboard shortcuts

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