go-ftx go-ftx is a Go client library for accessing the FTX API

go-ftx

Test Lint codecov Go Report Card

go-ftx is a Go client library for accessing the FTX API.

Install

go get github.com/cloudingcity/go-ftx

Quick Start

package main

import (
	"fmt"
	"log"

	"github.com/cloudingcity/go-ftx/ftx"
)

func main() {
	client := ftx.New()
	market, err := client.Markets.Get("ETH/USD")
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Printf("%+v", market)
}

Examples

REST API

package main

import (
	"fmt"
	"log"

	"github.com/cloudingcity/go-ftx/ftx"
)

func main() {
	client := ftx.New(
		ftx.WithAuth("your-api-key", "your-api-secret"),
		ftx.WithSubaccount("your-subaccount"), // Omit if not using subaccounts
	)
	account, err := client.Accounts.GetInformation()
	if err != nil {
		log.Fatal()
	}
	fmt.Printf("%+v", account)
}

Websocket

package main

import (
	"fmt"
	"log"

	"github.com/cloudingcity/go-ftx/ftx"
	"github.com/cloudingcity/go-ftx/ftx/stream"
)

func main() {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	client := ftx.New(
		ftx.WithAuth("your-api-key", "your-api-secret"),
		ftx.WithSubaccount("your-subaccount"), // Omit if not using subaccounts
	)
	conn, err := client.Connect()
	if err != nil {
		log.Fatal(err)
	}
	
	conn.PingRegular(ctx, 50*time.Second) // Keep connection prevent read timeout

	// Ping
	if err := conn.Ping(); err != nil {
		log.Fatal(err)
	}

	// Public Channels
	if err := conn.Subscribe(stream.ChannelTicker, "BTC/USD"); err != nil {
		log.Fatal(err)
	}
	if err := conn.Subscribe(stream.ChannelTrades, "BTC/USD"); err != nil {
		log.Fatal(err)
	}

	// Private Channels
	if err := conn.Login(); err != nil {
		log.Fatal(err)
	}
	if err := conn.Subscribe(stream.ChannelFills); err != nil {
		log.Fatal(err)
	}
	if err := conn.Subscribe(stream.ChannelOrders); err != nil {
		log.Fatal(err)
	}

	for {
		resp, err := conn.Recv()
		if err != nil {
			log.Fatal(err)
			return
		}

		switch v := resp.(type) {
		case stream.General:
			fmt.Println("general:", v)
		case stream.Pong:
			fmt.Println("pong:", v)
		case stream.OrderBook:
			fmt.Println("orderbook:", v)
		case stream.Trade:
			fmt.Println("trade:", v)
		case stream.Ticker:
			fmt.Println("ticker:", v)
		case stream.Fills:
			fmt.Println("fills:", v)
		case stream.Orders:
			fmt.Println("orders:", v)
		case stream.Error:
			fmt.Println("error:", v)
		}
	}
}

Todos

  • REST API
    • Marktes
    • Accounts
    • Subaccounts
    • Futures
    • Wallet
    • Orders
    • Convert
    • Spot Margin
    • Fills
    • Funding Payments
    • Leveraged Tokens
    • Options
    • Staking
  • Websocket API
    • Ping
    • OrderBooks
    • Trade
    • Ticker
    • Markets
    • Grouped Orderbooks
    • Fills
    • Orders
Owner
Clouding
Backend engineer 😖
Clouding
Similar Resources

🤖🚀📦 A Discord Bot for accessing the cdnjs platform

🤖🚀📦 A Discord Bot for accessing the cdnjs platform

A bridge between https://cdnjs.com/api and Discord Big shoutout to Br1ght0ne for helping me with writing helpers.go/SplitIn

Aug 17, 2022

efsu is for accessing AWS EFS from your machine without a VPN

efsu: VPN-less access to AWS EFS efsu is for accessing AWS EFS from your machine without a VPN. It achieves this by deploying a Lambda function and sh

Mar 11, 2022

Clusterpedia-client - clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

clusterpedia-client supports the use of native client-go mode to call the cluste

Jan 7, 2022

Client-go - Clusterpedia-client supports the use of native client-go mode to call the clusterpedia API

clusterpedia-client supports the use of native client-go mode to call the cluste

Dec 5, 2022

A Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

A Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

Kinesumer is a Go client implementing a client-side distributed consumer group client for Amazon Kinesis.

Jan 5, 2023

Nutanix-client-go - Go client for the Nutanix Prism V3 API

nutanix-client-go This repository contains portions of the Nutanix API client code in nutanix/terraform-provider-nutanix. It has been extracted to red

Jan 6, 2022

Aoe4-client - Client library for aoe4 leaderboards etc

AOE4 Client Overview This is a go client used to query AOE4 data from either the

Jan 18, 2022

Go client for the YNAB API. Unofficial. It covers 100% of the resources made available by the YNAB API.

YNAB API Go Library This is an UNOFFICIAL Go client for the YNAB API. It covers 100% of the resources made available by the YNAB API. Installation go

Oct 6, 2022

An API client for the Notion API implemented in Golang

An API client for the Notion API implemented in Golang

Dec 30, 2022
May 25, 2021
NotionGo is a Go client library for accessing the Notion API v1.

NotionGo (WIP) NotionGo is a Go client library for accessing the Notion API v1. Installation NotionGo is compatible with modern Go releases in module

May 22, 2021
Go library for accessing the MyAnimeList API: http://myanimelist.net/modules.php?go=api

go-myanimelist go-myanimelist is a Go client library for accessing the MyAnimeList API. Project Status The MyAnimeList API has been stable for years a

Sep 28, 2022
Go(lang) client library for accessing information of an Apache Mesos cluster.

megos Go(lang) client library for accessing an Apache Mesos cluster. Features Determine the Mesos leader Get the current state of every mesos node (ma

Sep 27, 2022
A GoLang wrapper for Politics & War's API. Forego the hassle of accessing the API directly!

A GoLang wrapper for Politics & War's API. Forego the hassle of accessing the API directly!

Mar 5, 2022
Go library for accessing the Codeship API v2

Codeship API v2 Client for Go Codeship API v2 client for Go. Documentation https://godoc.org/github.com/codeship/codeship-go Usage go get -u github.co

Sep 27, 2022
Go library for accessing the GitHub API

go-github go-github is a Go client library for accessing the GitHub API v3. Currently, go-github requires Go version 1.9 or greater. go-github tracks

Dec 30, 2022
Go library for accessing the Keycloak API

keycloak keycloak is a Go client library for accessing the Keycloak API. Installation go get github.com/zemirco/keycloak Usage package main import (

Dec 1, 2022
Go library for accessing the BlaBlaCar API

go-blablacar is a Go client library for accessing the BlaBlaCar API.

Nov 27, 2022
Go library for accessing trending repositories and developers at Github.
Go library for accessing trending repositories and developers at Github.

go-trending A package to retrieve trending repositories and developers from Github written in golang. This package were inspired by rochefort/git-tren

Dec 21, 2022