rawapi

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package rawapi is a statically-typed layer over the wire client with one function per REST endpoint. Each endpoint has a typed request struct and a typed response struct (or element slice for an array response), and a method that builds the ordered wire parameters, issues exactly one call through the wire client under a caller-supplied policy, and returns the decoded typed value alongside the verbatim response bytes.

The layer is static: it carries no runtime catalog, spec, documentation registry, or validation engine. It holds no retry or idempotency policy — the caller supplies the policy for the single call each function issues. Money and quantity values are decimal strings end to end and pass through untouched.

Ordered parameters follow the wire declaration order: positionals first, then the remaining parameters, with absent optional parameters omitted. The wire client signs the exact encoded parameter string it sends, so this ordering is the signing-byte contract.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	Currency        string `json:"currency"`
	Balance         string `json:"balance"`
	Available       string `json:"available"`
	TradeInUse      string `json:"tradeInUse"`
	WithdrawalInUse string `json:"withdrawalInUse"`
	AvgPrice        string `json:"avgPrice"`
}

Balance is one asset's balance.

type BalanceRequest

type BalanceRequest struct {
	Currencies *string
	AccountSeq *int
}

BalanceRequest fetches account balances. Currencies is the optional comma-separated asset filter.

type Candle

type Candle struct {
	Timestamp int64  `json:"timestamp"`
	Open      string `json:"open"`
	High      string `json:"high"`
	Low       string `json:"low"`
	Close     string `json:"close"`
	Volume    string `json:"volume"`
}

Candle is one candlestick.

type CandlesRequest

type CandlesRequest struct {
	Symbol   Symbol
	Interval string
	// Limit is required: the endpoint rejects a missing or out-of-range limit
	// (1..200) with BAD_REQUEST "limit out of range", so it is a value, not a
	// pointer — every call must carry one.
	Limit     int
	StartTime *int
	EndTime   *int
}

CandlesRequest is one symbol's candle request. Interval is required; the time bounds are optional.

type Client

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

Client is the typed endpoint layer over a wire client. It is configured once (with a Doer, a *korbit.Client in production) and reused; safety for concurrent use matches the wrapped client.

func New

func New(wire Doer, log *slog.Logger) *Client

New wraps a wire client in the typed endpoint layer. log is the optional operational logger (nil = silent): the typed layer's one diagnostic is a typed-decode mismatch — the verbatim bytes did not fit the endpoint's typed view — logged at Debug so a --log-level debug run explains why a typed field (e.g. an order's id) came back empty even though the call succeeded. The wire layer below already logs the request target/status/timing; the typed layer adds nothing per call on the happy path. It never sees a secret (the signature is appended below it) and never logs the response body.

func (*Client) Balance

func (*Client) Candles

func (*Client) Currencies

func (*Client) DepositAddress

func (*Client) DepositAddresses

func (*Client) DepositGenerate

func (*Client) DepositHistory

func (*Client) DepositStatus

func (*Client) Fees

func (c *Client) Fees(ctx context.Context, req FeesRequest, pol korbit.Policy) ([]Fee, json.RawMessage, korbit.Meta, error)

func (*Client) Fills

func (*Client) KRWDeposit

func (*Client) KRWDeposits

func (*Client) KRWWithdraw

func (*Client) KRWWithdrawals

func (*Client) OrderGet

func (*Client) OrderHistory

func (c *Client) OrderHistory(ctx context.Context, req OrderHistoryRequest, pol korbit.Policy) ([]Order, json.RawMessage, korbit.Meta, error)

func (*Client) OrderOpen

func (c *Client) OrderOpen(ctx context.Context, req OrderOpenRequest, pol korbit.Policy) ([]Order, json.RawMessage, korbit.Meta, error)

func (*Client) Orderbook

func (*Client) Pairs

func (*Client) TickSize

TickSize returns the queried symbol's tick-size policy. The endpoint's data payload is an array (one element per symbol), so the typed value is a slice; a single-symbol query yields a one-element slice.

func (*Client) Ticker

func (*Client) Time

func (*Client) Trades

func (*Client) Whoami

func (*Client) WithdrawHistory

func (*Client) WithdrawStatus

type CoinDeposit

type CoinDeposit struct {
	ID               int64  `json:"id"`
	Currency         string `json:"currency"`
	Network          string `json:"network"`
	Address          string `json:"address"`
	SecondaryAddress string `json:"secondaryAddress,omitempty"`
	Status           string `json:"status"`
	Quantity         string `json:"quantity"`
	TransactionHash  string `json:"transactionHash"`
	CreatedAt        int64  `json:"createdAt"`
}

CoinDeposit is one crypto deposit record.

type CoinWithdrawal

type CoinWithdrawal struct {
	ID               int64  `json:"id"`
	Currency         string `json:"currency"`
	Network          string `json:"network"`
	Address          string `json:"address"`
	SecondaryAddress string `json:"secondaryAddress,omitempty"`
	Quantity         string `json:"quantity"`
	Fee              string `json:"fee"`
	Status           string `json:"status"`
	TransactionHash  string `json:"transactionHash,omitempty"`
	CreatedAt        int64  `json:"createdAt"`
}

CoinWithdrawal is one crypto withdrawal record.

type CurrenciesRequest

type CurrenciesRequest struct{}

CurrenciesRequest has no parameters.

type Currency

type Currency string

Currency is an asset symbol, e.g. "btc".

type CurrencyInfo

type CurrencyInfo struct {
	Name                          string            `json:"name"`
	FullName                      string            `json:"fullName"`
	WithdrawalMaxAmountPerRequest string            `json:"withdrawalMaxAmountPerRequest"`
	WithdrawalMinAmount           string            `json:"withdrawalMinAmount"`
	DefaultNetwork                string            `json:"defaultNetwork"`
	NetworkList                   []CurrencyNetwork `json:"networkList"`
}

CurrencyInfo is one supported cryptocurrency. NetworkList is absent for fiat.

type CurrencyNetwork

type CurrencyNetwork struct {
	Name             string          `json:"name"`
	WithdrawalStatus string          `json:"withdrawalStatus,omitempty"`
	DepositStatus    string          `json:"depositStatus,omitempty"`
	Raw              json.RawMessage `json:"-"`
}

CurrencyNetwork is one supported network for a currency. The network detail fields beyond name vary by asset, so the verbatim object is preserved in Raw alongside the common fields for the typed surface.

func (*CurrencyNetwork) UnmarshalJSON

func (n *CurrencyNetwork) UnmarshalJSON(b []byte) error

UnmarshalJSON keeps the verbatim network object in Raw while decoding the common fields, since the per-network detail set varies by asset.

type DepositAddress

type DepositAddress struct {
	Currency         string `json:"currency"`
	Network          string `json:"network"`
	Address          string `json:"address"`
	SecondaryAddress string `json:"secondaryAddress,omitempty"`
}

DepositAddress is a crypto deposit address.

type DepositAddressRequest

type DepositAddressRequest struct {
	Currency   Currency
	Network    *string
	AccountSeq *int
}

DepositAddressRequest shows the deposit address for one asset.

type DepositAddressesRequest

type DepositAddressesRequest struct {
	AccountSeq *int
}

DepositAddressesRequest lists deposit addresses. AccountSeq is main-only (the API accepts only 1); see the funding accountSeq note below.

type DepositGenerateRequest

type DepositGenerateRequest struct {
	Currency   Currency
	Network    *string
	AccountSeq *int
}

DepositGenerateRequest generates (or returns the existing) deposit address.

type DepositHistoryRequest

type DepositHistoryRequest struct {
	Currency   Currency
	Limit      *int
	AccountSeq *int
}

DepositHistoryRequest lists recent crypto deposits for an asset.

type DepositStatusRequest

type DepositStatusRequest struct {
	Currency      Currency
	CoinDepositID int
	AccountSeq    *int
}

DepositStatusRequest fetches one crypto deposit by id.

type Doer

type Doer interface {
	Do(ctx context.Context, call korbit.Call, pol korbit.Policy) (json.RawMessage, korbit.Meta, error)
}

Doer is the minimal wire surface the typed layer drives: one logical call executed under a policy. *korbit.Client satisfies it; an interface here keeps the typed layer testable with a scripted fake and documents that it needs nothing more than Do.

type Fee

type Fee struct {
	Symbol          string `json:"symbol"`
	BuyFeeCurrency  string `json:"buyFeeCurrency"`
	SellFeeCurrency string `json:"sellFeeCurrency"`
	MaxFeeRate      string `json:"maxFeeRate"`
	TakerFeeRate    string `json:"takerFeeRate"`
	MakerFeeRate    string `json:"makerFeeRate"`
}

Fee is one symbol's trading fee policy.

type FeesRequest

type FeesRequest struct {
	Symbol     *string
	AccountSeq *int
}

FeesRequest fetches the trading fee policy. Symbol is the optional comma-separated trading-pair filter.

type Fill

type Fill struct {
	Symbol      string `json:"symbol"`
	TradeID     int64  `json:"tradeId"`
	OrderID     int64  `json:"orderId"`
	Side        string `json:"side"`
	Price       string `json:"price"`
	Qty         string `json:"qty"`
	Amt         string `json:"amt"`
	TradedAt    int64  `json:"tradedAt"`
	IsTaker     bool   `json:"isTaker"`
	FeeCurrency string `json:"feeCurrency"`
	FeeQty      string `json:"feeQty"`
}

Fill is one executed trade.

type FillsRequest

type FillsRequest struct {
	Symbol     Symbol
	Limit      *int
	StartTime  *int
	EndTime    *int
	AccountSeq *int
}

FillsRequest lists your executed trades for a symbol.

type KRWDeposit

type KRWDeposit struct {
	ID        int64  `json:"id"`
	Status    string `json:"status"`
	Quantity  string `json:"quantity"`
	CreatedAt int64  `json:"createdAt"`
}

KRWDeposit is one KRW deposit record.

type KRWDepositRequest

type KRWDepositRequest struct {
	Amount     string
	AccountSeq *int
}

KRWDepositRequest sends a KRW-deposit push to the Korbit app.

type KRWDepositsRequest

type KRWDepositsRequest struct {
	Limit      *int
	AccountSeq *int
}

KRWDepositsRequest lists recent KRW deposits.

type KRWPushResponse

type KRWPushResponse struct {
	Success bool `json:"success,omitempty"`
}

KRWPushResponse is a KRW deposit/withdrawal push acknowledgement.

type KRWWithdrawRequest

type KRWWithdrawRequest struct {
	Amount     string
	AccountSeq *int
}

KRWWithdrawRequest sends a KRW-withdrawal push to the Korbit app.

type KRWWithdrawal

type KRWWithdrawal struct {
	ID        int64  `json:"id"`
	Quantity  string `json:"quantity"`
	Fee       string `json:"fee"`
	Status    string `json:"status"`
	CreatedAt int64  `json:"createdAt"`
}

KRWWithdrawal is one KRW withdrawal record.

type KRWWithdrawalsRequest

type KRWWithdrawalsRequest struct {
	Limit      *int
	AccountSeq *int
}

KRWWithdrawalsRequest lists recent KRW withdrawals.

type KeyInfo

type KeyInfo struct {
	APIKey             string   `json:"apiKey"`
	UserUUID           string   `json:"userUuid,omitempty"`
	Type               string   `json:"type"`
	PublicKey          string   `json:"publicKey,omitempty"`
	Permissions        []string `json:"permissions"`
	Whitelist          string   `json:"whitelist"`
	Expiration         int64    `json:"expiration"`
	Status             string   `json:"status"`
	Label              string   `json:"label"`
	AllowedAccountSeqs []int    `json:"allowedAccountSeqs"`
	CreatedAt          int64    `json:"createdAt"`
}

KeyInfo is the current API key's metadata.

type Order

type Order struct {
	OrderID       int64  `json:"orderId"`
	ClientOrderID string `json:"clientOrderId,omitempty"`
	Symbol        string `json:"symbol"`
	OrderType     string `json:"orderType"`
	Side          string `json:"side"`
	TimeInForce   string `json:"timeInForce"`
	Price         string `json:"price,omitempty"`
	Qty           string `json:"qty"`
	Amt           string `json:"amt,omitempty"`
	FilledQty     string `json:"filledQty"`
	FilledAmt     string `json:"filledAmt"`
	AvgPrice      string `json:"avgPrice,omitempty"`
	CreatedAt     int64  `json:"createdAt"`
	LastFilledAt  int64  `json:"lastFilledAt"`
	Status        string `json:"status"`
}

Order is the full order document returned by the order query endpoints.

type OrderCancelRequest

type OrderCancelRequest struct {
	Symbol        Symbol
	OrderID       *int
	ClientOrderID *string
	AccountSeq    *int
}

OrderCancelRequest cancels one open order by order id or clientOrderId.

type OrderCancelResponse

type OrderCancelResponse struct {
	Success bool `json:"success,omitempty"`
}

OrderCancelResponse is the cancel acknowledgement (a bare ack normalizes to success only).

type OrderGetRequest

type OrderGetRequest struct {
	Symbol        Symbol
	OrderID       *int
	ClientOrderID *string
	AccountSeq    *int
}

OrderGetRequest fetches one order by order id or clientOrderId.

type OrderHistoryRequest

type OrderHistoryRequest struct {
	Symbol     Symbol
	Limit      *int
	StartTime  *int
	EndTime    *int
	AccountSeq *int
}

OrderHistoryRequest lists recent orders for a symbol.

type OrderOpenRequest

type OrderOpenRequest struct {
	Symbol     Symbol
	Limit      *int
	AccountSeq *int
}

OrderOpenRequest lists open orders for a symbol.

type OrderPlaceRequest

type OrderPlaceRequest struct {
	Symbol        Symbol
	Side          Side
	OrderType     OrderType
	Price         *string
	Qty           *string
	Amt           *string
	TimeInForce   *TimeInForce
	BestNth       *int
	ClientOrderID *string
	PP            *bool
	PPPercent     *int
	AccountSeq    *int
}

OrderPlaceRequest is a place-order request. Symbol, Side, and OrderType are required; the remaining fields are optional and appended in wire declaration order only when set.

type OrderPlaceResponse

type OrderPlaceResponse struct {
	OrderID       int64  `json:"orderId"`
	ClientOrderID string `json:"clientOrderId,omitempty"`
}

OrderPlaceResponse is the place-order acknowledgement.

type OrderType

type OrderType string

OrderType is an order type.

const (
	OrderTypeLimit  OrderType = "limit"
	OrderTypeMarket OrderType = "market"
	OrderTypeBest   OrderType = "best"
)

type Orderbook

type Orderbook struct {
	Timestamp int64            `json:"timestamp"`
	Bids      []OrderbookLevel `json:"bids"`
	Asks      []OrderbookLevel `json:"asks"`
}

Orderbook is an orderbook snapshot.

type OrderbookLevel

type OrderbookLevel struct {
	Price string `json:"price"`
	Qty   string `json:"qty"`
	Amt   string `json:"amt,omitempty"`
}

OrderbookLevel is one price level in the orderbook. Amt is present only on some grouping levels.

type OrderbookRequest

type OrderbookRequest struct {
	Symbol Symbol
	Level  *string
}

OrderbookRequest is one symbol's orderbook request. Level is the optional price-grouping level.

type Pair

type Pair struct {
	Symbol string `json:"symbol"`
	Status string `json:"status"`
}

Pair is one trading pair and its status.

type PairsRequest

type PairsRequest struct{}

PairsRequest has no parameters.

type ServerTime

type ServerTime struct {
	Time int64 `json:"time"`
}

ServerTime is the Korbit server time.

type Side

type Side string

Side is an order side.

const (
	SideBuy  Side = "buy"
	SideSell Side = "sell"
)

type Symbol

type Symbol string

Symbol is a trading pair, e.g. "btc_krw".

type TickSizeBand

type TickSizeBand struct {
	PriceGte string `json:"priceGte"`
	TickSize string `json:"tickSize"`
}

TickSizeBand is one price band of the tick-size policy.

type TickSizePolicy

type TickSizePolicy struct {
	Symbol          string         `json:"symbol"`
	TickSizePolicy  []TickSizeBand `json:"tickSizePolicy"`
	OrderbookLevels []string       `json:"orderbookLevels"`
}

TickSizePolicy is a symbol's tick-size policy and orderbook grouping levels.

type TickSizeRequest

type TickSizeRequest struct {
	Symbol Symbol
}

TickSizeRequest is one symbol's tick-size request.

type Ticker

type Ticker struct {
	Symbol             string `json:"symbol"`
	Open               string `json:"open"`
	High               string `json:"high"`
	Low                string `json:"low"`
	Close              string `json:"close"`
	PrevClose          string `json:"prevClose"`
	PriceChange        string `json:"priceChange"`
	PriceChangePercent string `json:"priceChangePercent"`
	Volume             string `json:"volume"`
	QuoteVolume        string `json:"quoteVolume"`
	BestBidPrice       string `json:"bestBidPrice"`
	BestAskPrice       string `json:"bestAskPrice"`
	LastTradedAt       int64  `json:"lastTradedAt"`
}

Ticker is one symbol's latest price and 24h stats.

type TickerRequest

type TickerRequest struct {
	Symbol *string
}

TickerRequest selects the symbols to fetch. Symbol is the comma-separated wire parameter; an empty value omits it (all symbols).

type TimeInForce

type TimeInForce string

TimeInForce is an order time-in-force.

const (
	TimeInForceGTC TimeInForce = "gtc"
	TimeInForceIOC TimeInForce = "ioc"
	TimeInForceFOK TimeInForce = "fok"
	TimeInForcePO  TimeInForce = "po"
)

type TimeRequest

type TimeRequest struct{}

TimeRequest has no parameters.

type Trade

type Trade struct {
	Timestamp    int64  `json:"timestamp"`
	Price        string `json:"price"`
	Qty          string `json:"qty"`
	IsBuyerTaker bool   `json:"isBuyerTaker"`
	TradeID      int64  `json:"tradeId"`
}

Trade is one public trade.

type TradesRequest

type TradesRequest struct {
	Symbol Symbol
	Limit  *int
}

TradesRequest is one symbol's recent-trades request.

type WhoamiRequest

type WhoamiRequest struct{}

WhoamiRequest has no parameters.

type WithdrawAddressesRequest

type WithdrawAddressesRequest struct {
	AccountSeq *int
}

WithdrawAddressesRequest lists registered withdrawal addresses. AccountSeq is main-only (see the funding accountSeq note above).

type WithdrawAmountRequest

type WithdrawAmountRequest struct {
	Currency   *string
	AccountSeq *int
}

WithdrawAmountRequest fetches withdrawable amounts. Currency is optional (omit for all).

type WithdrawCancelRequest

type WithdrawCancelRequest struct {
	CoinWithdrawalID int
	AccountSeq       *int
}

WithdrawCancelRequest cancels a crypto withdrawal by id.

type WithdrawCancelResponse

type WithdrawCancelResponse struct {
	Success bool `json:"success,omitempty"`
}

WithdrawCancelResponse is the cancel acknowledgement.

type WithdrawHistoryRequest

type WithdrawHistoryRequest struct {
	Currency   Currency
	Limit      *int
	AccountSeq *int
}

WithdrawHistoryRequest lists recent crypto withdrawals for an asset.

type WithdrawRequestRequest

type WithdrawRequestRequest struct {
	Currency         Currency
	Amount           string
	Address          string
	Network          *string
	SecondaryAddress *string
	AccountSeq       *int
}

WithdrawRequestRequest requests a crypto withdrawal to a registered address. Amount and Address are required; Network and SecondaryAddress are optional and appended in declaration order when set.

type WithdrawRequestResponse

type WithdrawRequestResponse struct {
	Status           string `json:"status"`
	CoinWithdrawalID int64  `json:"coinWithdrawalId"`
}

WithdrawRequestResponse is the withdrawal-request acknowledgement.

type WithdrawStatusRequest

type WithdrawStatusRequest struct {
	Currency         Currency
	CoinWithdrawalID int
	AccountSeq       *int
}

WithdrawStatusRequest fetches one crypto withdrawal by id.

type WithdrawableAddress

type WithdrawableAddress struct {
	Network          string `json:"network"`
	Currency         string `json:"currency,omitempty"`
	Address          string `json:"address"`
	SecondaryAddress string `json:"secondaryAddress,omitempty"`
}

WithdrawableAddress is one address registered for API withdrawals.

type WithdrawableAmount

type WithdrawableAmount struct {
	Currency              string `json:"currency"`
	WithdrawableAmount    string `json:"withdrawableAmount"`
	WithdrawalInUseAmount string `json:"withdrawalInUseAmount"`
}

WithdrawableAmount is one asset's withdrawable amount.

Jump to

Keyboard shortcuts

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