Documentation

Overview

Package rmapi implements reMarkable api, as described in https://github.com/splitbrain/ReMarkableAPI/wiki.

Index

Constants

This section is empty.

Variables

View Source
var RootDisplayName = "<ROOT>"

RootDisplayName is the display name to be used by the root directory.

Functions

This section is empty.

Types

type Client

type Client struct {
	RefreshToken string

	Logger logger.Logger
	// contains filtered or unexported fields
}

Client defines a reMarkable API client.

You can get it either by using Register with a new token, or construct directly from refresh token stored previously.

func Register

func Register(ctx context.Context, args RegisterArgs) (*Client, error)

Register registers a new token with reMarkable API server.

Upon success, it returns a *Client with RefreshToken set.

func (*Client) AutoRefresh

func (c *Client) AutoRefresh(ctx context.Context) error

AutoRefresh refreshes the token when needed.

func (*Client) ListDirs

func (c *Client) ListDirs(ctx context.Context) (map[string]string, error)

ListDirs lists all the directories user created on their reMarkable account.

The returned map is in format of <id> -> <display name>. When error is nil, the map is guaranteed to have at least an entry of "" -> RootDisplayName.

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context) error

Refresh refreshes the token.

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, args UploadArgs) error

Upload uploads a document to reMarkable.

type ContentArgs

type ContentArgs struct {
	Font string
}

ContentArgs defines the args to population InitialContent.

type FileType

type FileType int

FileType is an enum type defining the file type on reMarkable.

It's either epub or pdf.

const (
	FileTypeEpub FileType
	FileTypePdf
)

FileType values.

func (FileType) Ext

func (ft FileType) Ext() string

Ext returns the file extension of the given FileType.

func (FileType) InitialContent

func (ft FileType) InitialContent(args ContentArgs) (string, error)

InitialContent returns the initial .content file for the given FileType.

type ItemInfo

type ItemInfo struct {
	ID             string    `json:"ID,omitempty"`
	Type           string    `json:"Type,omitempty"`
	Name           string    `json:"VissibleName,omitempty"`
	Parent         string    `json:"Parent,omitempty"`
	Version        int       `json:"Version,omitempty"`
	UploadURL      string    `json:"BlobURLPut,omitempty"`
	ModifiedClient time.Time `json:"ModifiedClient,omitempty"`

	// responses only
	Message string `json:"Message,omitempty"`
	Success *bool  `json:"Success,omitempty"`
}

ItemInfo defines the json format of an item metadata.

Some of the fields are only used in requests and some of the fields are only used in responses, as a result it's important for all of them to have omitempty json tag.

func (ItemInfo) IsSuccess

func (i ItemInfo) IsSuccess() error

IsSuccess checks the Success field

func (ItemInfo) ToMetadata

func (i ItemInfo) ToMetadata() ItemMetadata

ToMetadata converts ItemInfo into ItemMetadata

type ItemMetadata

type ItemMetadata struct {
	Type         string               `json:"type"`
	Name         string               `json:"visibleName"`
	Parent       string               `json:"parent"`
	Version      int                  `json:"version"`
	LastModified TimestampMillisecond `json:"lastModified"`
}

ItemMetadata defines the json format for the .metadata files.

type RegisterArgs

type RegisterArgs struct {
	// A token got from either https://my.remarkable.com/connect/desktop or
	// https://my.remarkable.com/connect/mobile, usually with length of 8.
	Token string

	// A description of this device, usually something like "desktop-linux",
	// "mobile-android".
	Description string
}

RegisterArgs defines args to be used with Register.

type TimestampMillisecond

type TimestampMillisecond time.Time

TimestampMillisecond is used to marshal timestamp into milliseconds since unix epoch in json.

func (TimestampMillisecond) MarshalJSON

func (ts TimestampMillisecond) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

It converts time into milliseconds since unix epoch, but omits any sub-second precision.

type UploadArgs

type UploadArgs struct {
	ID    string
	Title string

	Data io.Reader
	Type FileType

	// Optional
	ParentID    string
	ContentArgs ContentArgs
}

UploadArgs defines the args used by Upload function.