github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/examples/v2/ws-private/main.go (about) 1 package main 2 3 import ( 4 "log" 5 "os" 6 "time" 7 8 "github.com/bitfinexcom/bitfinex-api-go/v2/websocket" 9 ) 10 11 // Set BFX_API_KEY and BFX_API_SECRET as : 12 // 13 // export BFX_API_KEY=YOUR_API_KEY 14 // export BFX_API_SECRET=YOUR_API_SECRET 15 // 16 // you can obtain it from https://www.bitfinex.com/api 17 18 func main() { 19 20 uri := os.Getenv("BFX_API_URI") 21 key := os.Getenv("BFX_API_KEY") 22 secret := os.Getenv("BFX_API_SECRET") 23 p := websocket.NewDefaultParameters() 24 p.URL = uri 25 c := websocket.NewWithParams(p).Credentials(key, secret) 26 27 err := c.Connect() 28 if err != nil { 29 log.Fatalf("connecting authenticated websocket: %s", err) 30 } 31 go func() { 32 for msg := range c.Listen() { 33 log.Printf("MSG RECV: %#v", msg) 34 } 35 }() 36 37 //ctx, _ := context.WithTimeout(context.Background(), time.Second*1) 38 //c.Authenticate(ctx) 39 40 time.Sleep(time.Second * 10) 41 }