gateio

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Overview

Package gateio is the library behind the gateio command line: the HTTP client, request shaping, and typed data models for Gate.io public API.

The Client is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries transient failures (429 and 5xx). No API key is required — all operations use public endpoints.

Index

Constants

View Source
const BaseURL = "https://" + Host

BaseURL is the root every request is built from.

View Source
const DefaultUserAgent = "gateio-cli/0.1 (tamnd87@gmail.com)"

DefaultUserAgent identifies the client politely.

View Source
const Host = "api.gateio.ws"

Host is the Gate.io API host.

Variables

This section is empty.

Functions

This section is empty.

Types

type Candle

type Candle struct {
	Time     string `kit:"id" json:"time"`
	High     string `json:"high"`
	Low      string `json:"low"`
	Close    string `json:"close"`
	BaseVol  string `json:"base_vol"`
	QuoteVol string `json:"quote_vol"`
}

Candle holds one OHLCV candlestick record. Note: Gate.io's public spot/candlesticks endpoint does not return an open price.

type Client

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

Client talks to the Gate.io public REST API.

func NewClient

func NewClient() *Client

NewClient returns a Client configured with DefaultConfig.

func (*Client) Candles

func (c *Client) Candles(ctx context.Context, pair, interval string, limit int) ([]*Candle, error)

Candles returns OHLCV candlestick data for a currency pair.

func (*Client) Orderbook

func (c *Client) Orderbook(ctx context.Context, pair string, depth int) ([]*Order, error)

Orderbook returns the bid and ask depth for a currency pair.

func (*Client) Pairs

func (c *Client) Pairs(ctx context.Context, quote string, limit int) ([]*Pair, error)

Pairs returns available spot currency pairs, optionally filtered by quote currency.

func (*Client) Ticker

func (c *Client) Ticker(ctx context.Context, pair string) (*Ticker, error)

Ticker returns the current price and stats for a currency pair.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds all tunable settings for a Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns safe, polite defaults.

type Domain

type Domain struct{}

Domain is the Gate.io driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every Gate.io operation onto app.

type Order

type Order struct {
	Side  string `kit:"id" json:"side"`
	Price string `json:"price"`
	Size  string `json:"size"`
}

Order is a single entry in the order book (one price level on one side).

type Pair

type Pair struct {
	ID     string `kit:"id" json:"id"`
	Base   string `json:"base"`
	Quote  string `json:"quote"`
	Fee    string `json:"fee"`
	Status string `json:"status"`
}

Pair is a tradable currency pair on Gate.io.

type Ticker

type Ticker struct {
	Pair          string `kit:"id" json:"pair"`
	Last          string `json:"last"`
	Bid           string `json:"bid"`
	Ask           string `json:"ask"`
	ChangePercent string `json:"change_percent"`
	BaseVol       string `json:"base_vol"`
	QuoteVol      string `json:"quote_vol"`
	High24h       string `json:"high_24h"`
	Low24h        string `json:"low_24h"`
}

Ticker holds current price and 24h stats for a currency pair.

Jump to

Keyboard shortcuts

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