api

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package api holds the JSON types of Fundarr's read API (/api/v1, see docs/api.md), so a Go app decodes the answers straight into them, and turns a copy of the history into what pkg/model and pkg/portfolio take:

var page api.Changes // GET /api/v1/changes?after=<cursor>
json.NewDecoder(resp.Body).Decode(&page)
copy.Apply(page) // copy is an api.Copy, kept with page.Cursor
acts, transfers := copy.Ledger()
now := portfolio.Now(acts, transfers, prices, time.Now())

Index

Constants

View Source
const (
	Upsert = "upsert" // add or replace the activity
	Remove = "remove" // delete it
)

Change kinds.

Variables

This section is empty.

Functions

func Ledger

func Ledger(list []Activity) ([]model.Activity, map[string]string)

Ledger returns the activities oldest first, and the transfers between your own sources Fundarr paired, as a deposit's id → its withdrawal's id: the two arguments of model.Books, portfolio.Now, History and TaxFR.

Types

type Activity

type Activity struct {
	model.Activity
	Source Source `json:"source"`
	// Cost: what an incoming asset cost, in Currency (bought with cash,
	// carried over a transfer, or valued at the day's price). Not in the
	// changes feed.
	Cost     string `json:"cost,omitempty"`
	Currency string `json:"currency,omitempty"`
	// TransferWith: the other side of a move between your own accounts.
	TransferWith string `json:"transferWith,omitempty"`
	// Correction: made by Fundarr's balance check, not by the platform.
	Correction bool `json:"correction,omitempty"`
}

Activity is an activity with what Fundarr worked out across sources, as /api/v1/activities and /api/v1/changes serve it.

type Change

type Change struct {
	Op       string    `json:"op"`
	ID       string    `json:"id"`
	Activity *Activity `json:"activity,omitempty"`
}

Change is one entry of the changes feed; Activity is nil on removals.

type Changes

type Changes struct {
	Changes []Change `json:"changes"`
	Cursor  string   `json:"cursor"`
	More    bool     `json:"more"`
}

Changes is one answer of GET /api/v1/changes: pass Cursor as after next time, and call again right away while More is true.

type Copy

type Copy map[string]Activity

Copy is a copy of the history kept from the changes feed, by id.

func (Copy) Apply

func (c Copy) Apply(page Changes)

Apply applies a page of changes, in order.

func (Copy) Ledger

func (c Copy) Ledger() ([]model.Activity, map[string]string)

Ledger returns the copy as Ledger does.

type Source

type Source struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Kind string `json:"kind"`
}

Source is a configured exchange or wallet.

Jump to

Keyboard shortcuts

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