Skip to content

aarjaneiro/advanced-trade-sdk-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Advanced Trade Go SDK README

GoDoc Go Report Card

Overview

The Advanced Trade Go SDK is a sample library that demonstrates the structure of a Coinbase Advanced Trade driver for the REST APIs.

License

The Advanced Trade Go SDK sample library is free and open source and released under the Apache License, Version 2.0.

The application and code are only available for demonstration purposes.

Usage

To use the Advanced Trade Go SDK, initialize the Credentials struct and create a new client. The Credentials struct is JSON enabled. Ensure that Advanced Trade API credentials are stored in a secure manner.

credentials := &adv.Credentials{}
if err := json.Unmarshal([]byte(os.Getenv("ADV_CREDENTIALS")), credentials); err != nil {
    return nil, fmt.Errorf("unable to deserialize advanced trade credentials JSON: %w", err)
}

client := adv.NewClient(credentials, http.Client{})

There are convenience functions to read the credentials as an environment variable (adv.ReadEnvCredentials) and to deserialize the JSON structure (adv.UnmarshalCredentials) if pulled from a different source. The JSON format expected by both is:

{
  "accessKey": "",
  "privatePemKey": "",
}

Coinbase Advanced Trade API credentials can be created in the CDP web portal.

Once the client is initialized, make the desired call. For example, to list portfolios, pass in the request object, check for an error, and if nil, process the response.

response, err := client.ListPortfolios(ctx, &adv.ListPortfoliosRequest{})

Build

To build the sample library, ensure that Go 1.19+ is installed and then run:

go build *.go

About

Sample Go SDK for the Coinbase Advanced Trade REST APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%