api

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	CurrencyCode string `json:"currency_code"`
	Amount       string `json:"amount"`
}

Balance represents a currency balance.

type Category

type Category struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type Client

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

Client is a Splitwise API client.

func New

func New() (*Client, error)

New creates a new authenticated API client.

func (*Client) CreateExpense

func (c *Client) CreateExpense(p CreateExpenseParams) (*Expense, error)

CreateExpense creates a new expense.

func (*Client) CreatePayment

func (c *Client) CreatePayment(p CreateExpenseParams) (*Expense, error)

CreatePayment records a settlement (payment) between users.

func (*Client) DeleteExpense

func (c *Client) DeleteExpense(id int64) error

DeleteExpense deletes an expense by ID.

func (*Client) GetCurrentUser

func (c *Client) GetCurrentUser() (*User, error)

GetCurrentUser returns the authenticated user.

func (*Client) GetExpenses

func (c *Client) GetExpenses(p GetExpensesParams) ([]Expense, error)

GetExpenses returns expenses matching the given criteria.

func (*Client) GetFriends

func (c *Client) GetFriends() ([]Friend, error)

GetFriends returns all friends for the current user.

func (*Client) GetGroup

func (c *Client) GetGroup(id int64) (*Group, error)

GetGroup returns a single group by ID.

func (*Client) GetGroups

func (c *Client) GetGroups() ([]Group, error)

GetGroups returns all groups for the current user.

func (*Client) ResolveFriendByName

func (c *Client) ResolveFriendByName(name string) (*Friend, error)

ResolveFriendByName finds a friend by name (case-insensitive).

func (*Client) ResolveGroupByName

func (c *Client) ResolveGroupByName(name string) (*Group, error)

ResolveGroupByName finds a group ID by name (case-insensitive partial match).

type CreateExpenseParams

type CreateExpenseParams struct {
	Description  string
	Cost         string
	CurrencyCode string
	GroupID      int64
	SplitEqually bool
	Date         string
	// For by-shares split: user_id -> {paid_share, owed_share}
	Shares []ShareParam
}

CreateExpenseParams holds parameters for creating an expense.

type Debt

type Debt struct {
	From         int64  `json:"from"`
	To           int64  `json:"to"`
	Amount       string `json:"amount"`
	CurrencyCode string `json:"currency_code"`
}

Debt represents a debt between two users.

type Expense

type Expense struct {
	ID           int64          `json:"id"`
	GroupID      *int64         `json:"group_id"`
	Description  string         `json:"description"`
	Cost         string         `json:"cost"`
	CurrencyCode string         `json:"currency_code"`
	Date         string         `json:"date"`
	Payment      bool           `json:"payment"`
	CreatedAt    string         `json:"created_at"`
	UpdatedAt    string         `json:"updated_at"`
	DeletedAt    *string        `json:"deleted_at"`
	Details      *string        `json:"details"`
	Repayments   []Repayment    `json:"repayments"`
	Users        []ExpenseShare `json:"users"`
	Category     *Category      `json:"category"`
	CreatedBy    *User          `json:"created_by"`
}

Expense represents a Splitwise expense.

type ExpenseShare

type ExpenseShare struct {
	UserID     int64  `json:"user_id"`
	PaidShare  string `json:"paid_share"`
	OwedShare  string `json:"owed_share"`
	NetBalance string `json:"net_balance"`
	User       *User  `json:"user"`
}

type Friend

type Friend struct {
	ID        int64         `json:"id"`
	FirstName string        `json:"first_name"`
	LastName  string        `json:"last_name"`
	Email     string        `json:"email"`
	Balance   []Balance     `json:"balance"`
	Groups    []FriendGroup `json:"groups"`
}

Friend represents a Splitwise friend.

type FriendGroup

type FriendGroup struct {
	GroupID int64     `json:"group_id"`
	Balance []Balance `json:"balance"`
}

type GetExpensesParams

type GetExpensesParams struct {
	GroupID     int64
	FriendID    int64
	DatedAfter  string
	DatedBefore string
	Limit       int
	Offset      int
}

GetExpensesParams holds query parameters for listing expenses.

type Group

type Group struct {
	ID                int64         `json:"id"`
	Name              string        `json:"name"`
	GroupType         string        `json:"group_type"`
	UpdatedAt         string        `json:"updated_at"`
	SimplifyByDefault bool          `json:"simplify_by_default"`
	Members           []GroupMember `json:"members"`
	OriginalDebts     []Debt        `json:"original_debts"`
	SimplifiedDebts   []Debt        `json:"simplified_debts"`
	InviteLink        string        `json:"invite_link,omitempty"`
}

Group represents a Splitwise group.

type GroupMember

type GroupMember struct {
	ID        int64     `json:"id"`
	FirstName string    `json:"first_name"`
	LastName  string    `json:"last_name"`
	Email     string    `json:"email"`
	Balance   []Balance `json:"balance"`
}

GroupMember is a user with group-specific balance info.

type Repayment

type Repayment struct {
	From   int64  `json:"from"`
	To     int64  `json:"to"`
	Amount string `json:"amount"`
}

type ShareParam

type ShareParam struct {
	UserID    int64
	PaidShare string
	OwedShare string
}

type User

type User struct {
	ID                 int64        `json:"id"`
	FirstName          string       `json:"first_name"`
	LastName           string       `json:"last_name"`
	Email              string       `json:"email"`
	RegistrationStatus string       `json:"registration_status"`
	DefaultCurrency    string       `json:"default_currency,omitempty"`
	Locale             string       `json:"locale,omitempty"`
	NotificationsCount int          `json:"notifications_count,omitempty"`
	Picture            *UserPicture `json:"picture,omitempty"`
}

User represents a Splitwise user.

type UserPicture

type UserPicture struct {
	Small  string `json:"small"`
	Medium string `json:"medium"`
	Large  string `json:"large"`
}

Jump to

Keyboard shortcuts

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