GOLANG Integration with Advanced Trade API

Hello, I’ve been trying to just get the Golang example to work for v3 and it doesn’t seem to work. I first tried copying it into Go playland just to run it and it said unauthorized. That makes sense and has been already addressed in another post (Advance Trade API - Market Data - #2 by jmicko).

However, I’ve added authentication and verified that my keys are correct. I still get unauthorized. Here is the goplayland (Go Playground - The Go Programming Language). This probably wont work on there because I’m not going to post my keys and goplayland doesn’t allow this type of comms but if you just paste it into a main.go file you can add your key/secret and see that it doesn’t work. I’m not sure what else to do… I think the signature is correct. Thanks!

  • Nick
1 Like

Hello @Segfault! Thank you for taking an interest in trying out Coinbase APIs. For the details regarding your inquiry, we will check on this for you with our team to see how we can best assist. We’ll get back to you once we have more information. Keep in touch!

1 Like

Nick -

From our soon to be open-sourced Go client library for Coinbase Adv API. Here’s the signature compute and headers.

func (c *Client) apiKeyAuth(req *http.Request, reqPath string, body []byte) {

	// The CB-ACCESS-SIGN header is generated by creating a sha256 HMAC object
	// using the API secret key on the string timestamp + method + requestPath + body.

	ts := strconv.FormatInt(time.Now().UTC().Unix(), 10)
	message := ts + req.Method + reqPath + string(body)
	h := hmac.New(sha256.New, []byte(c.ApiSKey))
	signature := hex.EncodeToString(h.Sum(nil))

	req.Header.Set("CB-ACCESS-KEY", c.ApiKey)
	req.Header.Set("CB-ACCESS-TIMESTAMP", ts)
	req.Header.Set("CB-ACCESS-SIGN", signature)

Thanks for your responses. Couple of questions.

Do you have a full working example in Golang for making a request? Also, do you know when the client will become available? Thanks!

1 Like

Okay, never mind it worked. Here is a working example in case anyone else runs into this issue.

Example (Go Playground - The Go Programming Language)


Yes, we have full working examples for all of the APIs we’ve implemented.

accounts, orders, fills, prices.

I’m discussing with my team right now when we can publish. It should be possible to pub an initial rev early next week

1 Like

Are you going to be including mocks or at least the implementation is based off of an interface so it can be mocked?

1 Like

That’s a good call. I’ll make sure it gets exposed via an interface so it can be mocked.

1 Like

Awesome, glad to hear it. Thanks!

1 Like

Hey guys, one more quick question. Is there a sandbox mode? A way to not hit a live API?

1 Like

I’d like to see a sandbox mode too, but other postings here seem to indicate that it isn’t in the plan.

The Go repo is now public and the go module is fetchable via go install.
Repo: GitHub - QuantFu-Inc/coinbase-adv: Go implementation for Coinbase Advanced Trading API

Hey Jason,

Is it possible to get a new tag after the pull request with the context included? Thanks!

Was done a few days ago… fyi.